1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:57:35 +00:00

LibJS: Add the ToTemporalInstant Abstract Operation & its requirements

This is Abstract Operation is required for the majority of
InstantConstructor's and InstantPrototype's methods.

The implementation is not entirely complete, (specifically 2 of the
underlying required abstract operations, ParseTemporalTimeZoneString
and ParseISODateTime are missing the required lexing, and as such are
TODO()-ed) but the majority of it is done.
This commit is contained in:
Idan Horowitz 2021-07-11 21:04:11 +03:00 committed by Linus Groh
parent 141c46feda
commit b816037739
19 changed files with 888 additions and 13 deletions

View file

@ -5,7 +5,6 @@
*/
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/Temporal/ISO8601.h>
#include <LibJS/Runtime/Temporal/TimeZone.h>
#include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
@ -54,10 +53,14 @@ Value TimeZoneConstructor::construct(FunctionObject& new_target)
String canonical;
// 3. If identifier satisfies the syntax of a TimeZoneNumericUTCOffset (see 13.33), then
if (is_valid_time_zone_numeric_utc_offset(identifier)) {
// TODO:
if (is_valid_time_zone_numeric_utc_offset_syntax(identifier)) {
// a. Let offsetNanoseconds be ? ParseTimeZoneOffsetString(identifier).
auto offset_nanoseconds = parse_time_zone_offset_string(global_object, identifier);
if (vm.exception())
return {};
// b. Let canonical be ! FormatTimeZoneOffsetString(offsetNanoseconds).
canonical = format_time_zone_offset_string(offset_nanoseconds);
}
// 4. Else,
else {