| 466 | } |
| 467 | |
| 468 | function formatDate(date: string | Date): string { |
| 469 | const d = typeof date === "string" ? new Date(date) : date |
| 470 | const now = new Date() |
| 471 | const diffMs = now.getTime() - d.getTime() |
| 472 | const diffMins = Math.floor(diffMs / 60_000) |
| 473 | const diffHours = Math.floor(diffMs / 3_600_000) |
| 474 | const diffDays = Math.floor(diffMs / 86_400_000) |
| 475 | |
| 476 | if (diffMins < 1) return "just now" |
| 477 | if (diffMins < 60) return `${diffMins}m ago` |
| 478 | if (diffHours < 24) return `${diffHours}h ago` |
| 479 | if (diffDays < 7) return `${diffDays}d ago` |
| 480 | |
| 481 | return d.toLocaleDateString("en-US", { |
| 482 | month: "short", |
| 483 | day: "numeric", |
| 484 | year: d.getFullYear() !== now.getFullYear() ? "numeric" : undefined, |
| 485 | }) |
| 486 | } |
| 487 | |
| 488 | function formatFullDate(date: string | Date): string { |
| 489 | const d = typeof date === "string" ? new Date(date) : date |