(dateInput: Date | string)
| 66 | |
| 67 | // Format relative time - moved outside component to avoid recreation |
| 68 | const formatTime = (dateInput: Date | string) => { |
| 69 | const date = dateInput instanceof Date ? dateInput : new Date(dateInput) |
| 70 | const now = new Date() |
| 71 | const diffMs = now.getTime() - date.getTime() |
| 72 | const diffMins = Math.floor(diffMs / 60000) |
| 73 | const diffHours = Math.floor(diffMs / 3600000) |
| 74 | const diffDays = Math.floor(diffMs / 86400000) |
| 75 | |
| 76 | if (diffMins < 1) return "now" |
| 77 | if (diffMins < 60) return `${diffMins}m` |
| 78 | if (diffHours < 24) return `${diffHours}h` |
| 79 | if (diffDays < 7) return `${diffDays}d` |
| 80 | if (diffDays < 30) return `${Math.floor(diffDays / 7)}w` |
| 81 | if (diffDays < 365) return `${Math.floor(diffDays / 30)}mo` |
| 82 | return `${Math.floor(diffDays / 365)}y` |
| 83 | } |
| 84 | |
| 85 | // Normalized chat type for archive popover (works with both local and remote chats) |
| 86 | interface NormalizedArchivedChat { |
no outgoing calls
no test coverage detected