douyinWEB/frontend/src/lib/ytRelayUi.ts

10 lines
287 B
TypeScript

export function fmtRelayUptime(sec?: number) {
const s = Math.max(0, Math.floor(Number(sec || 0)));
const h = Math.floor(s / 3600);
const m = Math.floor((s % 3600) / 60);
const r = s % 60;
if (h > 0) return `${h}h ${m}m`;
if (m > 0) return `${m}m ${r}s`;
return `${r}s`;
}