1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:27:43 +00:00

LibJS: Use infallible ParseTimeZoneOffsetString

This is an editorial change in the Temporal spec. See:
654e300
This commit is contained in:
Timothy Flynn 2022-10-14 11:42:12 -04:00 committed by Linus Groh
parent d992cba014
commit 443ffab9dc
7 changed files with 83 additions and 138 deletions

View file

@ -125,8 +125,12 @@ ThrowCompletionOr<BigInt*> parse_temporal_instant(VM& vm, String const& iso_stri
// 5. Let utc be GetUTCEpochNanoseconds(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).
auto utc = get_utc_epoch_nanoseconds(result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond);
// 6. Let offsetNanoseconds be ? ParseTimeZoneOffsetString(offsetString).
auto offset_nanoseconds = TRY(parse_time_zone_offset_string(vm, *offset_string));
// 6. If IsTimeZoneOffsetString(offsetString) is false, throw a RangeError exception.
if (!is_time_zone_offset_string(*offset_string))
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidTimeZoneName, *offset_string);
// 7. Let offsetNanoseconds be ParseTimeZoneOffsetString(offsetString).
auto offset_nanoseconds = parse_time_zone_offset_string(*offset_string);
// 7. Let result be utc - (offsetNanoseconds).
auto result_ns = utc.minus(Crypto::SignedBigInteger { offset_nanoseconds });