From dc3e960e792cfba3950c788f31618f1312bad0e3 Mon Sep 17 00:00:00 2001 From: Janne Kalliola Date: Mon, 2 Jul 2018 23:22:09 +0300 Subject: [PATCH] Fixed parsing date, as dt_txt is missing from certain weather API results --- modules/default/weatherforecast/weatherforecast.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index c16759ef..c06f5f5b 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -334,8 +334,15 @@ Module.register("weatherforecast",{ var forecast = data.list[i]; this.parserDataWeather(forecast); // hack issue #1017 - var day = moment(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss").format("ddd"); - var hour = moment(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss").format("H"); + var day; + var hour; + if(!!forecast.dt_txt) { + day = moment(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss").format("ddd"); + hour = moment(forecast.dt_txt, "YYYY-MM-DD hh:mm:ss").format("H"); + } else { + day = moment(forecast.dt, "X").format("ddd"); + hour = moment(forecast.dt, "X").format("H"); + } if (day !== lastDay) { var forecastData = {