Skip to content

Commit ee26193

Browse files
fix(weather): fix weathergov forecast day labels off by one (#4065)
While looking at all weather providers for #4063, I noticed another unrelated bug: The weathergov forecast has been off by one day. This has been since its first commit in 2019 and was not caused by the recent weather refactor. The provider built the days array correctly, but then threw away the first entry (`slice(1)`) because it was considered "incomplete". The problem: the template uses index position to decide what to label "Today" and "Tomorrow" — so dropping today made Monday show up as "Today", Tuesday as "Tomorrow", and one day disappeared entirely. The fix is a one-liner: remove `slice(1)`. Today's entry now shows min/max from the remaining hours of the day, which is the right behaviour anyway. In my understanding it's not a problem at all that the first day is incomplete. ## Before Notice in the screenshot that it is Sunday. So after today and tomorrow, Tuesday should come next, but it says **Wednesday** instead. <img width="385" height="365" alt="Ekrankopio de 2026-03-22 14-37-55" src="https://github.com/user-attachments/assets/02295cc6-4421-40a8-929e-6c6721dece97" /> ## After <img width="385" height="365" alt="Ekrankopio de 2026-03-22 14-38-34" src="https://github.com/user-attachments/assets/cb51ca01-7882-4805-8cf4-a78f6721038a" />
1 parent e1c44a8 commit ee26193

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

defaultmodules/weather/providers/weathergov.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class WeatherGovProvider {
349349
days.push(weather);
350350
}
351351

352-
return days.slice(1); // Skip first incomplete day
352+
return days;
353353
}
354354

355355
#generateWeatherObjectsFromHourly (forecasts) {

tests/unit/modules/default/weather/providers/weathergov_spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,36 @@ describe("WeatherGovProvider", () => {
241241
expect(day).toHaveProperty("weatherType");
242242
expect(day).toHaveProperty("precipitationProbability");
243243
});
244+
245+
it("should not skip the first day of forecast data", async () => {
246+
const provider = new WeatherGovProvider({
247+
lat: 40.71,
248+
lon: -74.0,
249+
type: "forecast"
250+
});
251+
252+
const dataPromise = new Promise((resolve) => {
253+
provider.setCallbacks(resolve, vi.fn());
254+
});
255+
256+
server.use(
257+
http.get(WEATHERGOV_FORECAST_URL, () => {
258+
return HttpResponse.json(forecastData);
259+
})
260+
);
261+
262+
await provider.initialize();
263+
provider.start();
264+
265+
const result = await dataPromise;
266+
267+
// Mock data starts on 2026-02-06 ("This Afternoon").
268+
// Before the fix, slice(1) dropped today, so result[0] would have been 2026-02-07.
269+
const firstDate = result[0].date;
270+
expect(firstDate.getFullYear()).toBe(2026);
271+
expect(firstDate.getMonth()).toBe(1); // February (0-indexed)
272+
expect(firstDate.getDate()).toBe(6);
273+
});
244274
});
245275

246276
describe("Hourly Parsing", () => {

0 commit comments

Comments
 (0)