From 261ffb4d3529ee705f381cb922a334816125cba2 Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Fri, 3 Jul 2015 10:50:02 -0500 Subject: [PATCH] Attempt to remove timezone offset from sun time calculations --- routes/weather.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/routes/weather.js b/routes/weather.js index 33a9ac1..74ebc3b 100644 --- a/routes/weather.js +++ b/routes/weather.js @@ -65,12 +65,16 @@ function getWeatherUndergroundData( location, weatherUndergroundKey, callback ) // Perform the HTTP request to retrieve the weather data httpRequest( url, function( data ) { try { - var data = JSON.parse( data ); + var data = JSON.parse( data ), + date = new Date( data.current_observation.local_epoch * 1000 ); + + date.setMinutes( date.getMinutes() + date.getTimezoneOffset() ); // Calculate sunrise and sunset since Weather Underground does not provide it - var sunData = SunCalc.getTimes( new Date( data.current_observation.local_epoch * 1000 ), + var sunData = SunCalc.getTimes( date, data.current_observation.observation_location.latitude, data.current_observation.observation_location.longitude ), + weather = { icon: data.current_observation.icon, timezone: data.current_observation.local_tz_offset,