MCPcopy
hub / github.com/syncthing/syncthing / NiceDurationString

Function NiceDurationString

lib/stringutil/stringutil.go:32–46  ·  view source on GitHub ↗
(d time.Duration)

Source from the content-addressed store, hash-verified

30}
31
32func NiceDurationString(d time.Duration) string {
33 switch {
34 case d > 24*time.Hour:
35 d = d.Round(time.Hour)
36 case d > time.Hour:
37 d = d.Round(time.Minute)
38 case d > time.Minute:
39 d = d.Round(time.Second)
40 case d > time.Second:
41 d = d.Round(time.Millisecond)
42 case d > time.Millisecond:
43 d = d.Round(time.Microsecond)
44 }
45 return d.String()
46}

Callers 1

pullMethod · 0.92

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected