diff --git a/apps/daisy/app.js b/apps/daisy/app.js index 65f3859ad..4b9b87058 100644 --- a/apps/daisy/app.js +++ b/apps/daisy/app.js @@ -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++; }