From e938f57c3ccf4bb5af6a5fe8adfc8a604a5abe1d Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Sun, 20 May 2018 16:27:08 -0500 Subject: [PATCH] Fix issue retrieving timezone data for OpenWeather Map --- routes/weather.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/routes/weather.js b/routes/weather.js index 5d7d584..704b1a3 100755 --- a/routes/weather.js +++ b/routes/weather.js @@ -229,14 +229,15 @@ function getOWMWeatherData( location, callback ) { httpRequest( url, function( data ) { try { data = JSON.parse( data ); - var weather = { - timezone: timezone, - sunrise: ( sunData.sunrise.getUTCHours() * 60 + sunData.sunrise.getUTCMinutes() ), - sunset: ( sunData.sunset.getUTCHours() * 60 + sunData.sunset.getUTCMinutes() ), - temp: parseInt( data.main.temp ), - humidity: parseInt( data.main.humidity ), - wind: parseInt( data.wind.speed ) - }; + } catch ( err ) { + // Otherwise indicate the request failed + callback( false ); + } + + getTimeData( location, function( weather ) { + weather.temp = parseInt( data.main.temp ); + weather.humidity = parseInt( data.main.humidity ); + weather.wind = parseInt( data.wind.speed ); location = location.join( "," ); @@ -248,11 +249,7 @@ function getOWMWeatherData( location, callback ) { } ); updateCache( location, weather ); - } catch ( err ) { - - // Otherwise indicate the request failed - callback( false ); - } + } ); } ); }