From ab6eda56b69e96a1bf45272fc94f77edc00cd127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Sat, 30 Nov 2024 19:32:19 -0800 Subject: [PATCH] durationRound: use '1m' instead of '60s' (same for 1h/60m) --- date.go | 4 ++-- date_test.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/date.go b/date.go index ed022dda..74d11eca 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 be7ec9d9..69846ab2 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) + } }