MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / formatDuration

Function formatDuration

packages/oauth/src/managed-usage.ts:160–173  ·  view source on GitHub ↗
(totalSeconds: number)

Source from the content-addressed store, hash-verified

158}
159
160export function formatDuration(totalSeconds: number): string {
161 if (!Number.isFinite(totalSeconds) || totalSeconds <= 0) return '0s';
162 const seconds = Math.floor(totalSeconds);
163 const days = Math.floor(seconds / 86_400);
164 const hours = Math.floor((seconds % 86_400) / 3600);
165 const minutes = Math.floor((seconds % 3600) / 60);
166 const secs = seconds % 60;
167 const parts: string[] = [];
168 if (days) parts.push(`${String(days)}d`);
169 if (hours) parts.push(`${String(hours)}h`);
170 if (minutes) parts.push(`${String(minutes)}m`);
171 if (secs && parts.length === 0) parts.push(`${String(secs)}s`);
172 return parts.length > 0 ? parts.join(' ') : '0s';
173}
174
175function toInt(value: unknown): number | null {
176 if (typeof value === 'number') {

Callers 3

resetHintFromFunction · 0.70
formatResetTimeFunction · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected