MCPcopy
hub / github.com/smallstep/cli / ParseTimeOrDuration

Function ParseTimeOrDuration

flags/flags.go:568–582  ·  view source on GitHub ↗

ParseTimeOrDuration is a helper that returns the time or the current time with an extra duration. It's used in flags like --not-before, --not-after.

(s string)

Source from the content-addressed store, hash-verified

566// ParseTimeOrDuration is a helper that returns the time or the current time
567// with an extra duration. It's used in flags like --not-before, --not-after.
568func ParseTimeOrDuration(s string) (time.Time, bool) {
569 if s == "" {
570 return time.Time{}, true
571 }
572
573 var t time.Time
574 if err := t.UnmarshalText([]byte(s)); err != nil {
575 d, err := time.ParseDuration(s)
576 if err != nil {
577 return time.Time{}, false
578 }
579 t = time.Now().Add(d)
580 }
581 return t, true
582}
583
584// ParseTimeDuration parses the not-before and not-after flags as a timeDuration
585func ParseTimeDuration(ctx *cli.Context) (notBefore, notAfter api.TimeDuration, err error) {

Callers 4

verifyActionFunction · 0.92
signActionFunction · 0.92
createActionFunction · 0.92
tokenActionFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…