Browse Source

LibJS+LibUnicode: Update the Intl.DateTimeFormat constructor spec steps

This constructor has undergone a handful of editorial changes that we
fell behind on. But we weren't able to take the updates until now due to
a spec bug in those updates. See:
https://github.com/tc39/ecma402/commit/3f029b0

The result is that we can remove the inheritance of Intl::DateTimeFormat
from Unicode::DateTimeFormat; the former now contains the latter as an
internal slot.
Timothy Flynn 11 months ago
parent
commit
c7dd4afd9c

+ 3 - 3
Userland/Libraries/LibJS/Print.cpp

@@ -738,9 +738,9 @@ ErrorOr<void> print_intl_date_time_format(JS::PrintContext& print_context, JS::I
     TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.calendar()), seen_objects));
     TRY(js_out(print_context, "\n  numberingSystem: "));
     TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.numbering_system()), seen_objects));
-    if (date_time_format.hour_cycle.has_value()) {
+    if (auto const& hour_cycle = date_time_format.date_time_format().hour_cycle; hour_cycle.has_value()) {
         TRY(js_out(print_context, "\n  hourCycle: "));
-        TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), Unicode::hour_cycle_to_string(*date_time_format.hour_cycle)), seen_objects));
+        TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), Unicode::hour_cycle_to_string(*hour_cycle)), seen_objects));
     }
     TRY(js_out(print_context, "\n  timeZone: "));
     TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.time_zone()), seen_objects));
@@ -753,7 +753,7 @@ ErrorOr<void> print_intl_date_time_format(JS::PrintContext& print_context, JS::I
         TRY(print_value(print_context, JS::PrimitiveString::create(date_time_format.vm(), date_time_format.time_style_string()), seen_objects));
     }
 
