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

+1
View File
@@ -2221,6 +2221,7 @@ accessible name remains "Don't show this again". Control behavior is unchanged.
## FIRMS source status
The FIRMS CSV parser rejects impossible acquisition calendar dates before the proxy filters records to the trailing 24 hours, while retaining valid UTC acquisition times.
FIRMS ages round to whole hours before choosing a unit, so a 47.6-hour age reads "2d", not "48h".
The `get_active_fires` tool reports acquisition times as UTC ISO timestamps,
including zero-padded hours and minutes; missing or invalid dates and times
remain `null`, including impossible calendar dates from a custom source.
+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) });
}
+24
View File
@@ -0,0 +1,24 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { getLocale, setLocale } from '../../i18n/index.js';
import { createModel } from './model.js';
const HOUR_MS = 3600000;
test('a fire age that rounds to 48 hours reads in days, as 48 hours does', () => {
const previousLocale = getLocale();
const { formatAge, formatAgeLabel } = createModel({
services: { anchors: {} },
});
try {
setLocale('en');
assert.equal(formatAge(47.4 * HOUR_MS), '47h');
assert.equal(formatAge(47.6 * HOUR_MS), '2d');
assert.equal(formatAge(48 * HOUR_MS), '2d');
assert.equal(formatAgeLabel(47.4 * HOUR_MS), '47h');
assert.equal(formatAgeLabel(47.6 * HOUR_MS), formatAgeLabel(48 * HOUR_MS));
assert.equal(formatAgeLabel(48 * HOUR_MS), '2d');
} finally {
setLocale(previousLocale);
}
});