From 425aab284726e3e188da66ccf358159953c0677a Mon Sep 17 00:00:00 2001 From: Patrick Kissling Date: Sun, 23 Oct 2022 13:07:40 +0200 Subject: [PATCH] Fix bug where wrong days were shown in forecast First N days were picked from the forecast instead of last N --- src/clock-weather-card.ts | 3 ++- src/types.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/clock-weather-card.ts b/src/clock-weather-card.ts index f53f3a95..be75e874 100644 --- a/src/clock-weather-card.ts +++ b/src/clock-weather-card.ts @@ -434,6 +434,7 @@ export class ClockWeatherCard extends LitElement { agg.push(avg); return agg; }, []) + .sort((a,b) => a.datetime.getTime() - b.datetime.getTime()) .slice(0, days); } @@ -456,7 +457,7 @@ export class ClockWeatherCard extends LitElement { return { temperature: maxTemp, templow: minTemp, - datetime: forecasts[0].datetime, + datetime: new Date(forecasts[0].datetime), condition: condition, precipitation_probability: precipitationProbability, precipitation: precipitation, diff --git a/src/types.ts b/src/types.ts index d28e1d4b..cf6c91db 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,7 +54,7 @@ export type WeatherForecast = { } export type MergedWeatherForecast = { - datetime: string; + datetime: Date; condition: string; temperature: number; precipitation: number;