(bytes: number)
| 10 | import { DocumentIcon, ImageIcon, PaperclipIcon, SearchIcon, TrashIcon } from './icons' |
| 11 | |
| 12 | function formatBytes(bytes: number): string { |
| 13 | if (bytes < 1024) return `${bytes} B` |
| 14 | const units = ['KB', 'MB', 'GB'] |
| 15 | let value = bytes / 1024 |
| 16 | let unit = 0 |
| 17 | while (value >= 1024 && unit < units.length - 1) { |
| 18 | value /= 1024 |
| 19 | unit++ |
| 20 | } |
| 21 | return `${value.toFixed(value >= 10 || unit === 0 ? 0 : 1)} ${units[unit]}` |
| 22 | } |
| 23 | |
| 24 | function formatDate(ms: number): string { |
| 25 | const d = new Date(ms) |