1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:38:13 +00:00

LibJS: Add the ToTemporalTime AO and stub the ParseTemporalTimeString AO

This AO is required for a bunch of PlainTime related methods.

As part of this change the `TemporalTime` record was renamed to
`UnregulatedTemporalTime` and a new `TemporalTime` record that matches
the other Temporal parse result records was added. This also has the
added benefit of getting rid of a would be round-trip cast from integer
to double and back in `ParseTemporalTimeString`.
This commit is contained in:
Idan Horowitz 2021-08-27 18:02:37 +03:00 committed by Linus Groh
parent 32fc81c186
commit f6370fe3f7
5 changed files with 147 additions and 17 deletions

View file

@ -53,6 +53,16 @@ struct TemporalDate {
Optional<String> calendar;
};
struct TemporalTime {
u8 hour;
u8 minute;
u8 second;
u16 millisecond;
u16 microsecond;
u16 nanosecond;
Optional<String> calendar = {};
};
struct TemporalTimeZone {
bool z;
Optional<String> offset;
@ -75,6 +85,7 @@ Optional<String> parse_temporal_calendar_string(GlobalObject&, String const& iso
Optional<TemporalDate> parse_temporal_date_string(GlobalObject&, String const& iso_string);
Optional<ISODateTime> parse_temporal_date_time_string(GlobalObject&, String const& iso_string);
Optional<TemporalDuration> parse_temporal_duration_string(GlobalObject&, String const& iso_string);
Optional<TemporalTime> parse_temporal_time_string(GlobalObject&, String const& iso_string);
Optional<TemporalTimeZone> parse_temporal_time_zone_string(GlobalObject&, String const& iso_string);
double to_positive_integer_or_infinity(GlobalObject&, Value argument);
Object* prepare_temporal_fields(GlobalObject&, Object& fields, Vector<String> const& field_names, Vector<StringView> const& required_fields);