Skip to content

Commit

Permalink
Fixed parsing date, as dt_txt is missing from certain weather API res…
Browse files Browse the repository at this point in the history
…ults
  • Loading branch information
jannekalliola committed Jul 2, 2018
1 parent 3545f80 commit dc3e960
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions modules/default/weatherforecast/weatherforecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit dc3e960

Please sign in to comment.