Refactor: better rounding (#1594)

This commit is contained in:
Alex Christoffer Rasmussen
2025-06-05 06:13:49 +02:00
committed by Carlos Valente
parent c1054711b0
commit b9ab1c6fd7
10 changed files with 93 additions and 181 deletions
+1 -1
View File
@@ -119,7 +119,7 @@ export function formatDuration(duration: number, hideSeconds = true): string {
}
if (!hideSeconds) {
const seconds = Math.floor((duration % MILLIS_PER_MINUTE) / MILLIS_PER_SECOND);
const seconds = Math.ceil((duration % MILLIS_PER_MINUTE) / MILLIS_PER_SECOND);
if (seconds > 0) {
result += `${seconds}s`;
}
@@ -81,7 +81,7 @@ export function getFormattedTimer(
localisedMinutes: string,
options: FormattingOptions,
): string {
if (timer == null) {
if (timer == null || timerType === TimerType.None) {
return options.removeSeconds ? timerPlaceholderMin : timerPlaceholder;
}
@@ -98,7 +98,7 @@ export function getFormattedTimer(
}
}
let display = millisToString(timeToParse);
let display = millisToString(timeToParse, { direction: timerType });
if (options.removeLeadingZero) {
display = removeLeadingZero(display);
}