Skip to content

Commit

Permalink
Fix timezone time calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Kissling authored and pkissling committed Apr 24, 2023
1 parent c6b49a3 commit a323216
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/clock-weather-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,12 @@ export class ClockWeatherCard extends LitElement {
private toZonedDate(date: Date): Date {
if (this.config.use_browser_time) return date;
const timeZone = this.hass?.config?.time_zone
const withTimeZone = DateTime.fromJSDate(date).setZone(timeZone, { keepLocalTime: true });
const withTimeZone = DateTime.fromJSDate(date).setZone(timeZone);
if (!withTimeZone.isValid) {
console.error(`clock-weather-card - Time Zone [${timeZone}] not supported. Falling back to browser time.`);
return date;
}
return withTimeZone.toJSDate();
return new Date(withTimeZone.year, withTimeZone.month - 1, withTimeZone.day, withTimeZone.hour, withTimeZone.minute, withTimeZone.second, withTimeZone.millisecond);
}

private calculateAverageForecast(forecasts: WeatherForecast[]): MergedWeatherForecast {
Expand Down

0 comments on commit a323216

Please sign in to comment.