diff --git a/date.go b/date.go index ed022dd..74d11ec 100644 --- a/date.go +++ b/date.go @@ -130,9 +130,9 @@ func durationRound(duration interface{}) string { return strconv.FormatUint(u/day, 10) + "d" case u > hour: return strconv.FormatUint(u/hour, 10) + "h" - case u > minute: + case u >= minute: return strconv.FormatUint(u/minute, 10) + "m" - case u > second: + case u >= second: return strconv.FormatUint(u/second, 10) + "s" } return "0s" diff --git a/date_test.go b/date_test.go index be7ec9d..69846ab 100644 --- a/date_test.go +++ b/date_test.go @@ -117,4 +117,7 @@ func TestDurationRound(t *testing.T) { if err := runtv(tpl, "3mo", map[string]interface{}{"Time": "2400h5s"}); err != nil { t.Error(err) } + if err := runtv(tpl, "1m", map[string]interface{}{"Time": time.Duration(time.Second * 60)}); err != nil { + t.Error(err) + } }