Explorar o código

LibJS: Update parse_temporal_time_zone() to match the spec again

Linus Groh %!s(int64=3) %!d(string=hai) anos
pai
achega
3f1af7c05f
Modificáronse 1 ficheiros con 7 adicións e 3 borrados
  1. 7 3
      Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp

+ 7 - 3
Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp

@@ -74,12 +74,16 @@ ThrowCompletionOr<String> parse_temporal_time_zone(GlobalObject& global_object,
     // 2. Let result be ? ParseTemporalTimeZoneString(string).
     // 2. Let result be ? ParseTemporalTimeZoneString(string).
     auto result = TRY(parse_temporal_time_zone_string(global_object, string));
     auto result = TRY(parse_temporal_time_zone_string(global_object, string));
 
 
-    // 3. If result.[[Z]] is not undefined, return "UTC".
+    // 3. If result.[[Name]] is not undefined, return result.[[Name]].
+    if (result.name.has_value())
+        return *result.name;
+
+    // 4. If result.[[Z]] is true, return "UTC".
     if (result.z)
     if (result.z)
         return String { "UTC" };
         return String { "UTC" };
 
 
-    // 4. Return result.[[Name]].
-    return *result.name;
+    // 5. Return result.[[OffsetString]].
+    return *result.offset;
 }
 }
 
 
 // 11.6.2 CreateTemporalTimeZone ( identifier [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporaltimezone
 // 11.6.2 CreateTemporalTimeZone ( identifier [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporaltimezone