humanDuration formats a duration as "2h 34m" / "12m 3s" / "45s". Non-translated: the h/m/s suffixes are language-neutral shorthand.
(d time.Duration)
| 291 | // humanDuration formats a duration as "2h 34m" / "12m 3s" / "45s". |
| 292 | // Non-translated: the h/m/s suffixes are language-neutral shorthand. |
| 293 | func humanDuration(d time.Duration) string { |
| 294 | d = d.Truncate(time.Second) |
| 295 | if d < time.Minute { |
| 296 | return fmt.Sprintf("%ds", int(d.Seconds())) |
| 297 | } |
| 298 | if d < time.Hour { |
| 299 | m := int(d.Minutes()) |
| 300 | s := int(d.Seconds()) - m*60 |
| 301 | return fmt.Sprintf("%dm %ds", m, s) |
| 302 | } |
| 303 | h := int(d.Hours()) |
| 304 | m := int(d.Minutes()) - h*60 |
| 305 | return fmt.Sprintf("%dh %dm", h, m) |
| 306 | } |
| 307 | |
| 308 | // subheader prints a "── <label>" subsection divider in gray. |
| 309 | func subheader(prefix, labelKey string) { |
no outgoing calls
no test coverage detected