One elapsed-time notation: ago() reads dur's units app-wide, health runs cell widened

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgBfkm4rCmtd1T4vHWjEPx
This commit is contained in:
2026-10-15 17:10:36 +02:00
co-authored by Claude Opus 5.5
parent 59f069022f
commit 70af80f6f6
10 changed files with 22 additions and 41 deletions
+10
View File
@@ -81,3 +81,13 @@ export function dur(ms: number, digits = 3): string {
]
return `${Number((rounded / factor).toPrecision(digits))} ${unit}`
}
/**
* How long ago a moment was, in `dur`'s notation: "4.52 min ago". A number is
* unix seconds, a string an ISO timestamp.
*/
export function ago(ts: string | number | null | undefined): string {
if (!ts) return "—"
const stamp = typeof ts === "number" ? ts * 1000 : Date.parse(ts)
return `${dur(Math.max(0, Date.now() - stamp))} ago`
}