Open History to see the last commit
1/** Compact relative time for freshness signals ("6m ago"). */
2export function timeAgo(epochSeconds: number | null): string {
3 if (!epochSeconds) return 'never'
4 const delta = Math.max(0, Math.floor(Date.now() / 1000) - epochSeconds)
5 if (delta < 90) return `${String(delta)}s ago`
6 if (delta < 5400) return `${String(Math.round(delta / 60))}m ago`
7 if (delta < 129_600) return `${String(Math.round(delta / 3600))}h ago`
8 return `${String(Math.round(delta / 86_400))}d ago`
9}
10
11/** Absolute date for provenance ("Jun 11, 2026"). */
12export function shortDate(epochSeconds: number | null): string {
13 if (!epochSeconds) return '—'
14 return new Date(epochSeconds * 1000).toLocaleDateString('en-US', {
15 month: 'short',
16 day: 'numeric',
17 year: 'numeric',
18 timeZone: 'UTC',
19 })
20}