Skip to content

Commit

Permalink
Don't print 3µs in duration strings
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Feb 21, 2022
1 parent 2f8222e commit 1f44606
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions internal/output/humanize.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ func HumanizeDuration(d time.Duration) string {
minutes := int64(math.Mod(d.Minutes(), 60))
seconds := int64(math.Mod(d.Seconds(), 60))
ms := int64(math.Mod(float64(d.Milliseconds()), 1000))
mc := int64(math.Mod(float64(d.Microseconds()), 1000))

chunks := []struct {
singularName string
Expand All @@ -26,7 +25,6 @@ func HumanizeDuration(d time.Duration) string {
{"m", minutes},
{"s", seconds},
{"ms", ms},
{"µs", mc},
}

parts := []string{}
Expand Down
4 changes: 2 additions & 2 deletions internal/output/humanize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestHumanizeDuration(t *testing.T) {
},
{
input: time.Microsecond * 3,
output: "3µs",
output: "0",
},
{
input: time.Millisecond * 542,
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestHumanizeDuration(t *testing.T) {
},
{
input: (time.Hour * (24*7*14 + 24*6 + 3)) + time.Minute*33 + time.Second*3 + time.Millisecond + 999 + time.Microsecond*5,
output: "14w6d3h33m3s1ms5µs",
output: "14w6d3h33m3s1ms",
},
}

Expand Down

0 comments on commit 1f44606

Please sign in to comment.