mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 13:44:12 +00:00
refactor: add options to hide schedule
This commit is contained in:
committed by
Carlos Valente
parent
8bd7645c95
commit
7b932ef0f7
@@ -1,4 +1,4 @@
|
||||
import { millisToHours, millisToMinutes, millisToSeconds } from "./conversionUtils";
|
||||
import { millisToHours, millisToMinutes, millisToSeconds, secondsInMillis } from './conversionUtils';
|
||||
|
||||
describe('millisToSecond()', () => {
|
||||
test('null values', () => {
|
||||
@@ -112,3 +112,14 @@ describe('millisToHours()', () => {
|
||||
expect(millisToHours(t.val)).toBe(t.result);
|
||||
});
|
||||
});
|
||||
|
||||
describe('secondsInMillis()', () => {
|
||||
it('return 0 if value is null', () => {
|
||||
expect(secondsInMillis(null)).toBe(0);
|
||||
});
|
||||
it('returns the seconds value of a millis date', () => {
|
||||
const date = 1686255053619; // Thu Jun 08 2023 20:10:53
|
||||
const seconds = secondsInMillis(date);
|
||||
expect(seconds).toBe(53);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,3 +64,15 @@ export function secondsToMinutes(seconds: number): number {
|
||||
export function secondsToHours(seconds: number): number {
|
||||
return Math.floor(seconds / 3600);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns amount of seconds in a date given in milliseconds. For studio clock second indicator
|
||||
* @param {MaybeNumber} millis time to format
|
||||
* @returns amount of elapsed seconds
|
||||
*/
|
||||
export function secondsInMillis(millis: MaybeNumber): number {
|
||||
if (!millis) {
|
||||
return 0;
|
||||
}
|
||||
return Math.floor((millis % MILLIS_PER_MINUTE) / MILLIS_PER_SECOND);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user