move skip logic to timerUtils

This commit is contained in:
arc-alex
2023-11-27 17:42:42 +01:00
parent b11041938d
commit 20d5d8b129
6 changed files with 45 additions and 103 deletions
+13
View File
@@ -1,5 +1,6 @@
import { MaybeNumber, TimerType } from 'ontime-types';
import { dayInMs } from 'ontime-utils';
import { config } from '../config/config.js';
/**
* Calculates expected finish time of a running timer
@@ -64,3 +65,15 @@ export function getCurrent(
}
return startedAt + duration + addedTime + pausedTime - clock;
}
export function skipedOutOfEvent(previousTime: number, clock: number, startedAt: number, finishAt): boolean {
const skipTime = previousTime - clock;
const hasSkipped = Math.abs(skipTime) > config.timeSkipLimit;
if (hasSkipped) {
if (clock > finishAt || clock < startedAt) {
return true;
}
// otherwise we just skipped within the event
}
return false;
}