mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:37:46 +00:00
LibJS: Convert Instant AOs to ThrowCompletionOr
This commit is contained in:
parent
ea7cc70118
commit
20337a34a2
11 changed files with 86 additions and 119 deletions
|
@ -861,7 +861,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_temporal_instant)
|
|||
ns = js_bigint(vm, ns->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000'000 }));
|
||||
|
||||
// 3. Return ! CreateTemporalInstant(ns).
|
||||
return Temporal::create_temporal_instant(global_object, *ns);
|
||||
return Temporal::create_temporal_instant(global_object, *ns).release_value();
|
||||
}
|
||||
|
||||
// 21.4.4.45 Date.prototype [ @@toPrimitive ] ( hint ), https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <AK/Variant.h>
|
||||
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Temporal/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Temporal/Calendar.h>
|
||||
|
@ -49,7 +50,7 @@ bool is_valid_epoch_nanoseconds(BigInt const& epoch_nanoseconds)
|
|||
}
|
||||
|
||||
// 8.5.2 CreateTemporalInstant ( epochNanoseconds [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporalinstant
|
||||
Instant* create_temporal_instant(GlobalObject& global_object, BigInt const& epoch_nanoseconds, FunctionObject const* new_target)
|
||||
ThrowCompletionOr<Instant*> create_temporal_instant(GlobalObject& global_object, BigInt const& epoch_nanoseconds, FunctionObject const* new_target)
|
||||
{
|
||||
// 1. Assert: Type(epochNanoseconds) is BigInt.
|
||||
|
||||
|
@ -62,14 +63,14 @@ Instant* create_temporal_instant(GlobalObject& global_object, BigInt const& epoc
|
|||
|
||||
// 4. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.Instant.prototype%", « [[InitializedTemporalInstant]], [[Nanoseconds]] »).
|
||||
// 5. Set object.[[Nanoseconds]] to epochNanoseconds.
|
||||
auto* object = TRY_OR_DISCARD(ordinary_create_from_constructor<Instant>(global_object, *new_target, &GlobalObject::temporal_instant_prototype, epoch_nanoseconds));
|
||||
auto* object = TRY(ordinary_create_from_constructor<Instant>(global_object, *new_target, &GlobalObject::temporal_instant_prototype, epoch_nanoseconds));
|
||||
|
||||
// 6. Return object.
|
||||
return object;
|
||||
}
|
||||
|
||||
// 8.5.3 ToTemporalInstant ( item ), https://tc39.es/proposal-temporal/#sec-temporal-totemporalinstant
|
||||
Instant* to_temporal_instant(GlobalObject& global_object, Value item)
|
||||
ThrowCompletionOr<Instant*> to_temporal_instant(GlobalObject& global_object, Value item)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
|
@ -92,27 +93,25 @@ Instant* to_temporal_instant(GlobalObject& global_object, Value item)
|
|||
|
||||
// 2. Let string be ? ToString(item).
|
||||
auto string = item.to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
|
||||
// 3. Let epochNanoseconds be ? ParseTemporalInstant(string).
|
||||
auto* epoch_nanoseconds = parse_temporal_instant(global_object, string);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* epoch_nanoseconds = TRY(parse_temporal_instant(global_object, string));
|
||||
|
||||
// 4. Return ! CreateTemporalInstant(ℤ(epochNanoseconds)).
|
||||
return create_temporal_instant(global_object, *epoch_nanoseconds);
|
||||
}
|
||||
|
||||
// 8.5.4 ParseTemporalInstant ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalinstant
|
||||
BigInt* parse_temporal_instant(GlobalObject& global_object, String const& iso_string)
|
||||
ThrowCompletionOr<BigInt*> parse_temporal_instant(GlobalObject& global_object, String const& iso_string)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. Assert: Type(isoString) is String.
|
||||
|
||||
// 2. Let result be ? ParseTemporalInstantString(isoString).
|
||||
auto result = TRY_OR_DISCARD(parse_temporal_instant_string(global_object, iso_string));
|
||||
auto result = TRY(parse_temporal_instant_string(global_object, iso_string));
|
||||
|
||||
// 3. Let offsetString be result.[[TimeZoneOffsetString]].
|
||||
auto& offset_string = result.time_zone_offset;
|
||||
|
@ -122,18 +121,17 @@ BigInt* parse_temporal_instant(GlobalObject& global_object, String const& iso_st
|
|||
|
||||
// 5. Let utc be ? GetEpochFromISOParts(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).
|
||||
auto* utc = get_epoch_from_iso_parts(global_object, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
|
||||
// 6. If utc < −8.64 × 10^21 or utc > 8.64 × 10^21, then
|
||||
if (utc->big_integer() < INSTANT_NANOSECONDS_MIN || utc->big_integer() > INSTANT_NANOSECONDS_MAX) {
|
||||
// a. Throw a RangeError exception.
|
||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds);
|
||||
return {};
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds);
|
||||
}
|
||||
|
||||
// 7. Let offsetNanoseconds be ? ParseTimeZoneOffsetString(offsetString).
|
||||
auto offset_nanoseconds = TRY_OR_DISCARD(parse_time_zone_offset_string(global_object, *offset_string));
|
||||
auto offset_nanoseconds = TRY(parse_time_zone_offset_string(global_object, *offset_string));
|
||||
|
||||
// 8. Return utc − offsetNanoseconds.
|
||||
return js_bigint(vm, utc->big_integer().minus(Crypto::SignedBigInteger::create_from(offset_nanoseconds)));
|
||||
|
@ -155,7 +153,7 @@ i32 compare_epoch_nanoseconds(BigInt const& epoch_nanoseconds_one, BigInt const&
|
|||
}
|
||||
|
||||
// 8.5.6 AddInstant ( epochNanoseconds, hours, minutes, seconds, milliseconds, microseconds, nanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal-addinstant
|
||||
BigInt* add_instant(GlobalObject& global_object, BigInt const& epoch_nanoseconds, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds)
|
||||
ThrowCompletionOr<BigInt*> add_instant(GlobalObject& global_object, BigInt const& epoch_nanoseconds, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
|
@ -174,10 +172,8 @@ BigInt* add_instant(GlobalObject& global_object, BigInt const& epoch_nanoseconds
|
|||
.plus(Crypto::SignedBigInteger::create_from((i64)hours).multiplied_by(Crypto::SignedBigInteger { 3600 }).multiplied_by(Crypto::SignedBigInteger { 1'000'000'000 })));
|
||||
|
||||
// If ! IsValidEpochNanoseconds(result) is false, throw a RangeError exception.
|
||||
if (!is_valid_epoch_nanoseconds(*result)) {
|
||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds);
|
||||
return {};
|
||||
}
|
||||
if (!is_valid_epoch_nanoseconds(*result))
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds);
|
||||
|
||||
// 4. Return result.
|
||||
return result;
|
||||
|
@ -240,7 +236,7 @@ BigInt* round_temporal_instant(GlobalObject& global_object, BigInt const& nanose
|
|||
}
|
||||
|
||||
// 8.5.9 TemporalInstantToString ( instant, timeZone, precision ), https://tc39.es/proposal-temporal/#sec-temporal-temporalinstanttostring
|
||||
Optional<String> temporal_instant_to_string(GlobalObject& global_object, Instant& instant, Value time_zone, Variant<StringView, u8> const& precision)
|
||||
ThrowCompletionOr<String> temporal_instant_to_string(GlobalObject& global_object, Instant& instant, Value time_zone, Variant<StringView, u8> const& precision)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
|
@ -254,19 +250,19 @@ Optional<String> temporal_instant_to_string(GlobalObject& global_object, Instant
|
|||
if (output_time_zone.is_undefined()) {
|
||||
// TODO: Can this really throw...?
|
||||
// a. Set outputTimeZone to ? CreateTemporalTimeZone("UTC").
|
||||
output_time_zone = TRY_OR_DISCARD(create_temporal_time_zone(global_object, "UTC"sv));
|
||||
output_time_zone = TRY(create_temporal_time_zone(global_object, "UTC"sv));
|
||||
}
|
||||
|
||||
// 5. Let isoCalendar be ! GetISO8601Calendar().
|
||||
auto* iso_calendar = get_iso8601_calendar(global_object);
|
||||
|
||||
// 6. Let dateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(outputTimeZone, instant, isoCalendar).
|
||||
auto* date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, output_time_zone, instant, *iso_calendar));
|
||||
auto* date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, output_time_zone, instant, *iso_calendar));
|
||||
|
||||
// 7. Let dateTimeString be ? TemporalDateTimeToString(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], undefined, precision, "never").
|
||||
auto date_time_string = temporal_date_time_to_string(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), js_undefined(), precision, "never"sv);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (auto* exception = vm.exception())
|
||||
return throw_completion(exception->value());
|
||||
|
||||
Optional<String> time_zone_string;
|
||||
|
||||
|
@ -278,7 +274,7 @@ Optional<String> temporal_instant_to_string(GlobalObject& global_object, Instant
|
|||
// 9. Else,
|
||||
else {
|
||||
// a. Let timeZoneString be ? BuiltinTimeZoneGetOffsetStringFor(timeZone, instant).
|
||||
time_zone_string = TRY_OR_DISCARD(builtin_time_zone_get_offset_string_for(global_object, time_zone, instant));
|
||||
time_zone_string = TRY(builtin_time_zone_get_offset_string_for(global_object, time_zone, instant));
|
||||
}
|
||||
|
||||
// 10. Return the string-concatenation of dateTimeString and timeZoneString.
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <LibJS/Runtime/BigInt.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
|
@ -36,13 +37,13 @@ const auto INSTANT_NANOSECONDS_MIN = "-8640000000000000000000"_sbigint;
|
|||
const auto INSTANT_NANOSECONDS_MAX = "8640000000000000000000"_sbigint;
|
||||
|
||||
bool is_valid_epoch_nanoseconds(BigInt const& epoch_nanoseconds);
|
||||
Instant* create_temporal_instant(GlobalObject&, BigInt const& nanoseconds, FunctionObject const* new_target = nullptr);
|
||||
Instant* to_temporal_instant(GlobalObject&, Value item);
|
||||
BigInt* parse_temporal_instant(GlobalObject&, String const& iso_string);
|
||||
ThrowCompletionOr<Instant*> create_temporal_instant(GlobalObject&, BigInt const& nanoseconds, FunctionObject const* new_target = nullptr);
|
||||
ThrowCompletionOr<Instant*> to_temporal_instant(GlobalObject&, Value item);
|
||||
ThrowCompletionOr<BigInt*> parse_temporal_instant(GlobalObject&, String const& iso_string);
|
||||
i32 compare_epoch_nanoseconds(BigInt const&, BigInt const&);
|
||||
BigInt* add_instant(GlobalObject&, BigInt const& epoch_nanoseconds, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
||||
ThrowCompletionOr<BigInt*> add_instant(GlobalObject&, BigInt const& epoch_nanoseconds, double hours, double minutes, double seconds, double milliseconds, double microseconds, double nanoseconds);
|
||||
BigInt* difference_instant(GlobalObject&, BigInt const& nanoseconds1, BigInt const& nanoseconds2, u64 rounding_increment, StringView smallest_unit, StringView rounding_mode);
|
||||
BigInt* round_temporal_instant(GlobalObject&, BigInt const& nanoseconds, u64 increment, StringView unit, StringView rounding_mode);
|
||||
Optional<String> temporal_instant_to_string(GlobalObject&, Instant&, Value time_zone, Variant<StringView, u8> const& precision);
|
||||
ThrowCompletionOr<String> temporal_instant_to_string(GlobalObject&, Instant&, Value time_zone, Variant<StringView, u8> const& precision);
|
||||
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ Value InstantConstructor::construct(FunctionObject& new_target)
|
|||
}
|
||||
|
||||
// 4. Return ? CreateTemporalInstant(epochNanoseconds, NewTarget).
|
||||
return create_temporal_instant(global_object, *epoch_nanoseconds, &new_target);
|
||||
return TRY_OR_DISCARD(create_temporal_instant(global_object, *epoch_nanoseconds, &new_target));
|
||||
}
|
||||
|
||||
// 8.2.2 Temporal.Instant.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.instant.from
|
||||
|
@ -78,11 +78,11 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from)
|
|||
// 1. If Type(item) is Object and item has an [[InitializedTemporalInstant]] internal slot, then
|
||||
if (item.is_object() && is<Instant>(item.as_object())) {
|
||||
// a. Return ! CreateTemporalInstant(item.[[Nanoseconds]]).
|
||||
return create_temporal_instant(global_object, *js_bigint(vm, static_cast<Instant&>(item.as_object()).nanoseconds().big_integer()));
|
||||
return create_temporal_instant(global_object, *js_bigint(vm, static_cast<Instant&>(item.as_object()).nanoseconds().big_integer())).release_value();
|
||||
}
|
||||
|
||||
// 2. Return ? ToTemporalInstant(item).
|
||||
return to_temporal_instant(global_object, item);
|
||||
return TRY_OR_DISCARD(to_temporal_instant(global_object, item));
|
||||
}
|
||||
|
||||
// 8.2.3 Temporal.Instant.fromEpochSeconds ( epochSeconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochseconds
|
||||
|
@ -108,7 +108,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_seconds)
|
|||
}
|
||||
|
||||
// 5. Return ! CreateTemporalInstant(epochNanoseconds).
|
||||
return create_temporal_instant(global_object, *epoch_nanoseconds);
|
||||
return create_temporal_instant(global_object, *epoch_nanoseconds).release_value();
|
||||
}
|
||||
|
||||
// 8.2.4 Temporal.Instant.fromEpochMilliseconds ( epochMilliseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochmilliseconds
|
||||
|
@ -134,7 +134,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_milliseconds)
|
|||
}
|
||||
|
||||
// 5. Return ! CreateTemporalInstant(epochNanoseconds).
|
||||
return create_temporal_instant(global_object, *epoch_nanoseconds);
|
||||
return create_temporal_instant(global_object, *epoch_nanoseconds).release_value();
|
||||
}
|
||||
|
||||
// 8.2.5 Temporal.Instant.fromEpochMicroseconds ( epochMicroseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochmicroseconds
|
||||
|
@ -155,7 +155,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_microseconds)
|
|||
}
|
||||
|
||||
// 4. Return ! CreateTemporalInstant(epochNanoseconds).
|
||||
return create_temporal_instant(global_object, *epoch_nanoseconds);
|
||||
return create_temporal_instant(global_object, *epoch_nanoseconds).release_value();
|
||||
}
|
||||
|
||||
// 8.2.6 Temporal.Instant.fromEpochNanoseconds ( epochNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochnanoseconds
|
||||
|
@ -173,21 +173,17 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_nanoseconds)
|
|||
}
|
||||
|
||||
// 3. Return ! CreateTemporalInstant(epochNanoseconds).
|
||||
return create_temporal_instant(global_object, *epoch_nanoseconds);
|
||||
return create_temporal_instant(global_object, *epoch_nanoseconds).release_value();
|
||||
}
|
||||
|
||||
// 8.2.7 Temporal.Instant.compare ( one, two ), https://tc39.es/proposal-temporal/#sec-temporal.instant.compare
|
||||
JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::compare)
|
||||
{
|
||||
// 1. Set one to ? ToTemporalInstant(one).
|
||||
auto* one = to_temporal_instant(global_object, vm.argument(0));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* one = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0)));
|
||||
|
||||
// 2. Set two to ? ToTemporalInstant(two).
|
||||
auto* two = to_temporal_instant(global_object, vm.argument(1));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* two = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(1)));
|
||||
|
||||
// 3. Return 𝔽(! CompareEpochNanoseconds(one.[[Nanoseconds]], two.[[Nanoseconds]])).
|
||||
return Value(compare_epoch_nanoseconds(one->nanoseconds(), two->nanoseconds()));
|
||||
|
|
|
@ -140,12 +140,12 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::add)
|
|||
auto duration = TRY_OR_DISCARD(to_limited_temporal_duration(global_object, temporal_duration_like, { "years"sv, "months"sv, "weeks"sv, "days"sv }));
|
||||
|
||||
// 4. Let ns be ? AddInstant(instant.[[Nanoseconds]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
|
||||
auto* ns = add_instant(global_object, instant->nanoseconds(), duration.hours, duration.minutes, duration.seconds, duration.milliseconds, duration.microseconds, duration.nanoseconds);
|
||||
auto* ns = TRY_OR_DISCARD(add_instant(global_object, instant->nanoseconds(), duration.hours, duration.minutes, duration.seconds, duration.milliseconds, duration.microseconds, duration.nanoseconds));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
// 5. Return ! CreateTemporalInstant(ns).
|
||||
return create_temporal_instant(global_object, *ns);
|
||||
return create_temporal_instant(global_object, *ns).release_value();
|
||||
}
|
||||
|
||||
// 8.3.8 Temporal.Instant.prototype.subtract ( temporalDurationLike ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.subtract
|
||||
|
@ -163,12 +163,10 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::subtract)
|
|||
auto duration = TRY_OR_DISCARD(to_limited_temporal_duration(global_object, temporal_duration_like, { "years"sv, "months"sv, "weeks"sv, "days"sv }));
|
||||
|
||||
// 4. Let ns be ? AddInstant(instant.[[Nanoseconds]], −duration.[[Hours]], −duration.[[Minutes]], −duration.[[Seconds]], −duration.[[Milliseconds]], −duration.[[Microseconds]], −duration.[[Nanoseconds]]).
|
||||
auto* ns = add_instant(global_object, instant->nanoseconds(), -duration.hours, -duration.minutes, -duration.seconds, -duration.milliseconds, -duration.microseconds, -duration.nanoseconds);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* ns = TRY_OR_DISCARD(add_instant(global_object, instant->nanoseconds(), -duration.hours, -duration.minutes, -duration.seconds, -duration.milliseconds, -duration.microseconds, -duration.nanoseconds));
|
||||
|
||||
// 5. Return ! CreateTemporalInstant(ns).
|
||||
return create_temporal_instant(global_object, *ns);
|
||||
return create_temporal_instant(global_object, *ns).release_value();
|
||||
}
|
||||
|
||||
// 8.3.9 Temporal.Instant.prototype.until ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.until
|
||||
|
@ -181,9 +179,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::until)
|
|||
return {};
|
||||
|
||||
// 3. Set other to ? ToTemporalInstant(other).
|
||||
auto* other = to_temporal_instant(global_object, vm.argument(0));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* other = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0)));
|
||||
|
||||
// 4. Set options to ? GetOptionsObject(options).
|
||||
auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(1)));
|
||||
|
@ -229,9 +225,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::since)
|
|||
return {};
|
||||
|
||||
// 3. Set other to ? ToTemporalInstant(other).
|
||||
auto* other = to_temporal_instant(global_object, vm.argument(0));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* other = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0)));
|
||||
|
||||
// 4. Set options to ? GetOptionsObject(options).
|
||||
auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(1)));
|
||||
|
@ -343,7 +337,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::round)
|
|||
return {};
|
||||
|
||||
// 16. Return ! CreateTemporalInstant(roundedNs).
|
||||
return create_temporal_instant(global_object, *rounded_ns);
|
||||
return create_temporal_instant(global_object, *rounded_ns).release_value();
|
||||
}
|
||||
|
||||
// 8.3.12 Temporal.Instant.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.equals
|
||||
|
@ -356,9 +350,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::equals)
|
|||
return {};
|
||||
|
||||
// 3. Set other to ? ToTemporalInstant(other).
|
||||
auto other = to_temporal_instant(global_object, vm.argument(0));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto other = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0)));
|
||||
|
||||
// 4. If instant.[[Nanoseconds]] ≠ other.[[Nanoseconds]], return false.
|
||||
if (instant->nanoseconds().big_integer() != other->nanoseconds().big_integer())
|
||||
|
@ -403,14 +395,10 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_string)
|
|||
return {};
|
||||
|
||||
// 9. Let roundedInstant be ! CreateTemporalInstant(roundedNs).
|
||||
auto* rounded_instant = create_temporal_instant(global_object, *rounded_ns);
|
||||
auto* rounded_instant = create_temporal_instant(global_object, *rounded_ns).release_value();
|
||||
|
||||
// 10. Return ? TemporalInstantToString(roundedInstant, timeZone, precision.[[Precision]]).
|
||||
auto string = temporal_instant_to_string(global_object, *rounded_instant, time_zone, precision.precision);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
return js_string(vm, *string);
|
||||
return js_string(vm, TRY_OR_DISCARD(temporal_instant_to_string(global_object, *rounded_instant, time_zone, precision.precision)));
|
||||
}
|
||||
|
||||
// 8.3.14 Temporal.Instant.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.tolocalestring
|
||||
|
@ -424,11 +412,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_locale_string)
|
|||
return {};
|
||||
|
||||
// 3. Return ? TemporalInstantToString(instant, undefined, "auto").
|
||||
auto string = temporal_instant_to_string(global_object, *instant, js_undefined(), "auto"sv);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
return js_string(vm, *string);
|
||||
return js_string(vm, TRY_OR_DISCARD(temporal_instant_to_string(global_object, *instant, js_undefined(), "auto"sv)));
|
||||
}
|
||||
|
||||
// 8.3.15 Temporal.Instant.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.tojson
|
||||
|
@ -441,11 +425,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_json)
|
|||
return {};
|
||||
|
||||
// 3. Return ? TemporalInstantToString(instant, undefined, "auto").
|
||||
auto string = temporal_instant_to_string(global_object, *instant, js_undefined(), "auto"sv);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
return js_string(vm, *string);
|
||||
return js_string(vm, TRY_OR_DISCARD(temporal_instant_to_string(global_object, *instant, js_undefined(), "auto"sv)));
|
||||
}
|
||||
|
||||
// 8.3.16 Temporal.Instant.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.valueof
|
||||
|
|
|
@ -192,7 +192,7 @@ Instant* system_instant(GlobalObject& global_object)
|
|||
auto* ns = system_utc_epoch_nanoseconds(global_object);
|
||||
|
||||
// 2. Return ! CreateTemporalInstant(ns).
|
||||
return create_temporal_instant(global_object, *ns);
|
||||
return create_temporal_instant(global_object, *ns).release_value();
|
||||
}
|
||||
|
||||
// 2.3.4 SystemDateTime ( temporalTimeZoneLike, calendarLike ), https://tc39.es/proposal-temporal/#sec-temporal-systemdatetime
|
||||
|
|
|
@ -95,7 +95,7 @@ PlainDate* to_temporal_date(GlobalObject& global_object, Value item, Object* opt
|
|||
auto& zoned_date_time = static_cast<ZonedDateTime&>(item_object);
|
||||
|
||||
// i. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time.nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time.nanoseconds()).release_value();
|
||||
|
||||
// ii. Let plainDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(item.[[TimeZone]], instant, item.[[Calendar]]).
|
||||
auto* plain_date_time = TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &zoned_date_time.time_zone(), *instant, zoned_date_time.calendar()));
|
||||
|
|
|
@ -154,7 +154,7 @@ PlainDateTime* to_temporal_date_time(GlobalObject& global_object, Value item, Ob
|
|||
auto& zoned_date_time = static_cast<ZonedDateTime&>(item_object);
|
||||
|
||||
// i. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time.nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time.nanoseconds()).release_value();
|
||||
|
||||
// ii. Return ? BuiltinTimeZoneGetPlainDateTimeFor(item.[[TimeZone]], instant, item.[[Calendar]]).
|
||||
return TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &zoned_date_time.time_zone(), *instant, zoned_date_time.calendar()));
|
||||
|
|
|
@ -66,7 +66,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(GlobalObject& global_object, Valu
|
|||
if (is<ZonedDateTime>(item_object)) {
|
||||
auto& zoned_date_time = static_cast<ZonedDateTime&>(item_object);
|
||||
// i. Let instant be ! CreateTemporalInstant(item.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time.nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time.nanoseconds()).release_value();
|
||||
// ii. Set plainDateTime to ? BuiltinTimeZoneGetPlainDateTimeFor(item.[[TimeZone]], instant, item.[[Calendar]]).
|
||||
auto* plain_date_time = TRY(builtin_time_zone_get_plain_date_time_for(global_object, &zoned_date_time.time_zone(), *instant, zoned_date_time.calendar()));
|
||||
// iii. Return ! CreateTemporalTime(plainDateTime.[[ISOHour]], plainDateTime.[[ISOMinute]], plainDateTime.[[ISOSecond]], plainDateTime.[[ISOMillisecond]], plainDateTime.[[ISOMicrosecond]], plainDateTime.[[ISONanosecond]]).
|
||||
|
|
|
@ -58,9 +58,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_nanoseconds_for)
|
|||
return {};
|
||||
|
||||
// 3. Set instant to ? ToTemporalInstant(instant).
|
||||
auto* instant = to_temporal_instant(global_object, vm.argument(0));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* instant = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0)));
|
||||
|
||||
// 4. If timeZone.[[OffsetNanoseconds]] is not undefined, return timeZone.[[OffsetNanoseconds]].
|
||||
if (time_zone->offset_nanoseconds().has_value())
|
||||
|
@ -80,9 +78,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_string_for)
|
|||
return {};
|
||||
|
||||
// 3. Set instant to ? ToTemporalInstant(instant).
|
||||
auto* instant = to_temporal_instant(global_object, vm.argument(0));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* instant = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0)));
|
||||
|
||||
// 4. Return ? BuiltinTimeZoneGetOffsetStringFor(timeZone, instant).
|
||||
auto offset_string = TRY_OR_DISCARD(builtin_time_zone_get_offset_string_for(global_object, time_zone, *instant));
|
||||
|
@ -96,9 +92,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_plain_date_time_for)
|
|||
auto time_zone = vm.this_value(global_object);
|
||||
|
||||
// 2. Set instant to ? ToTemporalInstant(instant).
|
||||
auto* instant = to_temporal_instant(global_object, vm.argument(0));
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* instant = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0)));
|
||||
|
||||
// 3. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
|
||||
auto* calendar = TRY_OR_DISCARD(to_temporal_calendar_with_iso_default(global_object, vm.argument(1)));
|
||||
|
|
|
@ -112,7 +112,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::year_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -137,7 +137,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::month_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -162,7 +162,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::month_code_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -187,7 +187,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::day_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -212,7 +212,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::hour_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -237,7 +237,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::minute_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -262,7 +262,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::second_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -287,7 +287,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::millisecond_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -312,7 +312,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::microsecond_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -337,7 +337,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::nanosecond_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -432,7 +432,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::day_of_week_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -457,7 +457,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::day_of_year_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -482,7 +482,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::week_of_year_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -507,7 +507,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_week_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -532,7 +532,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_month_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -557,7 +557,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_year_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -582,7 +582,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::months_in_year_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -607,7 +607,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::in_leap_year_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -632,7 +632,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_nanoseconds_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Return 𝔽(? GetOffsetNanosecondsFor(timeZone, instant)).
|
||||
return Value(TRY_OR_DISCARD(get_offset_nanoseconds_for(global_object, &time_zone, *instant)));
|
||||
|
@ -648,7 +648,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_getter)
|
|||
return {};
|
||||
|
||||
// 3. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 4. Return ? BuiltinTimeZoneGetOffsetStringFor(zonedDateTime.[[TimeZone]], instant).
|
||||
auto offset_string = TRY_OR_DISCARD(builtin_time_zone_get_offset_string_for(global_object, &zoned_date_time->time_zone(), *instant));
|
||||
|
@ -668,7 +668,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::era_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -693,7 +693,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::era_year_getter)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -723,7 +723,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_instant)
|
|||
return {};
|
||||
|
||||
// 3. Return ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
return create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
return create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
}
|
||||
|
||||
// 6.3.47 Temporal.ZonedDateTime.prototype.toPlainDate ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplaindate
|
||||
|
@ -739,7 +739,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_date)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -764,7 +764,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_time)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -789,7 +789,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_date_time)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Return ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, zonedDateTime.[[Calendar]]).
|
||||
return TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, zoned_date_time->calendar()));
|
||||
|
@ -808,7 +808,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_year_month)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -839,7 +839,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_month_day)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 5. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
@ -875,7 +875,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields)
|
|||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
||||
// 5. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
||||
auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds()).release_value();
|
||||
|
||||
// 6. Let calendar be zonedDateTime.[[Calendar]].
|
||||
auto& calendar = zoned_date_time->calendar();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue