mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibJS: Read user options in some Temporal toString methods sooner
This is a normative change in the Temporal proposal. See:
3eaaadf
This commit is contained in:
parent
d87b3030a7
commit
355589a89e
Notes:
github-actions[bot]
2025-08-28 23:15:42 +00:00
Author: https://github.com/trflynn89
Commit: 355589a89e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6019
Reviewed-by: https://github.com/gmta ✅
2 changed files with 10 additions and 10 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue