Skip to content

Commit 2b437e2

Browse files
committed
change week display rule
Signed-off-by: allencloud <allen.sun@daocloud.io>
1 parent f2145db commit 2b437e2

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

duration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func HumanDuration(d time.Duration) string {
2626
return fmt.Sprintf("%d hours", hours)
2727
} else if hours < 24*7*2 {
2828
return fmt.Sprintf("%d days", hours/24)
29-
} else if hours < 24*30*3 {
29+
} else if hours < 24*30*2 {
3030
return fmt.Sprintf("%d weeks", hours/24/7)
3131
} else if hours < 24*365*2 {
3232
return fmt.Sprintf("%d months", hours/24/30)

duration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func TestHumanDuration(t *testing.T) {
7171
assertEquals(t, "4 weeks", HumanDuration(1*month))
7272
assertEquals(t, "6 weeks", HumanDuration(1*month+2*week))
7373
assertEquals(t, "8 weeks", HumanDuration(2*month))
74+
assertEquals(t, "2 months", HumanDuration(2*month+2*week))
7475
assertEquals(t, "3 months", HumanDuration(3*month+1*week))
7576
assertEquals(t, "5 months", HumanDuration(5*month+2*week))
7677
assertEquals(t, "13 months", HumanDuration(13*month))

0 commit comments

Comments
 (0)