diff --git a/src/common/datetime/format_duration.ts b/src/common/datetime/format_duration.ts index e823df03a3b0..e20f7e18af25 100644 --- a/src/common/datetime/format_duration.ts +++ b/src/common/datetime/format_duration.ts @@ -71,7 +71,7 @@ export const formatDurationDigital = ( duration: HaDurationData ) => formatDigitalDurationMem(locale).format(duration); -export const DURATION_UNITS = ["ms", "s", "min", "h", "d"] as const; +export const DURATION_UNITS = ["s", "min", "h", "d"] as const; type DurationUnit = (typeof DURATION_UNITS)[number]; @@ -107,14 +107,6 @@ const formatDurationSecondMem = memoizeOne( }) ); -const formatDurationMillisecondMem = memoizeOne( - (locale: FrontendLocaleData) => - new Intl.DurationFormat(locale.language, { - style: "narrow", - millisecondsDisplay: "always", - }) -); - export const formatDuration = ( locale: FrontendLocaleData, duration: string, @@ -163,13 +155,6 @@ export const formatDuration = ( }; return formatDurationSecondMem(locale).format(input); } - case "ms": { - const milliseconds = Math.floor(value); - const input: DurationInput = { - milliseconds, - }; - return formatDurationMillisecondMem(locale).format(input); - } default: throw new Error("Invalid duration unit"); } diff --git a/test/common/datetime/format_duration.test.ts b/test/common/datetime/format_duration.test.ts index 94ad9e116fc3..cd62785320e4 100644 --- a/test/common/datetime/format_duration.test.ts +++ b/test/common/datetime/format_duration.test.ts @@ -21,14 +21,6 @@ const LOCALE: FrontendLocaleData = { describe("formatDuration", () => { it("works", () => { - assert.strictEqual(formatDuration(LOCALE, "0", "ms"), "0ms"); - assert.strictEqual(formatDuration(LOCALE, "1", "ms"), "1ms"); - assert.strictEqual(formatDuration(LOCALE, "10", "ms"), "10ms"); - assert.strictEqual(formatDuration(LOCALE, "100", "ms"), "100ms"); - assert.strictEqual(formatDuration(LOCALE, "1000", "ms"), "1,000ms"); - assert.strictEqual(formatDuration(LOCALE, "1001", "ms"), "1,001ms"); - assert.strictEqual(formatDuration(LOCALE, "65000", "ms"), "65,000ms"); - assert.strictEqual(formatDuration(LOCALE, "0.5", "s"), "0s 500ms"); assert.strictEqual(formatDuration(LOCALE, "1", "s"), "1s"); assert.strictEqual(formatDuration(LOCALE, "1.1", "s"), "1s 100ms");