core/clock: fix breakage at midnight

The difference between 23:59 and 00:00 is -23:59, not 00:01.
This commit is contained in:
outfoxxed 2024-07-31 01:51:53 -07:00
parent 76744c903a
commit a4903eaefc
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -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();
}