refactor: extract midnight cross rules

This commit is contained in:
Carlos Valente
2026-03-03 20:44:36 +01:00
committed by Carlos Valente
parent 5a5450d7ef
commit 2ef0b81743
3 changed files with 34 additions and 4 deletions
+3 -2
View File
@@ -35,6 +35,7 @@ import {
getExpectedFinish,
getRuntimeOffset,
getTimerPhase,
hasCrossedMidnight,
} from '../services/timerUtils.js';
import { loadRoll, normaliseRollStart } from '../services/rollUtils.js';
import { timerConfig } from '../setup/config.js';
@@ -555,8 +556,8 @@ export function update(): UpdateResult {
// 2. are we waiting to roll?
if (runtimeState.timer.playback === Playback.Roll && runtimeState.timer.secondaryTimer !== null) {
const hasCrossedMidnight = previousClock > now;
return updateIfWaitingToRoll(hasCrossedMidnight);
const clockHasCrossedMidnight = hasCrossedMidnight(previousClock, now);
return updateIfWaitingToRoll(clockHasCrossedMidnight);
}
// 3. at this point we know that we are playing an event