summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-09-02 18:35:11 +0100
committerLinus Groh <mail@linusgroh.de>2021-09-02 20:16:44 +0100
commit7acd174c8549acb6b7a87c2041e7ef3ac2c6f004 (patch)
tree0af7910f67cb5c608601e5bedae6c38a5ec4a165 /Userland/Libraries/LibJS
parentc20669328db4d3ed878cf1f1425fce92077c3b1b (diff)
downloadserenity-7acd174c8549acb6b7a87c2041e7ef3ac2c6f004.zip
LibJS: Reflect normative changes in ParseTemporalInstantString
Most of it doesn't affect us yet as the parsing code and additional AOs are not implemented yet. See: https://github.com/tc39/proposal-temporal/commit/f6ac475
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
index 89a5cb0ed6..bd4cf6e2ee 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
@@ -674,10 +674,20 @@ Optional<TemporalInstant> parse_temporal_instant_string(GlobalObject& global_obj
if (vm.exception())
return {};
- // 5. Assert: timeZoneResult.[[OffsetString]] is not undefined.
- VERIFY(time_zone_result->offset.has_value());
+ // 5. Let offsetString be timeZoneResult.[[OffsetString]].
+ auto offset_string = time_zone_result->offset;
- // 6. Return the Record { [[Year]]: result.[[Year]], [[Month]]: result.[[Month]], [[Day]]: result.[[Day]], [[Hour]]: result.[[Hour]], [[Minute]]: result.[[Minute]], [[Second]]: result.[[Second]], [[Millisecond]]: result.[[Millisecond]], [[Microsecond]]: result.[[Microsecond]], [[Nanosecond]]: result.[[Nanosecond]], [[TimeZoneOffsetString]]: timeZoneResult.[[OffsetString]] }.
+ // 6. If timeZoneResult.[[Z]] is true, then
+ if (time_zone_result->z) {
+ // a. Set offsetString to "+00:00".
+ offset_string = "+00:00"sv;
+ }
+
+ // 7. Assert: offsetString is not undefined.
+ VERIFY(offset_string.has_value());
+
+ // TODO: This is supposed to use `offset_string`, see https://github.com/tc39/proposal-temporal/pull/1799
+ // 8. Return the Record { [[Year]]: result.[[Year]], [[Month]]: result.[[Month]], [[Day]]: result.[[Day]], [[Hour]]: result.[[Hour]], [[Minute]]: result.[[Minute]], [[Second]]: result.[[Second]], [[Millisecond]]: result.[[Millisecond]], [[Microsecond]]: result.[[Microsecond]], [[Nanosecond]]: result.[[Nanosecond]], [[TimeZoneOffsetString]]: timeZoneResult.[[OffsetString]] }.
return TemporalInstant { .year = result->year, .month = result->month, .day = result->day, .hour = result->hour, .minute = result->minute, .second = result->second, .millisecond = result->millisecond, .microsecond = result->microsecond, .nanosecond = result->nanosecond, .time_zone_offset = move(time_zone_result->offset) };
}
@@ -800,8 +810,8 @@ Optional<TemporalTimeZone> parse_temporal_time_zone_string(GlobalObject& global_
// 4. If z is not undefined, then
if (z_part.has_value()) {
- // a. Return the Record { [[Z]]: "Z", [[OffsetString]]: "+00:00", [[Name]]: undefined }.
- return TemporalTimeZone { .z = true, .offset = "+00:00", .name = {} };
+ // a. Return the Record { [[Z]]: true, [[OffsetString]]: undefined, [[Name]]: name }.
+ return TemporalTimeZone { .z = true, .offset = {}, .name = name_part.has_value() ? String { *name_part } : Optional<String> {} };
}
Optional<String> offset;
@@ -868,7 +878,7 @@ Optional<TemporalTimeZone> parse_temporal_time_zone_string(GlobalObject& global_
name = canonicalize_time_zone_name(*name_part);
}
- // 8. Return the Record { [[Z]]: undefined, [[OffsetString]]: offsetString, [[Name]]: name }.
+ // 8. Return the Record { [[Z]]: false, [[OffsetString]]: offsetString, [[Name]]: name }.
return TemporalTimeZone { .z = false, .offset = offset, .name = name };
}