Skip to content

Commit

Permalink
Fix bug where wrong days were shown in forecast
Browse files Browse the repository at this point in the history
First N days were picked from the forecast instead of last N
  • Loading branch information
Patrick Kissling authored and pkissling committed Oct 23, 2022
1 parent b7bf7b9 commit 425aab2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/clock-weather-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type WeatherForecast = {
}

export type MergedWeatherForecast = {
datetime: string;
datetime: Date;
condition: string;
temperature: number;
precipitation: number;
Expand Down

0 comments on commit 425aab2

Please sign in to comment.