1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:57:44 +00:00

LibJS: Only call CanonicalizeTimeZoneName on valid time zone IDs

This is an editorial change in the Temporal spec.

See: 30122e6
This commit is contained in:
Linus Groh 2022-06-14 23:22:42 +01:00
parent cf61d01140
commit 9d2377ff60

View file

@ -450,12 +450,12 @@ ThrowCompletionOr<Object*> to_temporal_time_zone(GlobalObject& global_object, Va
// 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/1941
// 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;
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)) {
@ -468,10 +468,13 @@ ThrowCompletionOr<Object*> to_temporal_time_zone(GlobalObject& global_object, Va
// 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);
// ii. Set name to ! CanonicalizeTimeZoneName(name).
name = canonicalize_time_zone_name(name);
}
// c. Return ! CreateTemporalTimeZone(! CanonicalizeTimeZoneName(name)).
return MUST(create_temporal_time_zone(global_object, canonicalize_time_zone_name(name)));
// c. Return ! CreateTemporalTimeZone(name).
return MUST(create_temporal_time_zone(global_object, name));
}
// 5. If parseResult.[[Z]] is true, return ! CreateTemporalTimeZone("UTC").