refactor(time): trust pretty-ms defaults

This commit is contained in:
Peter Steinberger
2026-07-14 09:13:50 +01:00
parent 47d37804a8
commit 16ff48c729
9 changed files with 2 additions and 17 deletions

View File

@@ -346,8 +346,6 @@ function formatDuration(value: number | undefined): string {
return "n/a";
}
return prettyMilliseconds(Math.max(0, Math.round(value / 1000) * 1000), {
millisecondsDecimalDigits: 0,
secondsDecimalDigits: 0,
unitCount: 2,
});
}

View File

@@ -108,7 +108,6 @@ function formatDuration(ms: number): string {
return prettyMilliseconds(Math.max(0, roundedMs), {
compact: true,
hideYear: true,
secondsDecimalDigits: 0,
});
}

View File

@@ -243,8 +243,6 @@ function formatDuration(ms: number) {
}
const roundedMs = ms < 1000 ? Math.round(ms) : Math.round(ms / 1000) * 1000;
return prettyMilliseconds(roundedMs, {
millisecondsDecimalDigits: 0,
secondsDecimalDigits: 0,
unitCount: 2,
});
}

View File

@@ -24,8 +24,6 @@ export function formatIso(iso?: string) {
export function formatDuration(ms: number): string {
const roundedMs = ms < 1000 ? Math.round(ms) : Math.round(ms / 1000) * 1000;
return prettyMilliseconds(Math.max(0, roundedMs), {
millisecondsDecimalDigits: 0,
secondsDecimalDigits: 0,
unitCount: 2,
});
}

View File

@@ -193,8 +193,6 @@ function shouldWriteMatrixQaProgress() {
function formatMatrixQaDurationMs(durationMs: number) {
const roundedMs = durationMs < 1000 ? Math.round(durationMs) : Math.round(durationMs / 100) * 100;
return prettyMilliseconds(Math.max(0, roundedMs), {
millisecondsDecimalDigits: 0,
secondsDecimalDigits: 1,
unitCount: 1,
});
}

View File

@@ -65,8 +65,6 @@ export function formatDuration(durationMs: number): string {
const roundedMs =
durationMs < 1000 ? Math.round(durationMs) : Math.round(durationMs / 1000) * 1000;
return prettyMilliseconds(roundedMs, {
millisecondsDecimalDigits: 0,
secondsDecimalDigits: 0,
unitCount: 2,
});
}

View File

@@ -594,7 +594,6 @@ export function formatBuildAllDuration(durationMs) {
? Math.round(clampedMs / 10) * 10
: Math.round(clampedMs / 100) * 100;
return prettyMilliseconds(roundedMs, {
millisecondsDecimalDigits: 0,
secondsDecimalDigits: clampedMs < 10_000 ? 2 : 1,
});
}

View File

@@ -449,8 +449,6 @@ function formatDuration(ms) {
}
const roundedMs = ms < 1000 ? Math.round(ms) : Math.round(ms / 100) * 100;
return prettyMilliseconds(Math.max(0, roundedMs), {
millisecondsDecimalDigits: 0,
secondsDecimalDigits: 1,
unitCount: 1,
});
}

View File

@@ -38,7 +38,7 @@ export function formatDurationPrecise(
}
const roundedMs = Math.max(0, Math.round(ms));
if (roundedMs < 1000) {
return prettyMilliseconds(roundedMs, { millisecondsDecimalDigits: 0 });
return prettyMilliseconds(roundedMs);
}
return formatDurationSeconds(ms, {
decimals: options.decimals ?? 2,
@@ -61,11 +61,10 @@ export function formatDurationCompact(
}
const roundedMs = Math.round(ms);
if (roundedMs < 1000) {
return prettyMilliseconds(roundedMs, { millisecondsDecimalDigits: 0 });
return prettyMilliseconds(roundedMs);
}
const formatted = prettyMilliseconds(Math.round(ms / 1000) * 1000, {
hideYear: true,
secondsDecimalDigits: 0,
unitCount: 2,
});
return options?.spaced ? formatted : formatted.replaceAll(" ", "");