1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:07:34 +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

@ -14,7 +14,7 @@ namespace JS::Temporal {
class TimeZone final : public Object {
JS_OBJECT(TimeZone, Object);
// Needs to store values in the range -8.64 * 10^21 to 8.64 * 10^21
// Needs to store values in the range -8.64 * 10^13 to 8.64 * 10^13
using OffsetType = double;
public:
@ -23,7 +23,7 @@ public:
String const& identifier() const { return m_identifier; }
Optional<OffsetType> const& offset_nanoseconds() const { return m_offset_nanoseconds; }
void set_offset_nanoseconds(u32 offset_nanoseconds) { m_offset_nanoseconds = offset_nanoseconds; };
void set_offset_nanoseconds(OffsetType offset_nanoseconds) { m_offset_nanoseconds = offset_nanoseconds; };
private:
// 11.5 Properties of Temporal.TimeZone Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-timezone-instances
@ -39,5 +39,9 @@ bool is_valid_time_zone_name(String const& time_zone);
String canonicalize_time_zone_name(String const& time_zone);
String default_time_zone();
Object* create_temporal_time_zone(GlobalObject&, String const& identifier, FunctionObject* new_target = nullptr);
double parse_time_zone_offset_string(GlobalObject&, String const&);
String format_time_zone_offset_string(double offset_nanoseconds);
bool is_valid_time_zone_numeric_utc_offset_syntax(String const&);
}