mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-12-12 09:52:37 +00:00
fixes problems with daylight-saving-time in weather provider openmeteo (#3931)
fix for #3930
This commit is contained in:
@@ -29,6 +29,7 @@ planned for 2026-01-01
|
|||||||
- fixed eslint warnings shown in #3911 and updated npm publish docs (#3913)
|
- 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.
|
- [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 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
|
### Updated
|
||||||
|
|
||||||
|
|||||||
@@ -280,13 +280,24 @@ WeatherProvider.register("openmeteo", {
|
|||||||
return `${this.config.apiBase}/forecast?${this.getQueryParameters()}`;
|
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
|
// Transpose hourly and daily data matrices
|
||||||
transposeDataMatrix (data) {
|
transposeDataMatrix (data) {
|
||||||
return data.time.map((_, index) => Object.keys(data).reduce((row, key) => {
|
return data.time.map((_, index) => Object.keys(data).reduce((row, key) => {
|
||||||
return {
|
return {
|
||||||
...row,
|
...row,
|
||||||
// Parse time values as momentjs instances
|
// 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]
|
||||||
};
|
};
|
||||||
}, {}));
|
}, {}));
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user