summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2021-12-06 17:25:23 -0500
committerLinus Groh <mail@linusgroh.de>2021-12-08 11:29:36 +0000
commitd010ba10c3987fc2a1beaf5c83767fdab87833b0 (patch)
tree0dd35e6a3d57ce161442545d3ca478d1abfb4c87 /Userland/Libraries
parent4cc8cf9233aa90f655ba4b468cc4606e3fc458bb (diff)
downloadserenity-d010ba10c3987fc2a1beaf5c83767fdab87833b0.zip
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp3
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h5
2 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp
index 8ca87b1b93..f88e5a7bb8 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp
@@ -129,6 +129,9 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(GlobalObject& glo
// 23. Let dataLocale be r.[[dataLocale]].
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").
auto time_zone_value = TRY(options->get(vm.names.timeZone));
String time_zone;
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h
index 16ff75ff38..ece9ef225d 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h
@@ -46,6 +46,9 @@ public:
String const& locale() const { return m_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; }
void set_calendar(String calendar) { m_calendar = move(calendar); }
@@ -129,6 +132,8 @@ private:
String m_time_zone; // [[TimeZone]]
Optional<Style> m_date_style; // [[DateStyle]]
Optional<Style> m_time_style; // [[TimeStyle]]
+
+ String m_data_locale;
};
enum class OptionRequired {