mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-07 08:23:55 +00:00
3603b836f6
* refactor: typescript migration * chore: remove prop-types package * refactor: file structure * refactor: migrate ontime table to tanstack table 8 * refactor: rundown controller uses service as data source * refactor: convert to typescript * feat: caching store * refactor: add delay values to rundown * feat: toggle past visibility * chore: update tests * refactor: add extra fields to CSV * style: show skipped events * chore: add route to navigation menu * style: allow jumping to bottom * chore: add tests
20 lines
679 B
TypeScript
20 lines
679 B
TypeScript
import { DateTime } from 'luxon';
|
|
|
|
/**
|
|
* @description Converts milliseconds to string representing time
|
|
* @param {number | null} millis - time in milliseconds
|
|
* @param {boolean} showSeconds - weather to show the seconds
|
|
* @param {string} fallback - what to return if value is null
|
|
* @returns {string} String representing time 00:12:02
|
|
*/
|
|
export function millisToString(millis: number | null, showSeconds = true, fallback = '...') {
|
|
if (millis == null) {
|
|
return fallback;
|
|
}
|
|
|
|
const isNegative = millis < 0;
|
|
|
|
const format = `HH:mm${showSeconds ? ':ss' : ''}`;
|
|
return `${isNegative ? '-' : ''}${DateTime.fromMillis(Math.abs(millis)).toUTC().toFormat(format)}`;
|
|
}
|