| 45 | } |
| 46 | |
| 47 | function getRelativeTime(iso: string): { text: string; stale: boolean } { |
| 48 | const diff = Date.now() - new Date(iso).getTime(); |
| 49 | const secs = Math.floor(diff / 1000); |
| 50 | if (secs < 60) return { text: `${secs}s ago`, stale: false }; |
| 51 | const mins = Math.floor(secs / 60); |
| 52 | if (mins < 5) return { text: `${mins}m ago`, stale: false }; |
| 53 | if (mins < 60) return { text: `${mins}m ago`, stale: true }; |
| 54 | return { text: `${Math.floor(mins / 60)}h ago`, stale: true }; |
| 55 | } |
| 56 | |
| 57 | function UTCClock() { |
| 58 | const [time, setTime] = useState(""); |