From 92c6ee349fa834c267b7920de67eec12bd7716ce Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 19 Apr 2026 17:51:49 -0500 Subject: [PATCH] fix(weather): anchor timeline offsets to the Now slot, not wall-clock Same bug as the propagation map had in 9db9e6a. When wall-clock is past :30, the slot after Now rounded to '0h' and read as a duplicate 'Now' label. Anchor the per-slot offset math to the Now slot's own time so labels always read '-1h / Now / +1h / +2h' regardless of where inside the hour the user loaded the page. --- assets/js/weather_map_hook.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/js/weather_map_hook.ts b/assets/js/weather_map_hook.ts index 8b41484a..9999ac16 100644 --- a/assets/js/weather_map_hook.ts +++ b/assets/js/weather_map_hook.ts @@ -734,18 +734,22 @@ export const WeatherMap: WeatherMapHook = { const dt = new Date(time) const isSelected = time === this.selectedTime const isPast = dt.getTime() < now.getTime() - 1800000 - const offsetH = Math.round((dt.getTime() - now.getTime()) / 3600000) - return { time, dt, isSelected, isPast, offsetH, label: "" } + return { time, dt, isSelected, isPast, offsetH: 0, label: "" } }) const closestIdx = items.reduce((best, item, i) => Math.abs(item.dt.getTime() - now.getTime()) < Math.abs(items[best].dt.getTime() - now.getTime()) ? i : best, 0) + // Label offsets relative to the "Now" slot, not wall-clock. If we + // round from wall-clock, the hour after "Now" rounds to "0h" when + // the clock is past the half-hour, which reads as a second "now". + const anchorMs = items[closestIdx].dt.getTime() items.forEach((t, i) => { + const diff = Math.round((t.dt.getTime() - anchorMs) / 3600000) + t.offsetH = diff if (i === closestIdx) { t.label = "Now" } else { - const diff = t.offsetH t.label = diff > 0 ? `+${diff}h` : `${diff}h` } })