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

Fixes getting only full day forecasts
This commit is contained in:
Michael Teeuw 2020-07-17 16:18:57 +02:00 committed by GitHub
commit 1b199c1682
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -302,8 +302,8 @@ Module.register("weatherforecast", {
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);
// don't get forecasts for the next day, as it would not represent the whole day
numberOfDays = numberOfDays * 8 - (Math.round(new Date().getHours() / 3) % 8);
} else {
numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 17 ? 7 : this.config.maxNumberOfDays;
}