/** 1 536 000 → "1,5 MB" */ export function formatBytes(bytes: number): string { if (bytes < 1024) return `${bytes} B`; const units = ["KB", "MB", "GB", "TB"]; let value = bytes / 1024; let unit = 0; while (value >= 1024 && unit < units.length - 1) { value /= 1024; unit++; } return `${value.toFixed(value >= 100 ? 0 : 1).replace(".", ",")} ${units[unit]}`; } /** 93784 → "1 d 2 h 3 min" */ export function formatDuration(seconds: number): string { const d = Math.floor(seconds / 86400); const h = Math.floor((seconds % 86400) / 3600); const m = Math.floor((seconds % 3600) / 60); return [d ? `${d} d` : "", h || d ? `${h} h` : "", `${m} min`].filter(Boolean).join(" "); }