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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// |reftest| skip-if(!this.hasOwnProperty("Intl"))
const {
DayPeriod, Hour, Minute, Second, FractionalSecond, Literal
} = DateTimeFormatParts
const tests = [
// https://unicode-org.atlassian.net/browse/CLDR-13184
// https://unicode-org.atlassian.net/browse/CLDR-13623
{
locale: "en",
date: new Date("2020-01-01T00:00:00.123"),
options: {hour: "numeric", fractionalSecondDigits: 3},
parts: [
Hour("12"),
Literal(" "),
DayPeriod("AM"),
Literal(" (Fractional Second: "),
FractionalSecond("123"),
Literal(")")
]
},
// https://unicode-org.atlassian.net/browse/ICU-20992
{
locale: "ckb-IR",
date: new Date("2020-01-01T00:00:00.123"),
options: {minute: "2-digit", fractionalSecondDigits: 3},
parts: [
Minute("٠٠"),
Literal(":"),
Second("٠٠"),
Literal("٫"),
FractionalSecond("١٢٣"),
]
},
// https://unicode-org.atlassian.net/browse/ICU-20992
{
locale: "ckb-IR",
date: new Date("2020-01-01T00:00:00.123"),
options: {dayPeriod: "short", fractionalSecondDigits: 3},
parts: [
FractionalSecond("١٢٣"),
Literal(" (Dayperiod: "),
DayPeriod("ب.ن"),
Literal(")")
]
},
];
for (let {locale, date, options, parts} of tests) {
let dtf = new Intl.DateTimeFormat(locale, options);
assertParts(dtf, date, parts);
}
if (typeof reportCompare === "function")
reportCompare(0, 0, "ok");
|