diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-09-16 00:59:40 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-16 13:53:37 +0100 |
commit | 1822b2938e9edffa7337aa2af8c7ecd9d662fd8e (patch) | |
tree | 479af8b944523c0b2cc7a1c7b6df891824efe7c4 /Userland | |
parent | 5a4c90fcb1d4bb3fea5bf564ac13a58813d73663 (diff) | |
download | serenity-1822b2938e9edffa7337aa2af8c7ecd9d662fd8e.zip |
LibJS: Convert ZonedDateTime AOs to ThrowCompletionOr
Diffstat (limited to 'Userland')
5 files changed, 7 insertions, 7 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index 7289e78dc2..ed96c10be9 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -553,7 +553,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_zoned_date_time) return {}; // 10. Return ? CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, calendar). - return create_temporal_zoned_date_time(global_object, instant->nanoseconds(), *time_zone, *calendar); + return TRY_OR_DISCARD(create_temporal_zoned_date_time(global_object, instant->nanoseconds(), *time_zone, *calendar)); } // 8.3.18 Temporal.Instant.prototype.toZonedDateTimeISO ( item ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.tozoneddatetimeiso @@ -590,7 +590,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_zoned_date_time_iso) auto* calendar = get_iso8601_calendar(global_object); // 6. Return ? CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, calendar). - return create_temporal_zoned_date_time(global_object, instant->nanoseconds(), *time_zone, *calendar); + return TRY_OR_DISCARD(create_temporal_zoned_date_time(global_object, instant->nanoseconds(), *time_zone, *calendar)); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp index 664710dab0..3a732631a5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp @@ -254,7 +254,7 @@ ZonedDateTime* system_zoned_date_time(GlobalObject& global_object, Value tempora auto* ns = system_utc_epoch_nanoseconds(global_object); // 5. Return ? CreateTemporalZonedDateTime(ns, timeZone, calendar). - return create_temporal_zoned_date_time(global_object, *ns, *time_zone, *calendar); + return TRY_OR_DISCARD(create_temporal_zoned_date_time(global_object, *ns, *time_zone, *calendar)); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index fed3f02d5d..8714bbf099 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -31,7 +31,7 @@ void ZonedDateTime::visit_edges(Cell::Visitor& visitor) } // 6.5.3 CreateTemporalZonedDateTime ( epochNanoseconds, timeZone, calendar [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporalzoneddatetime -ZonedDateTime* create_temporal_zoned_date_time(GlobalObject& global_object, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target) +ThrowCompletionOr<ZonedDateTime*> create_temporal_zoned_date_time(GlobalObject& global_object, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target) { // 1. Assert: Type(epochNanoseconds) is BigInt. // 3. Assert: Type(timeZone) is Object. @@ -48,7 +48,7 @@ ZonedDateTime* create_temporal_zoned_date_time(GlobalObject& global_object, BigI // 7. Set object.[[Nanoseconds]] to epochNanoseconds. // 8. Set object.[[TimeZone]] to timeZone. // 9. Set object.[[Calendar]] to calendar. - auto* object = TRY_OR_DISCARD(ordinary_create_from_constructor<ZonedDateTime>(global_object, *new_target, &GlobalObject::temporal_time_zone_prototype, epoch_nanoseconds, time_zone, calendar)); + auto* object = TRY(ordinary_create_from_constructor<ZonedDateTime>(global_object, *new_target, &GlobalObject::temporal_time_zone_prototype, epoch_nanoseconds, time_zone, calendar)); // 10. Return object. return object; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h index 42bcd15a2d..8bd512ad9f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h @@ -33,6 +33,6 @@ private: Object& m_calendar; // [[Calendar]] }; -ZonedDateTime* create_temporal_zoned_date_time(GlobalObject&, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target = nullptr); +ThrowCompletionOr<ZonedDateTime*> create_temporal_zoned_date_time(GlobalObject&, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target = nullptr); } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp index a895d26f00..d9ca18db8a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp @@ -70,7 +70,7 @@ Value ZonedDateTimeConstructor::construct(FunctionObject& new_target) return {}; // 6. Return ? CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar, NewTarget). - return create_temporal_zoned_date_time(global_object, *epoch_nanoseconds, *time_zone, *calendar, &new_target); + return TRY_OR_DISCARD(create_temporal_zoned_date_time(global_object, *epoch_nanoseconds, *time_zone, *calendar, &new_target)); } } |