Merge pull request #2066 from oemel09/fix-maxNumberOfDays-2018

Adjusts maxNumberOfDays depending on the endpoint
This commit is contained in:
Michael Teeuw 2020-07-03 22:02:26 +02:00 committed by GitHub
commit 37237d9c10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -17,6 +17,8 @@ _This release is scheduled to be released on 2020-10-01._
### Fixed
- Fix the use of "maxNumberOfDays" in the module "weatherforecast depending on the endpoint (forecast/daily or forecast)". [#2018](https://github.com/MichMich/MagicMirror/issues/2018)
## [2.12.0] - 2020-07-01
Special thanks to the following contributors: @AndreKoepke, @andrezibaia, @bryanzzhu, @chamakura, @DarthBrento, @Ekristoffe, @khassel, @Legion2, @ndom91, @radokristof, @rejas, @XBCreepinJesus & @ZoneMR.

View File

@ -294,7 +294,15 @@ Module.register("weatherforecast", {
return;
}
params += "&cnt=" + (this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 17 ? 7 : this.config.maxNumberOfDays);
let numberOfDays;
if (this.config.forecastEndpoint === "forecast") {
numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 5 ? 5 : this.config.maxNumberOfDays;
// don't get forecasts for the 6th day, as it would not represent the whole day
numberOfDays = numberOfDays * 8 - (Math.floor(new Date().getHours() / 3) % 8);
} else {
numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 17 ? 7 : this.config.maxNumberOfDays;
}
params += "&cnt=" + numberOfDays;
params += "&units=" + this.config.units;
params += "&lang=" + this.config.lang;