diff --git a/util.go b/util.go index 0d3a181..cb7f0ee 100644 --- a/util.go +++ b/util.go @@ -4,6 +4,7 @@ import ( "reflect" "strconv" "strings" + "time" ) // extractTypeInternal gets the actual underlying type of field value. @@ -229,6 +230,15 @@ func asInt(param string) int64 { return i } +// asIntFromTimeDuration parses param as time.Duration and returns it as int64 +// or panics on error. +func asIntFromTimeDuration(param string) int64 { + d, err := time.ParseDuration(param) + panicIf(err) + + return int64(d) +} + // asUint returns the parameter as a uint64 // or panics if it can't convert func asUint(param string) uint64 {