Attempt to generate UTC timestamp for sun times
This commit is contained in:
@@ -66,15 +66,13 @@ function getWeatherUndergroundData( location, weatherUndergroundKey, callback )
|
|||||||
httpRequest( url, function( data ) {
|
httpRequest( url, function( data ) {
|
||||||
try {
|
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() );
|
date = new Date( Date.UTC( 1970, 0, 1, 0, 0, data.current_observation.local_epoch, 0 ) ),
|
||||||
|
|
||||||
// Calculate sunrise and sunset since Weather Underground does not provide it
|
// Calculate sunrise and sunset since Weather Underground does not provide it
|
||||||
var sunData = SunCalc.getTimes( date,
|
sunData = SunCalc.getTimes( date,
|
||||||
data.current_observation.observation_location.latitude,
|
data.current_observation.observation_location.latitude,
|
||||||
data.current_observation.observation_location.longitude ),
|
data.current_observation.observation_location.longitude ),
|
||||||
|
|
||||||
weather = {
|
weather = {
|
||||||
icon: data.current_observation.icon,
|
icon: data.current_observation.icon,
|
||||||
timezone: data.current_observation.local_tz_offset,
|
timezone: data.current_observation.local_tz_offset,
|
||||||
@@ -90,6 +88,8 @@ function getWeatherUndergroundData( location, weatherUndergroundKey, callback )
|
|||||||
elevation: data.current_observation.observation_location.elevation
|
elevation: data.current_observation.observation_location.elevation
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log( date, date.getTimezoneOffset() );
|
||||||
|
|
||||||
if ( weather.sunrise > weather.sunset ) {
|
if ( weather.sunrise > weather.sunset ) {
|
||||||
weather.sunset += 1440;
|
weather.sunset += 1440;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user