summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--humanFormat.go16
1 files 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
}