From a4903eaefc3d195bae35ace6a01291a2cd237fa0 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 31 Jul 2024 01:51:53 -0700 Subject: [PATCH] core/clock: fix breakage at midnight The difference between 23:59 and 00:00 is -23:59, not 00:01. --- src/core/clock.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/clock.cpp b/src/core/clock.cpp index b232d0b1..0af9762e 100644 --- a/src/core/clock.cpp +++ b/src/core/clock.cpp @@ -55,7 +55,11 @@ void SystemClock::update() { else if (minutePrecision) nextTime = nextTime.addSecs(60); else if (hourPrecision) nextTime = nextTime.addSecs(3600); - this->timer.start(time.msecsTo(nextTime)); + auto delay = time.msecsTo(nextTime); + // day rollover + if (delay < 0) delay += 86400000; + + this->timer.start(delay); } else { this->timer.stop(); }