mirror of https://github.com/containrrr/watchtower
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
398 B
Go
16 lines
398 B
Go
package util
|
|
|
|
import (
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
// ParseDuration parses the input string as a duration, treating a plain number as implicitly using the specified unit
|
|
func ParseDuration(input string, unitlessUnit time.Duration) (time.Duration, error) {
|
|
if unitless, err := strconv.Atoi(input); err == nil {
|
|
return unitlessUnit * time.Duration(unitless), nil
|
|
}
|
|
|
|
return time.ParseDuration(input)
|
|
}
|