mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibJS: Fix production for time zone name in time zone strings
This is a normative change in the Temporal spec. See: -caf013a
-fb7cfa6
This commit is contained in:
parent
f5669a1373
commit
3720f4bd8f
5 changed files with 11 additions and 29 deletions
|
@ -449,25 +449,13 @@ ThrowCompletionOr<Object*> to_temporal_time_zone(GlobalObject& global_object, Va
|
|||
// 3. Let parseResult be ? ParseTemporalTimeZoneString(identifier).
|
||||
auto parse_result = TRY(parse_temporal_time_zone_string(global_object, identifier));
|
||||
|
||||
// TODO: This currently cannot be tested as ParseTemporalTimeZoneString only considers
|
||||
// TimeZoneIANAName for the returned [[Name]] slot, not TimeZoneUTCOffsetName.
|
||||
// So when we provide a numeric time zone offset, this branch won't be executed,
|
||||
// and if we provide an IANA name, it won't be a valid TimeZoneNumericUTCOffset.
|
||||
// This should be fixed by: https://github.com/tc39/proposal-temporal/pull/2200
|
||||
|
||||
// 4. If parseResult.[[Name]] is not undefined, then
|
||||
if (parse_result.name.has_value()) {
|
||||
// a. Let name be parseResult.[[Name]].
|
||||
auto name = parse_result.name.release_value();
|
||||
|
||||
// b. If ParseText(StringToCodePoints(name, TimeZoneNumericUTCOffset)) is not a List of errors, then
|
||||
if (is_valid_time_zone_numeric_utc_offset_syntax(name)) {
|
||||
// i. If parseResult.[[OffsetString]] is not undefined, and ! ParseTimeZoneOffsetString(parseResult.[[OffsetString]]) ≠ ! ParseTimeZoneOffsetString(name), throw a RangeError exception.
|
||||
if (parse_result.offset_string.has_value() && (MUST(parse_time_zone_offset_string(global_object, *parse_result.offset_string)) != MUST(parse_time_zone_offset_string(global_object, name))))
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalTimeZoneOffsetStringMismatch, *parse_result.offset_string, name);
|
||||
}
|
||||
// c. Else,
|
||||
else {
|
||||
// b. If ParseText(StringToCodePoints(name, TimeZoneNumericUTCOffset)) is a List of errors, then
|
||||
if (!is_valid_time_zone_numeric_utc_offset_syntax(name)) {
|
||||
// i. If IsValidTimeZoneName(name) is false, throw a RangeError exception.
|
||||
if (!is_valid_time_zone_name(name))
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidTimeZoneName, name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue