1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +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

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/Date.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/Temporal/TimeZone.h>
#include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
@ -49,9 +50,8 @@ ThrowCompletionOr<Object*> TimeZoneConstructor::construct(FunctionObject& new_ta
// 2. Set identifier to ? ToString(identifier).
auto identifier = TRY(vm.argument(0).to_string(vm));
// 3. Let parseResult be ParseText(StringToCodePoints(identifier), TimeZoneNumericUTCOffset).
// 4. If parseResult is a List of errors, then
if (!is_valid_time_zone_numeric_utc_offset_syntax(identifier)) {
// 3. If IsTimeZoneOffsetString(identifier) is false, then
if (!is_time_zone_offset_string(identifier)) {
// a. If IsValidTimeZoneName(identifier) is false, then
if (!is_valid_time_zone_name(identifier)) {
// i. Throw a RangeError exception.
@ -62,7 +62,7 @@ ThrowCompletionOr<Object*> TimeZoneConstructor::construct(FunctionObject& new_ta
identifier = canonicalize_time_zone_name(identifier);
}
// 5. Return ? CreateTemporalTimeZone(identifier, NewTarget).
// 4. Return ? CreateTemporalTimeZone(identifier, NewTarget).
return TRY(create_temporal_time_zone(vm, identifier, &new_target));
}