|
@@ -27,36 +27,36 @@ void TimeZonePrototype::initialize(GlobalObject& global_object)
|
|
|
auto& vm = this->vm();
|
|
|
|
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
|
- define_old_native_accessor(vm.names.id, id_getter, {}, Attribute::Configurable);
|
|
|
- define_old_native_function(vm.names.getOffsetNanosecondsFor, get_offset_nanoseconds_for, 1, attr);
|
|
|
- define_old_native_function(vm.names.getOffsetStringFor, get_offset_string_for, 1, attr);
|
|
|
- define_old_native_function(vm.names.getPlainDateTimeFor, get_plain_date_time_for, 1, attr);
|
|
|
- define_old_native_function(vm.names.toString, to_string, 0, attr);
|
|
|
- define_old_native_function(vm.names.toJSON, to_json, 0, attr);
|
|
|
+ define_native_accessor(vm.names.id, id_getter, {}, Attribute::Configurable);
|
|
|
+ define_native_function(vm.names.getOffsetNanosecondsFor, get_offset_nanoseconds_for, 1, attr);
|
|
|
+ define_native_function(vm.names.getOffsetStringFor, get_offset_string_for, 1, attr);
|
|
|
+ define_native_function(vm.names.getPlainDateTimeFor, get_plain_date_time_for, 1, attr);
|
|
|
+ define_native_function(vm.names.toString, to_string, 0, attr);
|
|
|
+ define_native_function(vm.names.toJSON, to_json, 0, attr);
|
|
|
|
|
|
// 11.4.2 Temporal.TimeZone.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype-@@tostringtag
|
|
|
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.TimeZone"), Attribute::Configurable);
|
|
|
}
|
|
|
|
|
|
// 11.4.3 get Temporal.TimeZone.prototype.id, https://tc39.es/proposal-temporal/#sec-get-temporal.timezone.prototype.id
|
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(TimeZonePrototype::id_getter)
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::id_getter)
|
|
|
{
|
|
|
// 1. Let timeZone be the this value.
|
|
|
auto time_zone = vm.this_value(global_object);
|
|
|
|
|
|
// 2. Return ? ToString(timeZone).
|
|
|
- return js_string(vm, TRY_OR_DISCARD(time_zone.to_string(global_object)));
|
|
|
+ return js_string(vm, TRY(time_zone.to_string(global_object)));
|
|
|
}
|
|
|
|
|
|
// 11.4.4 Temporal.TimeZone.prototype.getOffsetNanosecondsFor ( instant ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getoffsetnanosecondsfor
|
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(TimeZonePrototype::get_offset_nanoseconds_for)
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_nanoseconds_for)
|
|
|
{
|
|
|
// 1. Let timeZone be the this value.
|
|
|
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
|
|
- auto* time_zone = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
+ auto* time_zone = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Set instant to ? ToTemporalInstant(instant).
|
|
|
- auto* instant = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0)));
|
|
|
+ auto* instant = TRY(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())
|
|
@@ -67,55 +67,55 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TimeZonePrototype::get_offset_nanoseconds_for)
|
|
|
}
|
|
|
|
|
|
// 11.4.5 Temporal.TimeZone.prototype.getOffsetStringFor ( instant ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getoffsetstringfor
|
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(TimeZonePrototype::get_offset_string_for)
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_string_for)
|
|
|
{
|
|
|
// 1. Let timeZone be the this value.
|
|
|
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
|
|
- auto* time_zone = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
+ auto* time_zone = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Set instant to ? ToTemporalInstant(instant).
|
|
|
- auto* instant = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0)));
|
|
|
+ auto* instant = TRY(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));
|
|
|
+ auto offset_string = TRY(builtin_time_zone_get_offset_string_for(global_object, time_zone, *instant));
|
|
|
return js_string(vm, move(offset_string));
|
|
|
}
|
|
|
|
|
|
// 11.4.6 Temporal.TimeZone.prototype.getPlainDateTimeFor ( instant [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getplaindatetimefor
|
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(TimeZonePrototype::get_plain_date_time_for)
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_plain_date_time_for)
|
|
|
{
|
|
|
// 1. Let timeZone be the this value.
|
|
|
auto time_zone = vm.this_value(global_object);
|
|
|
|
|
|
// 2. Set instant to ? ToTemporalInstant(instant).
|
|
|
- auto* instant = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0)));
|
|
|
+ auto* instant = TRY(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)));
|
|
|
+ auto* calendar = TRY(to_temporal_calendar_with_iso_default(global_object, vm.argument(1)));
|
|
|
|
|
|
// 4. Return ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
|
|
|
- return TRY_OR_DISCARD(builtin_time_zone_get_plain_date_time_for(global_object, time_zone, *instant, *calendar));
|
|
|
+ return TRY(builtin_time_zone_get_plain_date_time_for(global_object, time_zone, *instant, *calendar));
|
|
|
}
|
|
|
|
|
|
// 11.4.11 Temporal.TimeZone.prototype.toString ( ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.tostring
|
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(TimeZonePrototype::to_string)
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_string)
|
|
|
{
|
|
|
// 1. Let timeZone be the this value.
|
|
|
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
|
|
- auto* time_zone = TRY_OR_DISCARD(typed_this_object(global_object));
|
|
|
+ auto* time_zone = TRY(typed_this_object(global_object));
|
|
|
|
|
|
// 3. Return timeZone.[[Identifier]].
|
|
|
return js_string(vm, time_zone->identifier());
|
|
|
}
|
|
|
|
|
|
// 11.4.12 Temporal.TimeZone.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.tojson
|
|
|
-JS_DEFINE_OLD_NATIVE_FUNCTION(TimeZonePrototype::to_json)
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_json)
|
|
|
{
|
|
|
// 1. Let timeZone be the this value.
|
|
|
auto time_zone = vm.this_value(global_object);
|
|
|
|
|
|
// 2. Return ? ToString(timeZone).
|
|
|
- return js_string(vm, TRY_OR_DISCARD(time_zone.to_string(global_object)));
|
|
|
+ return js_string(vm, TRY(time_zone.to_string(global_object)));
|
|
|
}
|
|
|
|
|
|
}
|