1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// |reftest| skip -- Intl.DurationFormat is not supported
// Copyright (C) 2023 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DurationFormat.prototype.format
description: >
The correct separator is used for numeric hours with zero minutes and non-zero seconds.
locale: [en-US]
features: [Intl.DurationFormat]
---*/
const df = new Intl.DurationFormat("en", {
// hours must be numeric, so that a time separator is used for the following units.
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),
]);
assert.sameValue(
df.format(duration),
expected,
`No time separator is used when minutes is zero`
);
reportCompare(0, 0);
|