ParseDurationInSeconds parses input s, removes ms/us/ns and returns result duration
(s string)
| 7 | |
| 8 | // ParseDurationInSeconds parses input s, removes ms/us/ns and returns result duration |
| 9 | func ParseDurationInSeconds(s string) (time.Duration, error) { |
| 10 | d, err := time.ParseDuration(s) |
| 11 | if err != nil { |
| 12 | return 0, err |
| 13 | } |
| 14 | |
| 15 | d = d.Truncate(time.Second) |
| 16 | if d <= 0 { |
| 17 | return 0, errors.New(`duration must be greater than 0s`) |
| 18 | } |
| 19 | |
| 20 | return d, nil |
| 21 | } |
no outgoing calls
no test coverage detected