Spaces:
Running
Running
File size: 650 Bytes
fb57ab3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | export const fmtDuration = (ms: number) => {
if (ms < 1000) return `${Math.round(ms)}ms`;
const s = ms / 1000;
if (s < 60) return `${s.toFixed(1)}s`;
const m = Math.floor(s / 60);
return `${m}m ${Math.round(s - m * 60)}s`;
};
export const timeAgo = (ts: number, now = Date.now()) => {
const s = Math.max(0, Math.round((now - ts) / 1000));
if (s < 5) return "just now";
if (s < 60) return `${s}s ago`;
const m = Math.floor(s / 60);
if (m < 60) return `${m}m ago`;
const h = Math.floor(m / 60);
return `${h}h ago`;
};
export const isMac = /Mac|iPhone|iPad/.test(navigator.platform);
export const MOD = isMac ? "⌘" : "Ctrl";
|