Fix on if we're acting on the sunrise/sunset after one occurred since the last check.
parent
f2c6163777
commit
2e563f8a0d
|
|
@ -115,7 +115,7 @@ var sunFull;
|
|||
function updateSunRiseSunSet(now, lat, lon, sunLeftCalcs){
|
||||
// get today's sunlight times for lat/lon
|
||||
var times = SunCalc.getTimes(now, lat, lon);
|
||||
dateCopy = new Date(now.getTime());
|
||||
var dateCopy = new Date(now.getTime());
|
||||
|
||||
// format sunrise time from the Date object
|
||||
sunRise = extractTime(times.sunrise);
|
||||
|
|
@ -274,6 +274,10 @@ function drawClock() {
|
|||
break;
|
||||
case 'Sun':
|
||||
ring_percent = 100 * (date - sunStart) / sunFull;
|
||||
if (ring_percent > 100) { // If we're now past a sunrise of sunset
|
||||
updateSunRiseSunSet(date, location.lat, location.lon, true);
|
||||
ring_percent = 100 * (date - sunStart) / sunFull;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -302,7 +306,7 @@ function drawClock() {
|
|||
|
||||
// recalc sunrise / sunset every hour
|
||||
if (drawCount % 60 == 0)
|
||||
updateSunRiseSunSet(new Date(), location.lat, location.lon, settings.ring == 'Sun');
|
||||
updateSunRiseSunSet(date, location.lat, location.lon, settings.ring == 'Sun');
|
||||
drawCount++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue