export function formatGB(gb: number): string { if (gb >= 1000) return `${(gb / 1000).toFixed(2)} TB`; return `${gb.toFixed(1)} GB`; } export function formatHours(h: number): string { if (h >= 1000) return `${(h / 1000).toFixed(1)}k h`; return `${h.toFixed(0)}h`; } export function timeAgo(iso: string | null | undefined): string { if (!iso) return "Never"; const diff = Date.now() - new Date(iso).getTime(); const mins = Math.floor(diff / 60_000); if (mins < 1) return "just now"; if (mins < 60) return `${mins}m ago`; const hrs = Math.floor(mins / 60); if (hrs < 24) return `${hrs}h ago`; const days = Math.floor(hrs / 24); if (days < 30) return `${days}d ago`; return new Date(iso).toLocaleDateString(undefined, { month: "short", year: "numeric" }); } export function unixTimeAgo(ts: number | null): string { if (ts === null) return "Never"; return timeAgo(new Date(ts * 1000).toISOString()); }