export function formatBytes(n: number): string { const num = Number(n) || 0; if (num < 1024) return `${num} B`; const units = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB']; let v = num / 1024; let i = 0; while (v >= 1024 && i < units.length - 1) { v /= 1024; i++; } return `${v.toFixed(2)} ${units[i]}`; } export function formatDate(s: string | null | undefined): string { if (!s) return '—'; const d = new Date(s); if (Number.isNaN(d.getTime())) return '—'; return d.toLocaleString(); }