ago
How long ago ts was, as a person says it.
export function ago(ts: number, now = Date.now()): string { const s = Math.max(0, Math.round((now - ts) / 1000)); if (s < 60) return "just now"; if (s < 3600) return `${Math.floor(s / 60)}m ago`; if (s < 86400) return `${Math.floor(s / 3600)}h ago`; return `${Math.floor(s / 86400)}d ago`; }