diff --git a/apps/server/src/services/__tests__/timerUtils.test.ts b/apps/server/src/services/__tests__/timerUtils.test.ts index 30d0b571a..2f9f418ae 100644 --- a/apps/server/src/services/__tests__/timerUtils.test.ts +++ b/apps/server/src/services/__tests__/timerUtils.test.ts @@ -997,12 +997,12 @@ describe('getRuntimeOffset()', () => { } as RuntimeState; const offset = getRuntimeOffset(state); - expect(offset).toBe(400000); // <--- offset is always the overtime + expect(offset).toBe(-400000); // <--- offset is always the overtime }); it('handles time-to-end started after the end time', () => { const state = { - clock: 82000000, // 22:46:40 <--- starting 16 min after the scheduled end + clock: 82000000, // 22:46:40 <--- starting 16m 40s after the scheduled end eventNow: { id: 'd6a2ce', timeStart: 77400000, // 21:30:00 @@ -1039,8 +1039,8 @@ describe('getRuntimeOffset()', () => { const updateCurrent = getCurrent(state); state.timer.current = updateCurrent; const offset = getRuntimeOffset(state); - expect(millisToString(offset)).toBe('00:16:40'); - expect(offset).toBe(82000000 - 81000000); // <-- now - planned end + expect(millisToString(offset)).toBe('-00:16:40'); + expect(offset).toBe(81000000 - 82000000); // <-- planned end - now }); }); diff --git a/apps/server/src/services/timerUtils.ts b/apps/server/src/services/timerUtils.ts index 4f2da2425..28fd41263 100644 --- a/apps/server/src/services/timerUtils.ts +++ b/apps/server/src/services/timerUtils.ts @@ -140,7 +140,7 @@ export function getRuntimeOffset(state: RuntimeState): number { return timeStart - clock; } - const overtime = Math.abs(Math.min(current, 0)); + const overtime = Math.min(current, 0); // in time-to-end, offset is overtime if (timerType === TimerType.TimeToEnd) { return overtime; @@ -153,7 +153,7 @@ export function getRuntimeOffset(state: RuntimeState): number { // addedTime - time added by user (negative offset) // pausedTime - time the playback was paused (negative offset) // overtime - how long the timer has been over-running (negative offset) - return startOffset - addedTime - pausedTime - overtime; + return startOffset - addedTime - pausedTime + overtime; } /**