1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:27:35 +00:00

LibJS+LibUnicode: Generate a set of default DateTimeFormat patterns

This isn't called out in TR-35, but before ICU even looks at CLDR data,
it adds a hard-coded set of default patterns to each locale's calendar.
It has done this since 2006 when its DateTimeFormat feature was first
created. Several test262 tests depend on this, which under ECMA-402,
falls into "implementation defined" behavior. For compatibility, we
can do the same in LibUnicode.
This commit is contained in:
Timothy Flynn 2022-07-22 18:00:06 -04:00 committed by Linus Groh
parent 8150d71821
commit ae2acc8cdf
3 changed files with 56 additions and 2 deletions

View file

@ -431,7 +431,7 @@ Optional<Unicode::CalendarPattern> basic_format_matcher(Unicode::CalendarPattern
best_format->for_each_calendar_field_zipped_with(options, [&](auto& best_format_field, auto const& option_field, auto field_type) {
switch (field_type) {
case Unicode::CalendarPattern::Field::FractionalSecondDigits:
if (best_format->second.has_value() && option_field.has_value())
if ((best_format_field.has_value() || best_format->second.has_value()) && option_field.has_value())
best_format_field = option_field;
break;