1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 12:17:44 +00:00

LibJS: Fallback to [[pattern]] when [[pattern12]] is unavailable

Other implementations unconditionally initialize [[pattern12]] from
[[pattern]] regardless of whether [[pattern]] has an hour pattern of h11
or h12. LibUnicode does not do this. So when InitializeDateTimeFormat
defaults the hour cycle to the locale's preferred hour cycle, if the
best format didn't have an equivalent hour pattern, [[pattern12]] will
be empty.
This commit is contained in:
Timothy Flynn 2021-12-01 12:24:35 -05:00 committed by Andreas Kling
parent dfe8d02482
commit 9dc9700e3b

View file

@ -322,8 +322,13 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(GlobalObject& glo
// f. If dateTimeformat.[[HourCycle]] is "h11" or "h12", then
if ((hour_cycle == Unicode::HourCycle::H11) || (hour_cycle == Unicode::HourCycle::H12)) {
// i. Let pattern be bestFormat.[[pattern12]].
if (best_format->pattern12.has_value())
if (best_format->pattern12.has_value()) {
pattern = best_format->pattern12.release_value();
} else {
// Non-standard, LibUnicode only provides [[pattern12]] when [[pattern]] has a day
// period. Other implementations provide [[pattern12]] as a copy of [[pattern]].
pattern = move(best_format->pattern);
}
// ii. Let rangePatterns be bestFormat.[[rangePatterns12]].
}