refactor: show running gap in UI

This commit is contained in:
Carlos Valente
2024-08-27 09:39:32 +02:00
committed by Carlos Valente
parent f5936e5254
commit 73db14c383
10 changed files with 129 additions and 50 deletions
@@ -0,0 +1,24 @@
import { checkIsNextDay } from './checkIsNextDay.js';
/**
* Checks whether a new element is the latest in the list
*/
export function isNewLatest(timeStart: number, timeEnd: number, previousStart?: number, previousEnd?: number): boolean {
// true if there is no previous
if (previousStart === undefined || previousEnd === undefined) {
return true;
}
// true if it starts after the previous is finished
if (timeStart >= previousEnd) {
return true;
}
// true if it finishes later than previous
if (timeEnd > previousEnd) {
return true;
}
// true if it is the day after
return checkIsNextDay(previousStart, timeStart, previousEnd - previousStart);
}