From 73f9511128b709b5a465c280498d29d39c687124 Mon Sep 17 00:00:00 2001 From: Marco Heiming Date: Thu, 27 Jan 2022 20:18:57 +0100 Subject: [PATCH] Fix sunprogress calculation during night --- apps/circlesclock/app.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/circlesclock/app.js b/apps/circlesclock/app.js index 5b7569d63..7c9645159 100644 --- a/apps/circlesclock/app.js +++ b/apps/circlesclock/app.js @@ -504,12 +504,12 @@ function getSunProgress() { } } else { // during night - if (sunSet < sunRise) { - const upcomingSunRise = sunRise + 60 * 60 * 24; - return 1 - (upcomingSunRise - now) / (upcomingSunRise - sunSet); + if (now < sunRise) { + const prevSunSet = sunSet - 60 * 60 * 24; + return 1- (sunRise - now) / (sunRise - prevSunSet); } else { - const lastSunSet = sunSet - 60 * 60 * 24; - return (now - lastSunSet) / (sunRise - lastSunSet); + const upcomingSunRise = sunRise + 60 * 60 * 24; + return (upcomingSunRise - now) / (upcomingSunRise - sunSet); } } }