From 2dfb349609244aec9c37ca787e106e0388bfc959 Mon Sep 17 00:00:00 2001 From: fwitte Date: Mon, 7 Jan 2019 08:19:50 +0100 Subject: [PATCH] fixed missing last day display in forecast/hourly --- modules/default/weather/providers/openweathermap.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/default/weather/providers/openweathermap.js b/modules/default/weather/providers/openweathermap.js index 3d257cee..9ae7cbd4 100644 --- a/modules/default/weather/providers/openweathermap.js +++ b/modules/default/weather/providers/openweathermap.js @@ -113,7 +113,6 @@ WeatherProvider.register("openweathermap", { for (const forecast of forecasts) { if (date !== moment(forecast.dt, "X").format("YYYY-MM-DD")) { - // a new day // calculate minimum/maximum temperature, specify rain amount weather.minTemperature = Math.min.apply(null, minTemp); weather.maxTemperature = Math.max.apply(null, maxTemp); @@ -135,9 +134,9 @@ WeatherProvider.register("openweathermap", { // select weather type by first forecast value of a day, is this reasonable? weather.weatherType = this.convertWeatherType(forecast.weather[0].icon); - + } - + // the same day as before // add values from forecast to corresponding variables minTemp.push(forecast.main.temp_min); @@ -155,6 +154,13 @@ WeatherProvider.register("openweathermap", { rain += 0; } } + // last day + // calculate minimum/maximum temperature, specify rain amount + weather.minTemperature = Math.min.apply(null, minTemp); + weather.maxTemperature = Math.max.apply(null, maxTemp); + weather.rain = rain; + // push weather information to days array + days.push(weather); return days.slice(1); },