MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / formatDuration

Function formatDuration

lib/tui/format.ts:1–14  ·  view source on GitHub ↗
(ms: number)

Source from the content-addressed store, hash-verified

1export function formatDuration(ms: number): string {
2 const safeMs = Math.max(0, Math.round(ms))
3 if (safeMs < 1000) return `${safeMs} ms`
4
5 const totalSeconds = safeMs / 1000
6 if (totalSeconds < 60) return `${totalSeconds.toFixed(1)} s`
7
8 const wholeSeconds = Math.floor(totalSeconds)
9 const hours = Math.floor(wholeSeconds / 3600)
10 const minutes = Math.floor((wholeSeconds % 3600) / 60)
11 const seconds = wholeSeconds % 60
12 if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`
13 return `${minutes}m ${seconds}s`
14}
15
16export function formatRatio(inputTokens: number, outputTokens: number): string {
17 if (inputTokens <= 0) return "0:1"

Callers 1

StatsDialogFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected