From de406a3c60ee85d6572321c6c7175a91f96cd596 Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Sat, 25 Oct 2025 18:14:21 +0200 Subject: [PATCH] fixes problems with daylight-saving-time in weather provider `openmeto` --- CHANGELOG.md | 1 + modules/default/weather/providers/openmeteo.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 599be892f8..d2d6190dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ planned for 2026-01-01 - fixed eslint warnings shown in #3911 and updated npm publish docs (#3913) - [core] refactor: replace `express-ipfilter` with lightweight custom middleware (#3917) - This fixes security issue [CVE-2023-42282](https://github.com/advisories/GHSA-78xj-cgh5-2h22), which is not very likely to be exploitable in MagicMirror² setups, but still should be fixed. - fixed the Environment Canada weather URL (#3912) and now converts a windspeed of 'calm' to 0 +- fixed problems with daylight-saving-time in weather provider `openmeto` (#3930, #3931) ### Updated diff --git a/modules/default/weather/providers/openmeteo.js b/modules/default/weather/providers/openmeteo.js index d80b670162..08c686867a 100644 --- a/modules/default/weather/providers/openmeteo.js +++ b/modules/default/weather/providers/openmeteo.js @@ -280,13 +280,24 @@ WeatherProvider.register("openmeteo", { return `${this.config.apiBase}/forecast?${this.getQueryParameters()}`; }, + // fix daylight-saving-time differences + checkDST (dt) { + const uxdt = moment.unix(dt); + const nowDST = moment().isDST(); + if (nowDST === moment(uxdt).isDST()) { + return uxdt; + } else { + return uxdt.add(nowDST ? +1 : -1, "hour"); + } + }, + // Transpose hourly and daily data matrices transposeDataMatrix (data) { return data.time.map((_, index) => Object.keys(data).reduce((row, key) => { return { ...row, // Parse time values as momentjs instances - [key]: ["time", "sunrise", "sunset"].includes(key) ? moment.unix(data[key][index]) : data[key][index] + [key]: ["time", "sunrise", "sunset"].includes(key) ? this.checkDST(data[key][index]) : data[key][index] }; }, {})); },