mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +00:00
LibJS+LibUnicode: Generate missing patterns with fractionalSecondDigits
TR-35's Matching Skeleton algorithm dictates how user requests including fractional second digits should be handled when the CLDR format pattern does not include that field. When the format pattern contains {second}, but does not contain {fractionalSecondDigits}, generate a second pattern which appends "{decimal}{fractionalSecondDigits}" to the {second} field.
This commit is contained in:
parent
6ace4000bf
commit
9f7c727720
3 changed files with 46 additions and 7 deletions
|
@ -659,9 +659,18 @@ Optional<Unicode::CalendarPattern> basic_format_matcher(Unicode::CalendarPattern
|
|||
//
|
||||
// Rather than generating an prohibitively large amount of nearly-duplicate patterns, which only
|
||||
// differ by field length, we expand the field lengths here.
|
||||
best_format->for_each_calendar_field_zipped_with(options, [](auto& best_format_field, auto const& option_field, auto) {
|
||||
if (best_format_field.has_value() && option_field.has_value())
|
||||
best_format_field = option_field;
|
||||
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())
|
||||
best_format_field = option_field;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (best_format_field.has_value() && option_field.has_value())
|
||||
best_format_field = option_field;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// 11. Return bestFormat.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue