diff --git a/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index 310d43b5f95..aaf37fca818 100644 --- a/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -268,16 +268,16 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_string) // 7. Let smallestUnit be ? GetTemporalUnitValuedOption(resolvedOptions, "smallestUnit", UNSET). auto smallest_unit = TRY(get_temporal_unit_valued_option(vm, resolved_options, vm.names.smallestUnit, Unset {})); - // 8. Perform ? ValidateTemporalUnitValue(smallestUnit, TIME). + // 8. Let timeZone be ? Get(resolvedOptions, "timeZone"). + auto time_zone_value = TRY(resolved_options->get(vm.names.timeZone)); + + // 9. Perform ? ValidateTemporalUnitValue(smallestUnit, TIME). TRY(validate_temporal_unit_value(vm, vm.names.smallestUnit, smallest_unit, UnitGroup::Time)); - // 9. If smallestUnit is HOUR, throw a RangeError exception. + // 10. If smallestUnit is HOUR, throw a RangeError exception. if (auto const* unit = smallest_unit.get_pointer(); unit && *unit == Unit::Hour) return vm.throw_completion(ErrorType::OptionIsNotValidValue, temporal_unit_to_string(*unit), vm.names.smallestUnit); - // 10. Let timeZone be ? Get(resolvedOptions, "timeZone"). - auto time_zone_value = TRY(resolved_options->get(vm.names.timeZone)); - String time_zone_buffer; Optional time_zone; diff --git a/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index 9526da47e25..dd9cd182365 100644 --- a/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -776,16 +776,16 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_string) // 9. Let smallestUnit be ? GetTemporalUnitValuedOption(resolvedOptions, "smallestUnit", UNSET). auto smallest_unit = TRY(get_temporal_unit_valued_option(vm, resolved_options, vm.names.smallestUnit, Unset {})); - // 10. Perform ? ValidateTemporalUnitValue(smallestUnit, TIME). + // 10. Let showTimeZone be ? GetTemporalShowTimeZoneNameOption(resolvedOptions). + auto show_time_zone = TRY(get_temporal_show_time_zone_name_option(vm, resolved_options)); + + // 11. Perform ? ValidateTemporalUnitValue(smallestUnit, TIME). TRY(validate_temporal_unit_value(vm, vm.names.smallestUnit, smallest_unit, UnitGroup::Time)); - // 11. If smallestUnit is HOUR, throw a RangeError exception. + // 12. If smallestUnit is HOUR, throw a RangeError exception. if (auto const* unit = smallest_unit.get_pointer(); unit && *unit == Unit::Hour) return vm.throw_completion(ErrorType::OptionIsNotValidValue, temporal_unit_to_string(*unit), vm.names.smallestUnit); - // 12. Let showTimeZone be ? GetTemporalShowTimeZoneNameOption(resolvedOptions). - auto show_time_zone = TRY(get_temporal_show_time_zone_name_option(vm, resolved_options)); - // 13. Let precision be ToSecondsStringPrecisionRecord(smallestUnit, digits). auto precision = to_seconds_string_precision_record(smallest_unit, digits);