(deltaSeconds)
| 98 | } |
| 99 | |
| 100 | function relativeTime(deltaSeconds) { |
| 101 | if (Number.isNaN(deltaSeconds)) return "unknown"; |
| 102 | if (deltaSeconds < 60) return "just now"; |
| 103 | if (deltaSeconds < 3600) return `${Math.floor(deltaSeconds / 60)}m ago`; |
| 104 | if (deltaSeconds < 86400) return `${Math.floor(deltaSeconds / 3600)}h ago`; |
| 105 | if (deltaSeconds < 172800) return "yesterday"; |
| 106 | return `${Math.floor(deltaSeconds / 86400)}d ago`; |
| 107 | } |
| 108 | |
| 109 | /** Relative time from a unix-seconds timestamp. */ |
| 110 | export function timeAgo(ts) { |
no outgoing calls
no test coverage detected