From 58f309bec46b355e5d74bb0ba9e7f2901c4782f8 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 8 Oct 2025 06:32:58 -0500 Subject: dig up my other version --- humanFormat.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/humanFormat.go b/humanFormat.go index ac195d9..e501490 100644 --- a/humanFormat.go +++ b/humanFormat.go @@ -94,16 +94,20 @@ func FormatDuration(d time.Duration) string { ms := int(d.Milliseconds()) if ms > 100 { // todo: print .3s, etc ? - return fmt.Sprintf("%1.2fs", float64(seconds)/1000) } if ms > 0 { result += fmt.Sprintf("%dms", ms) + return result + } + + // report in milliseconds + mc := int(d.Microseconds()) + if mc > 0 { + result += fmt.Sprintf("%dmc", mc) + return result } - // totally not necessary but wth - var t time.Duration - t = time.Duration(ms) * time.Millisecond - nanos := d - t - result += fmt.Sprintf("%dnanos", nanos) + ns := int(d.Nanoseconds()) + result += fmt.Sprintf("%dns", ns) return result } -- cgit v1.2.3