MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / formatDuration

Function formatDuration

internal/tui/dashboard.go:692–708  ·  view source on GitHub ↗

formatDuration formats a duration in a human-readable way.

(d time.Duration)

Source from the content-addressed store, hash-verified

690
691// formatDuration formats a duration in a human-readable way.
692func formatDuration(d time.Duration) string {
693 if d == 0 {
694 return "0s"
695 }
696
697 h := int(d.Hours())
698 m := int(d.Minutes()) % 60
699 s := int(d.Seconds()) % 60
700
701 if h > 0 {
702 return fmt.Sprintf("%dh%02dm%02ds", h, m, s)
703 }
704 if m > 0 {
705 return fmt.Sprintf("%dm%02ds", m, s)
706 }
707 return fmt.Sprintf("%ds", s)
708}
709
710// wrapText wraps text to fit within a given width.
711func wrapText(text string, width int) string {

Callers 4

renderHeaderMethod · 0.85
renderNarrowHeaderMethod · 0.85
RenderMethod · 0.85
renderStoryTimingsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected