mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 13:23:35 +00:00
chore: remove unused code
This commit is contained in:
committed by
Carlos Valente
parent
30e290c320
commit
0ea00ff6be
@@ -1,4 +1,4 @@
|
|||||||
import { MILLIS_PER_HOUR, dayInMs, millisToString } from 'ontime-utils';
|
import { dayInMs, millisToString } from 'ontime-utils';
|
||||||
import { EndAction, Playback, TimeStrategy, TimerPhase, TimerType } from 'ontime-types';
|
import { EndAction, Playback, TimeStrategy, TimerPhase, TimerType } from 'ontime-types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
getExpectedFinish,
|
getExpectedFinish,
|
||||||
getRuntimeOffset,
|
getRuntimeOffset,
|
||||||
getTimerPhase,
|
getTimerPhase,
|
||||||
getTotalDuration,
|
|
||||||
normaliseEndTime,
|
normaliseEndTime,
|
||||||
skippedOutOfEvent,
|
skippedOutOfEvent,
|
||||||
} from '../timerUtils.js';
|
} from '../timerUtils.js';
|
||||||
@@ -1047,40 +1046,6 @@ describe('getRuntimeOffset()', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getTotalDuration()', () => {
|
|
||||||
it('calculates the duration of events in a single day', () => {
|
|
||||||
const start = MILLIS_PER_HOUR * 9;
|
|
||||||
const end = MILLIS_PER_HOUR * 17;
|
|
||||||
const daySpan = 0;
|
|
||||||
const duration = getTotalDuration(start, end, daySpan);
|
|
||||||
expect(duration).toBe(MILLIS_PER_HOUR * (17 - 9));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calculates the duration of events across days', () => {
|
|
||||||
const start = MILLIS_PER_HOUR * 9;
|
|
||||||
const end = MILLIS_PER_HOUR * 17;
|
|
||||||
const daySpan = 1;
|
|
||||||
const duration = getTotalDuration(start, end, daySpan);
|
|
||||||
expect(duration).toBe(MILLIS_PER_HOUR * (17 - 9) + dayInMs);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calculates the duration of events across days (2)', () => {
|
|
||||||
const start = new Date(0).setHours(12);
|
|
||||||
const end = new Date(0).setHours(8);
|
|
||||||
const daySpan = 1;
|
|
||||||
const duration = getTotalDuration(start, end, daySpan);
|
|
||||||
expect(millisToString(duration)).toBe('20:00:00');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calculates the duration of events across days (3)', () => {
|
|
||||||
const start = new Date(0).setHours(9);
|
|
||||||
const end = new Date(0).setHours(23);
|
|
||||||
const daySpan = 2;
|
|
||||||
const duration = getTotalDuration(start, end, daySpan);
|
|
||||||
expect(millisToString(duration)).toBe('62:00:00');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getTimerPhase()', () => {
|
describe('getTimerPhase()', () => {
|
||||||
it('should be None if the timer is not running', () => {
|
it('should be None if the timer is not running', () => {
|
||||||
const state = {
|
const state = {
|
||||||
|
|||||||
@@ -156,26 +156,6 @@ export function getRuntimeOffset(state: RuntimeState): number {
|
|||||||
return startOffset - addedTime - pausedTime + overtime;
|
return startOffset - addedTime - pausedTime + overtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates total duration of a time span
|
|
||||||
* @param firstStart
|
|
||||||
* @param lastEnd
|
|
||||||
* @param daySpan
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function getTotalDuration(firstStart: number, lastEnd: number, daySpan: number): number {
|
|
||||||
if (!lastEnd) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
let correctDay = 0;
|
|
||||||
if (lastEnd < firstStart) {
|
|
||||||
correctDay = dayInMs;
|
|
||||||
daySpan -= 1;
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line prettier/prettier -- we like the clarity
|
|
||||||
return lastEnd + correctDay + daySpan * dayInMs - firstStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the expected end of the rundown
|
* Calculates the expected end of the rundown
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user