This commit is contained in:
Ben Allen 2024-03-12 16:19:26 -07:00 committed by Ms2ger
parent 263ed65292
commit af3890a10a
1 changed files with 3 additions and 15 deletions

View File

@ -4,7 +4,7 @@
/*---
esid: sec-Intl.DurationFormat.prototype.format
description: >
The correct separator is used for numeric hours with zero minutes and non-zero seconds.
Minutes with numeric or 2-digit style are included in the output when between displayed hours and seconds, even when the minutes value is zero.
locale: [en-US]
features: [Intl.DurationFormat]
---*/
@ -14,28 +14,16 @@ const df = new Intl.DurationFormat("en", {
hours: "numeric",
});
const lf = new Intl.ListFormat("en", {
type: "unit",
style: "short",
});
const duration = {
hours: 1,
// Minutes is omitted from the output when its value is zero.
minutes: 0,
// Either seconds or sub-seconds must be non-zero.
seconds: 3,
};
const expected = lf.format([
new Intl.NumberFormat("en", {minimumIntegerDigits: 1}).format(duration.hours),
new Intl.NumberFormat("en", {minimumIntegerDigits: 2}).format(duration.seconds),
]);
const expected = "1:00:03"
assert.sameValue(
df.format(duration),
expected,
`No time separator is used when minutes is zero`
`Minutes always displayed when between displayed hours and seconds, even if minutes is 0`
);