Skip to content

Commit

Permalink
fix bug in day/night determination
Browse files Browse the repository at this point in the history
  • Loading branch information
opus1269 committed Mar 31, 2019
1 parent 8421a09 commit bde2955
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/scripts/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import '../scripts/chrome-extension-utils/scripts/ex_handler.js';
/**
* Current weather conditions
* @typedef {{}} module:weather.CurrentWeather
* @property {int} time - call time
* @property {int} time - call time UTC millisec
* @property {int} id - weather id
* @property {string} dayNight - day night prefix ('', 'day-', 'night-")
* @property {number} tempValue - temperature value in K
Expand Down Expand Up @@ -164,7 +164,9 @@ export async function update() {
/** @type {{sunrise, sunset}} */
const sys = response.sys;
if (sys && sys.sunrise && sys.sunset) {
if ((curWeather.time > sys.sunrise) && (curWeather.time < sys.sunset)) {
// sys time is UTC in seconds
const time = curWeather.time / 1000;
if ((time > sys.sunrise) && (time < sys.sunset)) {
curWeather.dayNight = 'day-';
} else {
curWeather.dayNight = 'night-';
Expand Down

0 comments on commit bde2955

Please sign in to comment.