-    auto result = JS::Intl::for_each_calendar_field(date_time_format.vm(), date_time_format, [&](auto& option, auto const& property, auto const&) -> JS::ThrowCompletionOr<void> {
+    auto result = JS::Intl::for_each_calendar_field(date_time_format.vm(), date_time_format.date_time_format(), [&](auto& option, auto const& property, auto const&) -> JS::ThrowCompletionOr<void> {
         using ValueType = typename RemoveReference<decltype(option)>::ValueType;
 
         if (!option.has_value())

+ 5 - 3
Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h

@@ -18,9 +18,7 @@
 
 namespace JS::Intl {
 
-class DateTimeFormat final
-    : public Object
-    , public Unicode::CalendarPattern {
+class DateTimeFormat final : public Object {
     JS_OBJECT(DateTimeFormat, Object);
     JS_DECLARE_ALLOCATOR(DateTimeFormat);
 
@@ -58,6 +56,9 @@ public:
     StringView time_style_string() const { return Unicode::date_time_style_to_string(*m_time_style); }
     void set_time_style(StringView style) { m_time_style = Unicode::date_time_style_from_string(style); }
 
+    Unicode::CalendarPattern& date_time_format() { return m_date_time_format; }
+    void set_date_time_format(Unicode::CalendarPattern date_time_format) { m_date_time_format = move(date_time_format); }
+
     NativeFunction* bound_format() const { return m_bound_format; }
     void set_bound_format(NativeFunction* bound_format) { m_bound_format = bound_format; }
 
@@ -75,6 +76,7 @@ private:
     String m_time_zone;                            // [[TimeZone]]
     Optional<Unicode::DateTimeStyle> m_date_style; // [[DateStyle]]
     Optional<Unicode::DateTimeStyle> m_time_style; // [[TimeStyle]]
+    Unicode::CalendarPattern m_date_time_format;   // [[DateTimeFormat]]
     GCPtr<NativeFunction> m_bound_format;          // [[BoundFormat]]
 
     // Non-standard. Stores the ICU date-time formatter for the Intl object's formatting options.

+ 52 - 73
Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp

@@ -84,7 +84,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatConstructor::supported_locales_of)
 // 11.1.2 CreateDateTimeFormat ( newTarget, locales, options, required, defaults ), https://tc39.es/ecma402/#sec-createdatetimeformat
 ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm, FunctionObject& new_target, Value locales_value, Value options_value, OptionRequired required, OptionDefaults defaults)
 {
-    // 1. Let dateTimeFormat be ? OrdinaryCreateFromConstructor(newTarget, "%DateTimeFormat.prototype%", « [[InitializedDateTimeFormat]], [[Locale]], [[Calendar]], [[NumberingSystem]], [[TimeZone]], [[Weekday]], [[Era]], [[Year]], [[Month]], [[Day]], [[DayPeriod]], [[Hour]], [[Minute]], [[Second]], [[FractionalSecondDigits]], [[TimeZoneName]], [[HourCycle]], [[DateStyle]], [[TimeStyle]], [[Pattern]], [[RangePatterns]], [[BoundFormat]] »).
+    // 1. Let dateTimeFormat be ? OrdinaryCreateFromConstructor(newTarget, "%Intl.DateTimeFormat.prototype%", « [[InitializedDateTimeFormat]], [[Locale]], [[Calendar]], [[NumberingSystem]], [[TimeZone]], [[HourCycle]], [[DateStyle]], [[TimeStyle]], [[DateTimeFormat]], [[BoundFormat]] »).
     auto date_time_format = TRY(ordinary_create_from_constructor<DateTimeFormat>(vm, new_target, &Intrinsics::intl_date_time_format_prototype));
 
     // 2. Let requestedLocales be ? CanonicalizeLocaleList(locales).
@@ -143,37 +143,35 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
     // 16. Set opt.[[hc]] to hourCycle.
     opt.hc = locale_key_from_value(hour_cycle);
 
-    // 17. Let localeData be %DateTimeFormat%.[[LocaleData]].
-    // 18. Let r be ResolveLocale(%DateTimeFormat%.[[AvailableLocales]], requestedLocales, opt, %DateTimeFormat%.[[RelevantExtensionKeys]], localeData).
+    // 17. Let r be ResolveLocale(%Intl.DateTimeFormat%.[[AvailableLocales]], requestedLocales, opt, %Intl.DateTimeFormat%.[[RelevantExtensionKeys]], %Intl.DateTimeFormat%.[[LocaleData]]).
     auto result = resolve_locale(requested_locales, opt, DateTimeFormat::relevant_extension_keys());
 
-    // 19. Set dateTimeFormat.[[Locale]] to r.[[locale]].
+    // 18. Set dateTimeFormat.[[Locale]] to r.[[Locale]].
     date_time_format->set_locale(move(result.locale));
 
-    // 20. Let resolvedCalendar be r.[[ca]].
-    // 21. Set dateTimeFormat.[[Calendar]] to resolvedCalendar.
+    // 19. Let resolvedCalendar be r.[[ca]].
+    // 20. Set dateTimeFormat.[[Calendar]] to resolvedCalendar.
     if (auto* resolved_calendar = result.ca.get_pointer<String>())
         date_time_format->set_calendar(move(*resolved_calendar));
 
-    // 22. Set dateTimeFormat.[[NumberingSystem]] to r.[[nu]].
+    // 21. Set dateTimeFormat.[[NumberingSystem]] to r.[[nu]].
     if (auto* resolved_numbering_system = result.nu.get_pointer<String>())
         date_time_format->set_numbering_system(move(*resolved_numbering_system));
 
-    // 23. Let dataLocale be r.[[dataLocale]].
+    // 22. Let resolvedLocaleData be r.[[LocaleData]].
 
-    // 24. Let dataLocaleData be localeData.[[<dataLocale>]].
     Optional<Unicode::HourCycle> hour_cycle_value;
     Optional<bool> hour12_value;
 
-    // 25. If hour12 is true, then
-    //     a. Let hc be dataLocaleData.[[hourCycle12]].
-    // 26. Else if hour12 is false, then
-    //     a. Let hc be dataLocaleData.[[hourCycle24]].
+    // 23. If hour12 is true, then
+    //     a. Let hc be resolvedLocaleData.[[hourCycle12]].
+    // 24. Else if hour12 is false, then
+    //     a. Let hc be resolvedLocaleData.[[hourCycle24]].
     if (hour12.is_boolean()) {
         // NOTE: We let LibUnicode figure out the appropriate hour cycle.
         hour12_value = hour12.as_bool();
     }
-    // 27. Else,
+    // 25. Else,
     else {
         // a. Assert: hour12 is undefined.
         VERIFY(hour12.is_undefined());
@@ -182,30 +180,27 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
         if (auto* resolved_hour_cycle = result.hc.get_pointer<String>())
             hour_cycle_value = Unicode::hour_cycle_from_string(*resolved_hour_cycle);
 
-        // c. If hc is null, set hc to dataLocaleData.[[hourCycle]].
+        // c. If hc is null, set hc to resolvedLocaleData.[[hourCycle]].
         if (!hour_cycle_value.has_value())
             hour_cycle_value = Unicode::default_hour_cycle(date_time_format->locale());
     }
 
-    // 28. Set dateTimeFormat.[[HourCycle]] to hc.
-    date_time_format->hour_cycle = hour_cycle_value;
-
-    // 29. Let timeZone be ? Get(options, "timeZone").
+    // 26. Let timeZone be ? Get(options, "timeZone").
     auto time_zone_value = TRY(options->get(vm.names.timeZone));
     String time_zone;
 
-    // 30. If timeZone is undefined, then
+    // 27. If timeZone is undefined, then
     if (time_zone_value.is_undefined()) {
-        // a. Set timeZone to DefaultTimeZone().
+        // a. Set timeZone to SystemTimeZoneIdentifier().
         time_zone = system_time_zone_identifier();
     }
-    // 31. Else,
+    // 28. Else,
     else {
         // a. Set timeZone to ? ToString(timeZone).
         time_zone = TRY(time_zone_value.to_string(vm));
     }
 
-    // 32. If IsTimeZoneOffsetString(timeZone) is true, then
+    // 29. If IsTimeZoneOffsetString(timeZone) is true, then
     bool is_time_zone_offset_string = JS::is_time_zone_offset_string(time_zone);
 
     if (is_time_zone_offset_string) {
@@ -222,7 +217,7 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
         // d. Let offsetNanoseconds be ParseTimeZoneOffsetString(timeZone).
         auto offset_nanoseconds = parse_time_zone_offset_string(time_zone);
 
-        // e. Let offsetMinutes be offsetNanoseconds / (6 × 10^10).
+        // e. Let offsetMinutes be offsetNanoseconds / (6 × 10**10).
         auto offset_minutes = offset_nanoseconds / 60'000'000'000;
 
         // f. Assert: offsetMinutes is an integer.
@@ -231,7 +226,7 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
         // g. Set timeZone to FormatOffsetTimeZoneIdentifier(offsetMinutes).
         time_zone = format_offset_time_zone_identifier(offset_minutes);
     }
-    // 33. Else
+    // 30. Else,
     else {
         // a. Let timeZoneIdentifierRecord be GetAvailableNamedTimeZoneIdentifier(timeZone).
         auto time_zone_identifier_record = get_available_named_time_zone_identifier(time_zone);
@@ -244,29 +239,29 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
         time_zone = time_zone_identifier_record->primary_identifier;
     }
 
-    // 35. Set dateTimeFormat.[[TimeZone]] to timeZone.
+    // 31. Set dateTimeFormat.[[TimeZone]] to timeZone.
     date_time_format->set_time_zone(time_zone);
 
     // NOTE: ICU requires time zone offset strings to be of the form "GMT+00:00"
     if (is_time_zone_offset_string)
         time_zone = MUST(String::formatted("GMT{}", time_zone));
 
-    // 36. Let formatOptions be a new Record.
+    // 32. Let formatOptions be a new Record.
     Unicode::CalendarPattern format_options {};
 
-    // 37. Set formatOptions.[[hourCycle]] to hc.
+    // 33. Set formatOptions.[[hourCycle]] to hc.
     format_options.hour_cycle = hour_cycle_value;
     format_options.hour12 = hour12_value;
 
-    // 38. Let hasExplicitFormatComponents be false.
+    // 34. Let hasExplicitFormatComponents be false.
     // NOTE: Instead of using a boolean, we track any explicitly provided component name for nicer exception messages.
     PropertyKey const* explicit_format_component = nullptr;
 
-    // 39. For each row of Table 6, except the header row, in table order, do
+    // 35. For each row of Table 16, except the header row, in table order, do
     TRY(for_each_calendar_field(vm, format_options, [&](auto& option, PropertyKey const& property, auto const& values) -> ThrowCompletionOr<void> {
         using ValueType = typename RemoveReference<decltype(option)>::ValueType;
 
-        // a. Let prop be the name given in the Property column of the row.
+        // a. Let prop be the name given in the Property column of the current row.
 
         // b. If prop is "fractionalSecondDigits", then
         if constexpr (IsIntegral<ValueType>) {
@@ -284,7 +279,7 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
         }
         // c. Else,
         else {
-            // i. Let values be a List whose elements are the strings given in the Values column of the row.
+            // i. Let values be a List whose elements are the strings given in the Values column of the current row.
             // ii. Let value be ? GetOption(options, prop, string, values, undefined).
             auto value = TRY(get_option(vm, *options, property, OptionType::String, values, Empty {}));
 
@@ -301,24 +296,26 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
         return {};
     }));
 
-    // 40. Let matcher be ? GetOption(options, "formatMatcher", string, « "basic", "best fit" », "best fit").
-    matcher = TRY(get_option(vm, *options, vm.names.formatMatcher, OptionType::String, AK::Array { "basic"sv, "best fit"sv }, "best fit"sv));
+    // 36. Let formatMatcher be ? GetOption(options, "formatMatcher", string, « "basic", "best fit" », "best fit").
+    [[maybe_unused]] auto format_matcher = TRY(get_option(vm, *options, vm.names.formatMatcher, OptionType::String, AK::Array { "basic"sv, "best fit"sv }, "best fit"sv));
 
-    // 41. Let dateStyle be ? GetOption(options, "dateStyle", string, « "full", "long", "medium", "short" », undefined).
+    // 37. Let dateStyle be ? GetOption(options, "dateStyle", string, « "full", "long", "medium", "short" », undefined).
     auto date_style = TRY(get_option(vm, *options, vm.names.dateStyle, OptionType::String, AK::Array { "full"sv, "long"sv, "medium"sv, "short"sv }, Empty {}));
 
-    // 42. Set dateTimeFormat.[[DateStyle]] to dateStyle.
+    // 38. Set dateTimeFormat.[[DateStyle]] to dateStyle.
     if (!date_style.is_undefined())
         date_time_format->set_date_style(date_style.as_string().utf8_string_view());
 
-    // 43. Let timeStyle be ? GetOption(options, "timeStyle", string, « "full", "long", "medium", "short" », undefined).
+    // 39. Let timeStyle be ? GetOption(options, "timeStyle", string, « "full", "long", "medium", "short" », undefined).
     auto time_style = TRY(get_option(vm, *options, vm.names.timeStyle, OptionType::String, AK::Array { "full"sv, "long"sv, "medium"sv, "short"sv }, Empty {}));
 
-    // 44. Set dateTimeFormat.[[TimeStyle]] to timeStyle.
+    // 40. Set dateTimeFormat.[[TimeStyle]] to timeStyle.
     if (!time_style.is_undefined())
         date_time_format->set_time_style(time_style.as_string().utf8_string_view());
 
-    // 45. If dateStyle is not undefined or timeStyle is not undefined, then
+    OwnPtr<Unicode::DateTimeFormat> formatter;
+
+    // 41. If dateStyle is not undefined or timeStyle is not undefined, then
     if (date_time_format->has_date_style() || date_time_format->has_time_style()) {
         // a. If hasExplicitFormatComponents is true, then
         if (explicit_format_component != nullptr) {
@@ -338,18 +335,17 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
             return vm.throw_completion<TypeError>(ErrorType::IntlInvalidDateTimeFormatOption, "dateStyle"sv, "time"sv);
         }
 
-        // d. Let styles be dataLocaleData.[[styles]].[[<resolvedCalendar>]].
+        // d. Let styles be resolvedLocaleData.[[styles]].[[<resolvedCalendar>]].
         // e. Let bestFormat be DateTimeStyleFormat(dateStyle, timeStyle, styles).
-        auto formatter = Unicode::DateTimeFormat::create_for_date_and_time_style(
+        formatter = Unicode::DateTimeFormat::create_for_date_and_time_style(
             date_time_format->locale(),
             time_zone,
             format_options.hour_cycle,
             format_options.hour12,
             date_time_format->date_style(),
             date_time_format->time_style());
-        date_time_format->set_formatter(move(formatter));
     }
-    // 46. Else,
+    // 42. Else,
     else {
         // a. Let needDefaults be true.
         bool needs_defaults = true;
@@ -359,7 +355,7 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
             // i. For each property name prop of « "weekday", "year", "month", "day" », do
             auto check_property_value = [&](auto const& value) {
                 // 1. Let value be formatOptions.[[<prop>]].
-                // 2. If value is not undefined, let needDefaults be false.
+                // 2. If value is not undefined, set needDefaults to false.
                 if (value.has_value())
                     needs_defaults = false;
             };
@@ -375,7 +371,7 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
             // i. For each property name prop of « "dayPeriod", "hour", "minute", "second", "fractionalSecondDigits" », do
             auto check_property_value = [&](auto const& value) {
                 // 1. Let value be formatOptions.[[<prop>]].
-                // 2. If value is not undefined, let needDefaults be false.
+                // 2. If value is not undefined, set needDefaults to false.
                 if (value.has_value())
                     needs_defaults = false;
             };
@@ -413,45 +409,28 @@ ThrowCompletionOr<NonnullGCPtr<DateTimeFormat>> create_date_time_format(VM& vm,
             set_property_value(format_options.second);
         }
 
-        // f. Let formats be dataLocaleData.[[formats]].[[<resolvedCalendar>]].
-        // g. If matcher is "basic", then
+        // f. Let formats be resolvedLocaleData.[[formats]].[[<resolvedCalendar>]].
+        // g. If formatMatcher is "basic", then
         //     i. Let bestFormat be BasicFormatMatcher(formatOptions, formats).
         // h. Else,
         //     i. Let bestFormat be BestFitFormatMatcher(formatOptions, formats).
-        auto formatter = Unicode::DateTimeFormat::create_for_pattern_options(
+        formatter = Unicode::DateTimeFormat::create_for_pattern_options(
             date_time_format->locale(),
             time_zone,
             format_options);
-        date_time_format->set_formatter(move(formatter));
     }
 
-    // 47. For each row in Table 6, except the header row, in table order, do
-    date_time_format->for_each_calendar_field_zipped_with(date_time_format->formatter().chosen_pattern(), [&](auto& date_time_format_field, auto const& best_format_field) {
-        // a. Let prop be the name given in the Property column of the row.
-        // b. If bestFormat has a field [[<prop>]], then
-        if (best_format_field.has_value()) {
-            // i. Let p be bestFormat.[[<prop>]].
-            // ii. Set dateTimeFormat's internal slot whose name is the Internal Slot column of the row to p.
-            date_time_format_field = best_format_field;
-        }
-    });
+    // 43. Set dateTimeFormat.[[DateTimeFormat]] to bestFormat.
+    date_time_format->set_date_time_format(formatter->chosen_pattern());
 
-    // 48. If dateTimeFormat.[[Hour]] is undefined, then
-    if (!date_time_format->hour.has_value()) {
-        // a. Set dateTimeFormat.[[HourCycle]] to undefined.
-        date_time_format->hour_cycle.clear();
-    }
+    // 44. If bestFormat has a field [[hour]], then
+    //     a. Set dateTimeFormat.[[HourCycle]] to hc.
+    // NOTE: The [[HourCycle]] is stored and accessed from [[DateTimeFormat]].
 
-    // 49. If dateTimeFormat.[[HourCycle]] is "h11" or "h12", then
-    //     a. Let pattern be bestFormat.[[pattern12]].
-    //     b. Let rangePatterns be bestFormat.[[rangePatterns12]].
-    // 50. Else,
-    //     a. Let pattern be bestFormat.[[pattern]].
-    //     b. Let rangePatterns be bestFormat.[[rangePatterns]].
-    // 51. Set dateTimeFormat.[[Pattern]] to pattern.
-    // 52. Set dateTimeFormat.[[RangePatterns]] to rangePatterns.
+    // Non-standard, create an ICU number formatter for this Intl object.
+    date_time_format->set_formatter(formatter.release_nonnull());
 
-    // 53. Return dateTimeFormat.
+    // 45. Return dateTimeFormat.
     return date_time_format;
 }
 

+ 23 - 18
Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp

@@ -160,29 +160,34 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options)
     // 4. Let options be OrdinaryObjectCreate(%Object.prototype%).
     auto options = Object::create(realm, realm.intrinsics().object_prototype());
 
-    // 5. For each row of Table 5, except the header row, in table order, do
-    //     a. Let p be the Property value of the current row.
-    //     b. If p is "hour12", then
-    //         i. Let hc be dtf.[[HourCycle]].
-    //         ii. If hc is "h11" or "h12", let v be true.
-    //         iii. Else if, hc is "h23" or "h24", let v be false.
-    //         iv. Else, let v be undefined.
-    //     c. Else,
-    //         i. Let v be the value of dtf's internal slot whose name is the Internal Slot value of the current row.
-    //     d. If the Internal Slot value of the current row is an Internal Slot value in Table 6, then
-    //         i. If dtf.[[DateStyle]] is not undefined or dtf.[[TimeStyle]] is not undefined, then
-    //             1. Let v be undefined.
-    //     e. If v is not undefined, then
-    //         i. Perform ! CreateDataPropertyOrThrow(options, p, v).
+    // 5. For each row of Table 15, except the header row, in table order, do
+    //    a. Let p be the Property value of the current row.
+    //    b. If there is an Internal Slot value in the current row, then
+    //        i. Let v be the value of dtf's internal slot whose name is the Internal Slot value of the current row.
+    //    c. Else,
+    //        i. Let format be dtf.[[DateTimeFormat]].
+    //        ii. If format has a field [[<p>]] and dtf.[[DateStyle]] is undefined and dtf.[[TimeStyle]] is undefined, then
+    //            1. Let v be format.[[<p>]].
+    //        iii. Else,
+    //            1. Let v be undefined.
+    //    d. If v is not undefined, then
+    //        i. If there is a Conversion value in the current row, then
+    //            1. Let conversion be the Conversion value of the current row.
+    //            2. If conversion is hour12, then
+    //                a. If v is "h11" or "h12", set v to true. Otherwise, set v to false.
+    //            3. Else,
+    //                a. Assert: conversion is number.
+    //                b. Set v to 𝔽(v).
+    //        ii. Perform ! CreateDataPropertyOrThrow(options, p, v).
     MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, date_time_format->locale())));
     MUST(options->create_data_property_or_throw(vm.names.calendar, PrimitiveString::create(vm, date_time_format->calendar())));
     MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, date_time_format->numbering_system())));
     MUST(options->create_data_property_or_throw(vm.names.timeZone, PrimitiveString::create(vm, date_time_format->time_zone())));
 
-    if (date_time_format->hour_cycle.has_value()) {
-        MUST(options->create_data_property_or_throw(vm.names.hourCycle, PrimitiveString::create(vm, Unicode::hour_cycle_to_string(*date_time_format->hour_cycle))));
+    if (auto const hour_cycle = date_time_format->date_time_format().hour_cycle; hour_cycle.has_value()) {
+        MUST(options->create_data_property_or_throw(vm.names.hourCycle, PrimitiveString::create(vm, Unicode::hour_cycle_to_string(*hour_cycle))));
 
-        switch (*date_time_format->hour_cycle) {
+        switch (*hour_cycle) {
         case Unicode::HourCycle::H11:
         case Unicode::HourCycle::H12:
             MUST(options->create_data_property_or_throw(vm.names.hour12, Value(true)));
@@ -195,7 +200,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options)
     }
 
     if (!date_time_format->has_date_style() && !date_time_format->has_time_style()) {
-        MUST(for_each_calendar_field(vm, date_time_format, [&](auto& option, auto const& property, auto const&) -> ThrowCompletionOr<void> {
+        MUST(for_each_calendar_field(vm, date_time_format->date_time_format(), [&](auto& option, auto const& property, auto const&) -> ThrowCompletionOr<void> {
             using ValueType = typename RemoveReference<decltype(option)>::ValueType;
 
             if (!option.has_value())

+ 0 - 17
Userland/Libraries/LibUnicode/DateTimeFormat.h

@@ -63,23 +63,6 @@ struct CalendarPattern {
     static CalendarPattern create_from_pattern(StringView);
     String to_pattern() const;
 
-    template<typename Callback>
-    void for_each_calendar_field_zipped_with(CalendarPattern const& other, Callback&& callback)
-    {
-        callback(hour_cycle, other.hour_cycle);
-        callback(era, other.era);
-        callback(year, other.year);
-        callback(month, other.month);
-        callback(weekday, other.weekday);
-        callback(day, other.day);
-        callback(day_period, other.day_period);
-        callback(hour, other.hour);
-        callback(minute, other.minute);
-        callback(second, other.second);
-        callback(fractional_second_digits, other.fractional_second_digits);
-        callback(time_zone_name, other.time_zone_name);
-    }
-
     Optional<HourCycle> hour_cycle;
     Optional<bool> hour12;