MCPcopy Index your code
hub / github.com/codehamr/codehamr / liveElapsed

Function liveElapsed

internal/tui/format.go:33–42  ·  view source on GitHub ↗

liveElapsed renders a running wall-clock duration for the status bar: whole seconds under a minute (no sub-second decimal spinning at the spinner's refresh rate), then `6m 51s` / `1h 14m`. The lower unit is always two digits and round values are NOT collapsed (`8m 00s`, not `8m`), so the readout nev

(d time.Duration)

Source from the content-addressed store, hash-verified

31// jumps from `7m 59s` straight to `8m` and back: it counts up visually steady.
32// Used live (time.Since(turnStart)) and frozen at finish.
33func liveElapsed(d time.Duration) string {
34 s := int(d.Seconds())
35 if s < 60 {
36 return fmt.Sprintf("%ds", s)
37 }
38 if s < 3600 {
39 return fmt.Sprintf("%dm %02ds", s/60, s%60)
40 }
41 return fmt.Sprintf("%dh %02dm", s/3600, (s%3600)/60)
42}
43
44// humanRate renders throughput: `25 tok/s`, `5.3 tok/s`. Returns "" on
45// degenerate input (no tokens or zero elapsed) so the caller omits the

Callers 2

TestLiveElapsedFunction · 0.85
renderStatusBarMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestLiveElapsedFunction · 0.68