mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00:00
LibJS: Cache the data locale used by Intl.DateTimeFormat
Unlike the locale, the data locale has Unicode locale extensions removed (e.g. the data locale for "en-US-u-ca-gregory" is just "en-US"). Cache the data locale for LibUnicode lookups during formatting.
This commit is contained in:
parent
4cc8cf9233
commit
d010ba10c3
2 changed files with 8 additions and 0 deletions
|
@ -129,6 +129,9 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(GlobalObject& glo
|
||||||
// 23. Let dataLocale be r.[[dataLocale]].
|
// 23. Let dataLocale be r.[[dataLocale]].
|
||||||
auto data_locale = move(result.data_locale);
|
auto data_locale = move(result.data_locale);
|
||||||
|
|
||||||
|
// Non-standard, the data locale is needed for LibUnicode lookups while formatting.
|
||||||
|
date_time_format.set_data_locale(data_locale);
|
||||||
|
|
||||||
// 24. Let timeZone be ? Get(options, "timeZone").
|
// 24. Let timeZone be ? Get(options, "timeZone").
|
||||||
auto time_zone_value = TRY(options->get(vm.names.timeZone));
|
auto time_zone_value = TRY(options->get(vm.names.timeZone));
|
||||||
String time_zone;
|
String time_zone;
|
||||||
|
|
|
@ -46,6 +46,9 @@ public:
|
||||||
String const& locale() const { return m_locale; }
|
String const& locale() const { return m_locale; }
|
||||||
void set_locale(String locale) { m_locale = move(locale); }
|
void set_locale(String locale) { m_locale = move(locale); }
|
||||||
|
|
||||||
|
String const& data_locale() const { return m_data_locale; }
|
||||||
|
void set_data_locale(String data_locale) { m_data_locale = move(data_locale); }
|
||||||
|
|
||||||
String const& calendar() const { return m_calendar; }
|
String const& calendar() const { return m_calendar; }
|
||||||
void set_calendar(String calendar) { m_calendar = move(calendar); }
|
void set_calendar(String calendar) { m_calendar = move(calendar); }
|
||||||
|
|
||||||
|
@ -129,6 +132,8 @@ private:
|
||||||
String m_time_zone; // [[TimeZone]]
|
String m_time_zone; // [[TimeZone]]
|
||||||
Optional<Style> m_date_style; // [[DateStyle]]
|
Optional<Style> m_date_style; // [[DateStyle]]
|
||||||
Optional<Style> m_time_style; // [[TimeStyle]]
|
Optional<Style> m_time_style; // [[TimeStyle]]
|
||||||
|
|
||||||
|
String m_data_locale;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class OptionRequired {
|
enum class OptionRequired {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue