mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 21:03:29 +00:00
Refactor: better rounding (#1594)
This commit is contained in:
committed by
arc-alex
parent
421183fe55
commit
33ac05ebee
@@ -1,4 +1,4 @@
|
||||
import type { MaybeNumber } from 'ontime-types';
|
||||
import type { MaybeNumber, TimerType } from 'ontime-types';
|
||||
|
||||
import { millisToSeconds, secondsToHours, secondsToMinutes } from './conversionUtils.js';
|
||||
|
||||
@@ -8,6 +8,7 @@ export function pad(val: number): string {
|
||||
|
||||
type FormatOptions = {
|
||||
fallback?: string;
|
||||
direction?: TimerType.CountDown | TimerType.CountUp;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -23,7 +24,7 @@ export function millisToString(millis?: MaybeNumber, options?: FormatOptions): s
|
||||
|
||||
const isNegative = millis < 0;
|
||||
|
||||
const totalSeconds = Math.abs(millisToSeconds(millis));
|
||||
const totalSeconds = Math.abs(millisToSeconds(millis, options?.direction));
|
||||
const seconds = totalSeconds % 60;
|
||||
const minutes = secondsToMinutes(totalSeconds) % 60;
|
||||
const hours = secondsToHours(totalSeconds);
|
||||
|
||||
Reference in New Issue
Block a user