const GB = 1024 * 1024 * 1024; const MB = 1024 * 1024; export const formatBytes = (bytes: number): string => { if (bytes >= GB) return `${(bytes / GB).toFixed(1)} GB`; if (bytes >= MB) return `${(bytes / MB).toFixed(0)} MB`; return `${bytes} B`; }; /** * Format an ETI version stamp (YYYYMMDD) for display. Falls back to the raw * string when it doesn't fit the expected shape. */ export const formatEtiVersion = (raw: string | undefined): string => { if (!raw) return '—'; if (raw.length === 8 && /^\d{8}$/.test(raw)) { return `${raw.slice(0, 4)}.${raw.slice(4, 6)}.${raw.slice(6, 8)}`; } return raw; }; export const formatPlayers = (max?: number): string => { if (!max || max <= 0) return '—'; return max === 1 ? '1' : `1–${max}`; };