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)
| 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. |
| 568 | func 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 |
| 585 | func ParseTimeDuration(ctx *cli.Context) (notBefore, notAfter api.TimeDuration, err error) { |
no outgoing calls
no test coverage detected
searching dependent graphs…