mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 05:34:09 +00:00
fix: issue where a end time can be overflowing (#761)
This commit is contained in:
@@ -93,6 +93,17 @@ describe('validateTimes()', () => {
|
||||
expect(timeEnd).toBe(10);
|
||||
expect(duration).toBe(10);
|
||||
});
|
||||
|
||||
it('ensures values dont overflow dayMs', () => {
|
||||
const start = 86100000;
|
||||
const endOverDay = 87420000;
|
||||
const durationNormal = 1320000;
|
||||
|
||||
const { timeStart, timeEnd, duration } = validateTimes(start, endOverDay, durationNormal);
|
||||
expect(timeStart).toBe(start);
|
||||
expect(timeEnd).toBe(1020000);
|
||||
expect(duration).toBe(durationNormal);
|
||||
});
|
||||
});
|
||||
|
||||
describe('calculateDuration()', () => {
|
||||
|
||||
@@ -52,9 +52,9 @@ function convertToInteger(value: unknown): number {
|
||||
* @param _duration
|
||||
*/
|
||||
export function validateTimes(_start?: unknown, _end?: unknown, _duration?: unknown) {
|
||||
const timeStart = convertToInteger(_start);
|
||||
const timeEnd = convertToInteger(_end);
|
||||
const duration = convertToInteger(_duration);
|
||||
const timeStart = convertToInteger(_start) % dayInMs;
|
||||
const timeEnd = convertToInteger(_end) % dayInMs;
|
||||
const duration = convertToInteger(_duration) % dayInMs;
|
||||
|
||||
if (_start != null && _end != null) {
|
||||
// Case 1. if we have start and end, duration must be derived
|
||||
|
||||
Reference in New Issue
Block a user