mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 17:29:01 +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:
parent
dfe8d02482
commit
9dc9700e3b
Notes:
sideshowbarker
2024-07-17 23:07:01 +09:00
Author: https://github.com/trflynn89
Commit: 9dc9700e3b
Pull-request: https://github.com/SerenityOS/serenity/pull/11160
1 changed files with 6 additions and 1 deletions
|
@ -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]].
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue