Write a run's elapsed time once, in the duration formatter's units

The runs table drew when a run started and how long it took in two
notations ('56m ago | 55.5 min'), and for a run still going those are the
same reading twice. `dur` now steps past the minute into hours and days,
the ago reading is derived from it, and a running run writes only the
elapsed one.
This commit is contained in:
2026-08-28 11:02:59 +02:00
parent dfa0d44589
commit e18a669aa0
3 changed files with 26 additions and 8 deletions
+5
View File
@@ -44,6 +44,8 @@ export function si(value: number, digits = 3): string {
/** Floor, divisor and unit per step, largest first. */
const DUR_STEPS: [number, number, string][] = [
[86_400_000, 86_400_000, "d"],
[3_600_000, 3_600_000, "h"],
[60_000, 60_000, "min"],
[1_000, 1_000, "s"],
[0.01, 1, "ms"],
@@ -63,6 +65,9 @@ const DUR_STEPS: [number, number, string][] = [
* window transposed onto units. That floor is deliberate: without it a tile
* polled every ten seconds flips between "400 µs" and "1.2 ms", and a reading
* that changes unit on every poll reads as broken rather than as fast.
*
* It keeps stepping past the minute into hours and days, so that an elapsed
* time is one notation wherever it is written — "3.5 h", never "210 min".
*/
export function dur(ms: number, digits = 3): string {
if (!Number.isFinite(ms)) return "--"