mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 12:23:51 +00:00
fix: handle multiple days
This commit is contained in:
committed by
Carlos Valente
parent
f8ca5b9cef
commit
db8ed93d41
@@ -57,4 +57,11 @@ describe('checkIsNextDay', () => {
|
||||
const timeStart = 2 * MILLIS_PER_HOUR;
|
||||
expect(checkIsNextDay(previousStart, timeStart, previousDuration)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should account for normalised start over multiple days', () => {
|
||||
const previousStart = 90000000; // 25:00:00
|
||||
const previousDuration = 1 * MILLIS_PER_HOUR;
|
||||
const timeStart = 0;
|
||||
expect(checkIsNextDay(previousStart, timeStart, previousDuration)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,8 +24,9 @@ export function checkIsNextDay(previousStart: number, timeStart: number, previou
|
||||
return false;
|
||||
}
|
||||
|
||||
if (timeStart <= previousStart) {
|
||||
const normalisedPreviousEnd = previousStart + previousDuration;
|
||||
const cappedStart = previousStart % dayInMs;
|
||||
if (timeStart <= cappedStart) {
|
||||
const normalisedPreviousEnd = cappedStart + previousDuration;
|
||||
if (normalisedPreviousEnd === dayInMs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user