|
@@ -29,151 +29,148 @@ void PlainTimePrototype::initialize(GlobalObject& global_object)
|
|
// 4.3.2 Temporal.PlainTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype-@@tostringtag
|
|
// 4.3.2 Temporal.PlainTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype-@@tostringtag
|
|
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainTime"), Attribute::Configurable);
|
|
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainTime"), Attribute::Configurable);
|
|
|
|
|
|
- define_old_native_accessor(vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
|
|
|
|
- define_old_native_accessor(vm.names.hour, hour_getter, {}, Attribute::Configurable);
|
|
|
|
- define_old_native_accessor(vm.names.minute, minute_getter, {}, Attribute::Configurable);
|
|
|
|
- define_old_native_accessor(vm.names.second, second_getter, {}, Attribute::Configurable);
|
|
|
|
- define_old_native_accessor(vm.names.millisecond, millisecond_getter, {}, Attribute::Configurable);
|
|
|
|
- define_old_native_accessor(vm.names.microsecond, microsecond_getter, {}, Attribute::Configurable);
|
|
|
|
- define_old_native_accessor(vm.names.nanosecond, nanosecond_getter, {}, Attribute::Configurable);
|
|
|
|
|
|
+ define_native_accessor(vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
|
|
|
|
+ define_native_accessor(vm.names.hour, hour_getter, {}, Attribute::Configurable);
|
|
|
|
+ define_native_accessor(vm.names.minute, minute_getter, {}, Attribute::Configurable);
|
|
|
|
+ define_native_accessor(vm.names.second, second_getter, {}, Attribute::Configurable);
|
|
|
|
+ define_native_accessor(vm.names.millisecond, millisecond_getter, {}, Attribute::Configurable);
|
|
|
|
+ define_native_accessor(vm.names.microsecond, microsecond_getter, {}, Attribute::Configurable);
|
|
|
|
+ define_native_accessor(vm.names.nanosecond, nanosecond_getter, {}, Attribute::Configurable);
|
|
|
|
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
- define_old_native_function(vm.names.with, with, 1, attr);
|
|
|
|
- define_old_native_function(vm.names.equals, equals, 1, attr);
|
|
|
|
- define_old_native_function(vm.names.toPlainDateTime, to_plain_date_time, 1, attr);
|
|
|
|
- define_old_native_function(vm.names.getISOFields, get_iso_fields, 0, attr);
|
|
|
|
- define_old_native_function(vm.names.toString, to_string, 0, attr);
|
|
|
|
- define_old_native_function(vm.names.toLocaleString, to_locale_string, 0, attr);
|
|
|
|
- define_old_native_function(vm.names.toJSON, to_json, 0, attr);
|
|
|
|
- define_old_native_function(vm.names.valueOf, value_of, 0, attr);
|
|
|
|
|
|
+ define_native_function(vm.names.with, with, 1, attr);
|
|
|
|
+ define_native_function(vm.names.equals, equals, 1, attr);
|
|
|
|
+ define_native_function(vm.names.toPlainDateTime, to_plain_date_time, 1, attr);
|
|
|
|
+ define_native_function(vm.names.getISOFields, get_iso_fields, 0, attr);
|
|
|
|
+ define_native_function(vm.names.toString, to_string, 0, attr);
|
|
|
|
+ define_native_function(vm.names.toLocaleString, to_locale_string, 0, attr);
|
|
|
|
+ define_native_function(vm.names.toJSON, to_json, 0, attr);
|
|
|
|
+ define_native_function(vm.names.valueOf, value_of, 0, attr);
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.3 get Temporal.PlainTime.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.calendar
|
|
// 4.3.3 get Temporal.PlainTime.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.calendar
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::calendar_getter)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::calendar_getter)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Return temporalTime.[[Calendar]].
|
|
// 3. Return temporalTime.[[Calendar]].
|
|
return Value(&temporal_time->calendar());
|
|
return Value(&temporal_time->calendar());
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.4 get Temporal.PlainTime.prototype.hour, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.hour
|
|
// 4.3.4 get Temporal.PlainTime.prototype.hour, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.hour
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::hour_getter)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::hour_getter)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Return 𝔽(temporalTime.[[ISOHour]]).
|
|
// 3. Return 𝔽(temporalTime.[[ISOHour]]).
|
|
return Value(temporal_time->iso_hour());
|
|
return Value(temporal_time->iso_hour());
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.5 get Temporal.PlainTime.prototype.minute, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.minute
|
|
// 4.3.5 get Temporal.PlainTime.prototype.minute, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.minute
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::minute_getter)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::minute_getter)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Return 𝔽(temporalTime.[[ISOMinute]]).
|
|
// 3. Return 𝔽(temporalTime.[[ISOMinute]]).
|
|
return Value(temporal_time->iso_minute());
|
|
return Value(temporal_time->iso_minute());
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.6 get Temporal.PlainTime.prototype.second, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.second
|
|
// 4.3.6 get Temporal.PlainTime.prototype.second, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.second
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::second_getter)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::second_getter)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Return 𝔽(temporalTime.[[ISOSecond]]).
|
|
// 3. Return 𝔽(temporalTime.[[ISOSecond]]).
|
|
return Value(temporal_time->iso_second());
|
|
return Value(temporal_time->iso_second());
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.7 get Temporal.PlainTime.prototype.millisecond, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.millisecond
|
|
// 4.3.7 get Temporal.PlainTime.prototype.millisecond, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.millisecond
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::millisecond_getter)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::millisecond_getter)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Return 𝔽(temporalTime.[[ISOMillisecond]]).
|
|
// 3. Return 𝔽(temporalTime.[[ISOMillisecond]]).
|
|
return Value(temporal_time->iso_millisecond());
|
|
return Value(temporal_time->iso_millisecond());
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.8 get Temporal.PlainTime.prototype.microsecond, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.microsecond
|
|
// 4.3.8 get Temporal.PlainTime.prototype.microsecond, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.microsecond
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::microsecond_getter)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::microsecond_getter)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Return 𝔽(temporalTime.[[ISOMicrosecond]]).
|
|
// 3. Return 𝔽(temporalTime.[[ISOMicrosecond]]).
|
|
return Value(temporal_time->iso_microsecond());
|
|
return Value(temporal_time->iso_microsecond());
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.9 get Temporal.PlainTime.prototype.nanosecond, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.nanosecond
|
|
// 4.3.9 get Temporal.PlainTime.prototype.nanosecond, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.nanosecond
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::nanosecond_getter)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::nanosecond_getter)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Return 𝔽(temporalTime.[[ISONanosecond]]).
|
|
// 3. Return 𝔽(temporalTime.[[ISONanosecond]]).
|
|
return Value(temporal_time->iso_nanosecond());
|
|
return Value(temporal_time->iso_nanosecond());
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.12 Temporal.PlainTime.prototype.with ( temporalTimeLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.with
|
|
// 4.3.12 Temporal.PlainTime.prototype.with ( temporalTimeLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.with
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::with)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::with)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
auto temporal_time_like_argument = vm.argument(0);
|
|
auto temporal_time_like_argument = vm.argument(0);
|
|
|
|
|
|
// 3. If Type(temporalTimeLike) is not Object, then
|
|
// 3. If Type(temporalTimeLike) is not Object, then
|
|
if (!temporal_time_like_argument.is_object()) {
|
|
if (!temporal_time_like_argument.is_object()) {
|
|
// a. Throw a TypeError exception.
|
|
// a. Throw a TypeError exception.
|
|
- vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, temporal_time_like_argument.to_string_without_side_effects());
|
|
|
|
- return {};
|
|
|
|
|
|
+ return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, temporal_time_like_argument.to_string_without_side_effects());
|
|
}
|
|
}
|
|
|
|
|
|
auto& temporal_time_like = temporal_time_like_argument.as_object();
|
|
auto& temporal_time_like = temporal_time_like_argument.as_object();
|
|
|
|
|
|
// 4. Perform ? RejectTemporalCalendarType(temporalTimeLike).
|
|
// 4. Perform ? RejectTemporalCalendarType(temporalTimeLike).
|
|
- TRY_OR_DISCARD(reject_temporal_calendar_type(global_object, temporal_time_like));
|
|
|
|
|
|
+ TRY(reject_temporal_calendar_type(global_object, temporal_time_like));
|
|
|
|
|
|
// 5. Let calendarProperty be ? Get(temporalTimeLike, "calendar").
|
|
// 5. Let calendarProperty be ? Get(temporalTimeLike, "calendar").
|
|
- auto calendar_property = TRY_OR_DISCARD(temporal_time_like.get(vm.names.calendar));
|
|
|
|
|
|
+ auto calendar_property = TRY(temporal_time_like.get(vm.names.calendar));
|
|
|
|
|
|
// 6. If calendarProperty is not undefined, then
|
|
// 6. If calendarProperty is not undefined, then
|
|
if (!calendar_property.is_undefined()) {
|
|
if (!calendar_property.is_undefined()) {
|
|
// a. Throw a TypeError exception.
|
|
// a. Throw a TypeError exception.
|
|
- vm.throw_exception<TypeError>(global_object, ErrorType::TemporalPlainTimeWithArgumentMustNotHave, "calendar");
|
|
|
|
- return {};
|
|
|
|
|
|
+ return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalPlainTimeWithArgumentMustNotHave, "calendar");
|
|
}
|
|
}
|
|
|
|
|
|
// 7. Let timeZoneProperty be ? Get(temporalTimeLike, "timeZone").
|
|
// 7. Let timeZoneProperty be ? Get(temporalTimeLike, "timeZone").
|
|
- auto time_zone_property = TRY_OR_DISCARD(temporal_time_like.get(vm.names.timeZone));
|
|
|
|
|
|
+ auto time_zone_property = TRY(temporal_time_like.get(vm.names.timeZone));
|
|
|
|
|
|
// 8. If timeZoneProperty is not undefined, then
|
|
// 8. If timeZoneProperty is not undefined, then
|
|
if (!time_zone_property.is_undefined()) {
|
|
if (!time_zone_property.is_undefined()) {
|
|
// a. Throw a TypeError exception.
|
|
// a. Throw a TypeError exception.
|
|
- vm.throw_exception<TypeError>(global_object, ErrorType::TemporalPlainTimeWithArgumentMustNotHave, "timeZone");
|
|
|
|
- return {};
|
|
|
|
|
|
+ return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalPlainTimeWithArgumentMustNotHave, "timeZone");
|
|
}
|
|
}
|
|
|
|
|
|
// 9. Let partialTime be ? ToPartialTime(temporalTimeLike).
|
|
// 9. Let partialTime be ? ToPartialTime(temporalTimeLike).
|
|
- auto partial_time = TRY_OR_DISCARD(to_partial_time(global_object, temporal_time_like));
|
|
|
|
|
|
+ auto partial_time = TRY(to_partial_time(global_object, temporal_time_like));
|
|
|
|
|
|
// 10. Set options to ? GetOptionsObject(options).
|
|
// 10. Set options to ? GetOptionsObject(options).
|
|
- auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(1)));
|
|
|
|
|
|
+ auto* options = TRY(get_options_object(global_object, vm.argument(1)));
|
|
|
|
|
|
// 11. Let overflow be ? ToTemporalOverflow(options).
|
|
// 11. Let overflow be ? ToTemporalOverflow(options).
|
|
- auto overflow = TRY_OR_DISCARD(to_temporal_overflow(global_object, *options));
|
|
|
|
|
|
+ auto overflow = TRY(to_temporal_overflow(global_object, *options));
|
|
|
|
|
|
// 12. If partialTime.[[Hour]] is not undefined, then
|
|
// 12. If partialTime.[[Hour]] is not undefined, then
|
|
// a. Let hour be partialTime.[[Hour]].
|
|
// a. Let hour be partialTime.[[Hour]].
|
|
@@ -212,21 +209,21 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::with)
|
|
auto nanosecond = partial_time.nanosecond.value_or(temporal_time->iso_nanosecond());
|
|
auto nanosecond = partial_time.nanosecond.value_or(temporal_time->iso_nanosecond());
|
|
|
|
|
|
// 24. Let result be ? RegulateTime(hour, minute, second, millisecond, microsecond, nanosecond, overflow).
|
|
// 24. Let result be ? RegulateTime(hour, minute, second, millisecond, microsecond, nanosecond, overflow).
|
|
- auto result = TRY_OR_DISCARD(regulate_time(global_object, hour, minute, second, millisecond, microsecond, nanosecond, overflow));
|
|
|
|
|
|
+ auto result = TRY(regulate_time(global_object, hour, minute, second, millisecond, microsecond, nanosecond, overflow));
|
|
|
|
|
|
// 25. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).
|
|
// 25. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]).
|
|
- return TRY_OR_DISCARD(create_temporal_time(global_object, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond));
|
|
|
|
|
|
+ return TRY(create_temporal_time(global_object, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond));
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.16 Temporal.PlainTime.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.equals
|
|
// 4.3.16 Temporal.PlainTime.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.equals
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::equals)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::equals)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Set other to ? ToTemporalTime(other).
|
|
// 3. Set other to ? ToTemporalTime(other).
|
|
- auto* other = TRY_OR_DISCARD(to_temporal_time(global_object, vm.argument(0)));
|
|
|
|
|
|
+ auto* other = TRY(to_temporal_time(global_object, vm.argument(0)));
|
|
|
|
|
|
// 4. If temporalTime.[[ISOHour]] ≠ other.[[ISOHour]], return false.
|
|
// 4. If temporalTime.[[ISOHour]] ≠ other.[[ISOHour]], return false.
|
|
if (temporal_time->iso_hour() != other->iso_hour())
|
|
if (temporal_time->iso_hour() != other->iso_hour())
|
|
@@ -257,25 +254,25 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::equals)
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.17 Temporal.PlainTime.prototype.toPlainDateTime ( temporalDate ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.toplaindatetime
|
|
// 4.3.17 Temporal.PlainTime.prototype.toPlainDateTime ( temporalDate ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.toplaindatetime
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_plain_date_time)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_plain_date_time)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Set temporalDate to ? ToTemporalDate(temporalDate).
|
|
// 3. Set temporalDate to ? ToTemporalDate(temporalDate).
|
|
- auto* temporal_date = TRY_OR_DISCARD(to_temporal_date(global_object, vm.argument(0)));
|
|
|
|
|
|
+ auto* temporal_date = TRY(to_temporal_date(global_object, vm.argument(0)));
|
|
|
|
|
|
// 4. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]).
|
|
// 4. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]).
|
|
- return TRY_OR_DISCARD(create_temporal_date_time(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), temporal_date->calendar()));
|
|
|
|
|
|
+ return TRY(create_temporal_date_time(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), temporal_date->calendar()));
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.19 Temporal.PlainTime.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.getisofields
|
|
// 4.3.19 Temporal.PlainTime.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.getisofields
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%).
|
|
// 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%).
|
|
auto* fields = Object::create(global_object, global_object.object_prototype());
|
|
auto* fields = Object::create(global_object, global_object.object_prototype());
|
|
@@ -306,20 +303,20 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields)
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.20 Temporal.PlainTime.prototype.toString ( [ options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tostring
|
|
// 4.3.20 Temporal.PlainTime.prototype.toString ( [ options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tostring
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_string)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_string)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Set options to ? GetOptionsObject(options).
|
|
// 3. Set options to ? GetOptionsObject(options).
|
|
- auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(0)));
|
|
|
|
|
|
+ auto* options = TRY(get_options_object(global_object, vm.argument(0)));
|
|
|
|
|
|
// 4. Let precision be ? ToSecondsStringPrecision(options).
|
|
// 4. Let precision be ? ToSecondsStringPrecision(options).
|
|
- auto precision = TRY_OR_DISCARD(to_seconds_string_precision(global_object, *options));
|
|
|
|
|
|
+ auto precision = TRY(to_seconds_string_precision(global_object, *options));
|
|
|
|
|
|
// 5. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
|
|
// 5. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc").
|
|
- auto rounding_mode = TRY_OR_DISCARD(to_temporal_rounding_mode(global_object, *options, "trunc"sv));
|
|
|
|
|
|
+ auto rounding_mode = TRY(to_temporal_rounding_mode(global_object, *options, "trunc"sv));
|
|
|
|
|
|
// 6. Let roundResult be ! RoundTime(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], precision.[[Increment]], precision.[[Unit]], roundingMode).
|
|
// 6. Let roundResult be ! RoundTime(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], precision.[[Increment]], precision.[[Unit]], roundingMode).
|
|
auto round_result = round_time(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), precision.increment, precision.unit, rounding_mode);
|
|
auto round_result = round_time(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), precision.increment, precision.unit, rounding_mode);
|
|
@@ -330,11 +327,11 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_string)
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.21 Temporal.PlainTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tolocalestring
|
|
// 4.3.21 Temporal.PlainTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tolocalestring
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_locale_string)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_locale_string)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto").
|
|
// 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto").
|
|
auto string = temporal_time_to_string(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), "auto"sv);
|
|
auto string = temporal_time_to_string(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), "auto"sv);
|
|
@@ -342,11 +339,11 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_locale_string)
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.22 Temporal.PlainTime.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tojson
|
|
// 4.3.22 Temporal.PlainTime.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tojson
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_json)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_json)
|
|
{
|
|
{
|
|
// 1. Let temporalTime be the this value.
|
|
// 1. Let temporalTime be the this value.
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
- auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
|
|
|
+ auto* temporal_time = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto").
|
|
// 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto").
|
|
auto string = temporal_time_to_string(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), "auto"sv);
|
|
auto string = temporal_time_to_string(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), "auto"sv);
|
|
@@ -354,11 +351,10 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_json)
|
|
}
|
|
}
|
|
|
|
|
|
// 4.3.23 Temporal.PlainTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.valueof
|
|
// 4.3.23 Temporal.PlainTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.valueof
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::value_of)
|
|
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::value_of)
|
|
{
|
|
{
|
|
// 1. Throw a TypeError exception.
|
|
// 1. Throw a TypeError exception.
|
|
- vm.throw_exception<TypeError>(global_object, ErrorType::Convert, "Temporal.PlainTime", "a primitive value");
|
|
|
|
- return {};
|
|
|
|
|
|
+ return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.PlainTime", "a primitive value");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|