mirror of
https://github.com/RGBCube/serenity
synced 2026-01-12 23:31:01 +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;
|
||||
break;
|
||||
|
||||
case Unicode::CalendarPattern::Field::Hour:
|
||||
case Unicode::CalendarPattern::Field::Minute:
|
||||
case Unicode::CalendarPattern::Field::Second:
|
||||
break;
|
||||
|
||||
default:
|
||||
if (best_format_field.has_value() && option_field.has_value())
|
||||
best_format_field = option_field;
|
||||
|
|
|
|||
|
|
@ -165,14 +165,14 @@ describe("correct behavior", () => {
|
|||
test("minute", () => {
|
||||
["2-digit", "numeric"].forEach(minute => {
|
||||
const en = new Intl.DateTimeFormat("en", { minute: minute });
|
||||
expect(en.resolvedOptions().minute).toBe(minute);
|
||||
expect(en.resolvedOptions().minute).toBe("2-digit");
|
||||
});
|
||||
});
|
||||
|
||||
test("second", () => {
|
||||
["2-digit", "numeric"].forEach(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