mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-24 00:19:21 +00:00
26 lines
784 B
TypeScript
26 lines
784 B
TypeScript
import { millisToString, removeTrailingZero } from 'ontime-utils';
|
|
|
|
import { formatDuration, normaliseWallClock } from '../../../common/utils/time';
|
|
|
|
export function formatDelay(timeStart: number, delay: number): string | undefined {
|
|
if (!delay) return;
|
|
|
|
const delayedStart = normaliseWallClock(timeStart + delay);
|
|
|
|
const timeTag = removeTrailingZero(millisToString(delayedStart));
|
|
return `New start ${timeTag}`;
|
|
}
|
|
|
|
export function formatGap(gap: number, isNextDay: boolean) {
|
|
if (gap === 0) {
|
|
if (isNextDay) {
|
|
// We show a next day warning even if there is no gap
|
|
return '(next day)';
|
|
}
|
|
return;
|
|
}
|
|
|
|
const gapString = formatDuration(Math.abs(gap), false);
|
|
return `${gap < 0 ? 'Overlap' : 'Gap'} ${gapString}${isNextDay ? ' (next day)' : ''}`;
|
|
}
|