fix(fires): show a 47.6-hour-old detection as 2d, not 48h

formatAge and formatAgeLabel picked the hour unit on the raw value and
rounded afterwards, so a detection between 47.5 and 48 hours old read
48h, while one exactly 48 hours old read 2d. Round to whole hours first,
then choose the unit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
quanticsoul4772andClaude Opus 5.5 committed 2026-11-03 11:43:10 -08:00
1 parent 1facc09f8d
commit 9d27366b3e
3 files changed
+30 -3

No files matched your search

+5 -3
View File
@@ -526,7 +526,8 @@ export function createModel({
if (!Number.isFinite(deltaMs) || deltaMs < 0) return '';
const hours = deltaMs / 3600000;
if (hours < 1) return '<1h';
if (hours < 48) return `${Math.round(hours)}h`;
const wholeHours = Math.round(hours);
if (wholeHours < 48) return `${wholeHours}h`;
return `${Math.round(hours / 24)}d`;
}
@@ -561,8 +562,9 @@ export function createModel({
if (!Number.isFinite(deltaMs) || deltaMs < 0) return '';
const hours = deltaMs / 3600000;
if (hours < 1) return t('<1h', { context: 'age' });
if (hours < 48)
return t('{count}h', { context: 'age', count: Math.round(hours) });
const wholeHours = Math.round(hours);
if (wholeHours < 48)
return t('{count}h', { context: 'age', count: wholeHours });
return t('{count}d', { context: 'age', count: Math.round(hours / 24) });
}