mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +02: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:
committed by
Andreas Kling
parent
dfe8d02482
commit
9dc9700e3b
Notes:
sideshowbarker
2024-07-17 23:07:01 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/9dc9700e3bd Pull-request: https://github.com/SerenityOS/serenity/pull/11160
@@ -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]].
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user