mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 16:49:41 +00:00
cleanup: millisToSeconds
This commit is contained in:
@@ -19,16 +19,17 @@ export function millisToSeconds(
|
|||||||
) {
|
) {
|
||||||
if (millis === null) return 0;
|
if (millis === null) return 0;
|
||||||
|
|
||||||
|
let seconds = 0;
|
||||||
if (direction === TimerType.CountDown) {
|
if (direction === TimerType.CountDown) {
|
||||||
// 0 + is there to avoid result giving -0
|
seconds = Math.ceil(millis / MILLIS_PER_SECOND);
|
||||||
return 0 + Math.ceil(millis / MILLIS_PER_SECOND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction === TimerType.CountUp) {
|
if (direction === TimerType.CountUp) {
|
||||||
return Math.floor(millis / MILLIS_PER_SECOND);
|
seconds = Math.floor(millis / MILLIS_PER_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error('?????');
|
// this is there to avoid result giving -0
|
||||||
|
return seconds === 0 ? 0 : seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user