| 535 | } |
| 536 | |
| 537 | function formatDate(date: string | Date): string { |
| 538 | const d = typeof date === 'string' ? new Date(date) : date |
| 539 | const now = new Date() |
| 540 | const diffMs = now.getTime() - d.getTime() |
| 541 | const diffMins = Math.floor(diffMs / 60_000) |
| 542 | const diffHours = Math.floor(diffMs / 3_600_000) |
| 543 | const diffDays = Math.floor(diffMs / 86_400_000) |
| 544 | |
| 545 | if (diffMins < 1) return 'just now' |
| 546 | if (diffMins < 60) return `${diffMins}m ago` |
| 547 | if (diffHours < 24) return `${diffHours}h ago` |
| 548 | if (diffDays < 7) return `${diffDays}d ago` |
| 549 | |
| 550 | return d.toLocaleDateString('en-US', { |
| 551 | month: 'short', |
| 552 | day: 'numeric', |
| 553 | year: d.getFullYear() !== now.getFullYear() ? 'numeric' : undefined |
| 554 | }) |
| 555 | } |
| 556 | |
| 557 | function formatFullDate(date: string | Date): string { |
| 558 | const d = typeof date === 'string' ? new Date(date) : date |