Skip to content

Commit

Permalink
durationRound: use '1m' instead of '60s' (same for 1h/60m)
Browse files Browse the repository at this point in the history
  • Loading branch information
abh committed Dec 1, 2024
1 parent 8cb06fe commit ab6eda5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions date.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit ab6eda5

Please sign in to comment.