mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 07:07:39 +00:00
LibJS: Map DurationFormat's list style to "short" when it is "digital"
This is a normative change in the Intl.DurationFormat proposal. See:
7495e32
This commit is contained in:
parent
84e6833203
commit
4686989582
3 changed files with 9 additions and 9 deletions
|
@ -510,8 +510,8 @@ Vector<PatternPartition> partition_duration_format_pattern(VM& vm, DurationForma
|
||||||
|
|
||||||
// 7. If listStyle is "digital", then
|
// 7. If listStyle is "digital", then
|
||||||
if (list_style == DurationFormat::Style::Digital) {
|
if (list_style == DurationFormat::Style::Digital) {
|
||||||
// a. Set listStyle to "narrow".
|
// a. Set listStyle to "short".
|
||||||
list_style = DurationFormat::Style::Narrow;
|
list_style = DurationFormat::Style::Short;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto unicode_list_style = ::Locale::style_to_string(static_cast<::Locale::Style>(list_style));
|
auto unicode_list_style = ::Locale::style_to_string(static_cast<::Locale::Style>(list_style));
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe("correct behavior", () => {
|
||||||
"1y 2m 3w 3d 4h 5m 6s 7ms 8μs 9ns"
|
"1y 2m 3w 3d 4h 5m 6s 7ms 8μs 9ns"
|
||||||
);
|
);
|
||||||
expect(new Intl.DurationFormat("en", { style: "digital" }).format(duration)).toBe(
|
expect(new Intl.DurationFormat("en", { style: "digital" }).format(duration)).toBe(
|
||||||
"1 yr 2 mths 3 wks 3 days 4:05:06"
|
"1 yr, 2 mths, 3 wks, 3 days, 4:05:06"
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
new Intl.DurationFormat("en", {
|
new Intl.DurationFormat("en", {
|
||||||
|
@ -81,8 +81,8 @@ describe("correct behavior", () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const en = new Intl.DurationFormat("en", { style: "digital" });
|
const en = new Intl.DurationFormat("en", { style: "digital" });
|
||||||
expect(en.format(duration1)).toBe("1 yr 2 mths 3 wks 3 days 0:00:00");
|
expect(en.format(duration1)).toBe("1 yr, 2 mths, 3 wks, 3 days, 0:00:00");
|
||||||
expect(en.format(duration2)).toBe("1 yr 2 mths 3 wks 3 days 4:05:06");
|
expect(en.format(duration2)).toBe("1 yr, 2 mths, 3 wks, 3 days, 4:05:06");
|
||||||
|
|
||||||
const de = new Intl.DurationFormat("de", { style: "digital" });
|
const de = new Intl.DurationFormat("de", { style: "digital" });
|
||||||
expect(de.format(duration1)).toBe("1 J, 2 Mon., 3 Wo., 3 Tg. und 0:00:00");
|
expect(de.format(duration1)).toBe("1 J, 2 Mon., 3 Wo., 3 Tg. und 0:00:00");
|
||||||
|
|
|
@ -124,13 +124,13 @@ describe("correct behavior", () => {
|
||||||
expect(new Intl.DurationFormat("en", { style: "digital" }).formatToParts(duration)).toEqual(
|
expect(new Intl.DurationFormat("en", { style: "digital" }).formatToParts(duration)).toEqual(
|
||||||
[
|
[
|
||||||
{ type: "element", value: "1 yr" },
|
{ type: "element", value: "1 yr" },
|
||||||
{ type: "literal", value: " " },
|
{ type: "literal", value: ", " },
|
||||||
{ type: "element", value: "2 mths" },
|
{ type: "element", value: "2 mths" },
|
||||||
{ type: "literal", value: " " },
|
{ type: "literal", value: ", " },
|
||||||
{ type: "element", value: "3 wks" },
|
{ type: "element", value: "3 wks" },
|
||||||
{ type: "literal", value: " " },
|
{ type: "literal", value: ", " },
|
||||||
{ type: "element", value: "3 days" },
|
{ type: "element", value: "3 days" },
|
||||||
{ type: "literal", value: " " },
|
{ type: "literal", value: ", " },
|
||||||
{ type: "element", value: "4:05:06" },
|
{ type: "element", value: "4:05:06" },
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue