mirror of
https://github.com/RGBCube/serenity
synced 2025-07-22 11:47:35 +00:00
LibJS: Do not override hour, minute, and second format field lengths
This was an oversight in e42d954743
.
These fields should always follow the locale preference in the CLDR.
Overriding these fields would permit formats like "h:mm:ss" to result in
strings like "1:2:3" instead of "1:02:03".
This commit is contained in:
parent
9f7c727720
commit
26f9666191
2 changed files with 7 additions and 2 deletions
|
@ -666,6 +666,11 @@ Optional<Unicode::CalendarPattern> basic_format_matcher(Unicode::CalendarPattern
|
||||||
best_format_field = option_field;
|
best_format_field = option_field;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Unicode::CalendarPattern::Field::Hour:
|
||||||
|
case Unicode::CalendarPattern::Field::Minute:
|
||||||
|
case Unicode::CalendarPattern::Field::Second:
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (best_format_field.has_value() && option_field.has_value())
|
if (best_format_field.has_value() && option_field.has_value())
|
||||||
best_format_field = option_field;
|
best_format_field = option_field;
|
||||||
|
|
|
@ -165,14 +165,14 @@ describe("correct behavior", () => {
|
||||||
test("minute", () => {
|
test("minute", () => {
|
||||||
["2-digit", "numeric"].forEach(minute => {
|
["2-digit", "numeric"].forEach(minute => {
|
||||||
const en = new Intl.DateTimeFormat("en", { minute: minute });
|
const en = new Intl.DateTimeFormat("en", { minute: minute });
|
||||||
expect(en.resolvedOptions().minute).toBe(minute);
|
expect(en.resolvedOptions().minute).toBe("2-digit");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("second", () => {
|
test("second", () => {
|
||||||
["2-digit", "numeric"].forEach(second => {
|
["2-digit", "numeric"].forEach(second => {
|
||||||
const en = new Intl.DateTimeFormat("en", { second: second });
|
const en = new Intl.DateTimeFormat("en", { second: second });
|
||||||
expect(en.resolvedOptions().second).toBe(second);
|
expect(en.resolvedOptions().second).toBe("2-digit");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue