mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibJS: Read user options in some Temporal toString methods sooner
This is a normative change in the Temporal proposal. See: https://github.com/tc39/proposal-temporal/commit/3eaaadf
This commit is contained in:
parent
d87b3030a7
commit
355589a89e
|
|
@ -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 == Unit::Hour)
|
||||
return vm.throw_completion<RangeError>(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<StringView> time_zone;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 == Unit::Hour)
|
||||
return vm.throw_completion<RangeError>(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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user