|
@@ -29,6 +29,7 @@ void PlainDatePrototype::initialize(GlobalObject& global_object)
|
|
|
define_native_accessor(vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
|
|
|
|
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
|
+ define_native_function(vm.names.withCalendar, with_calendar, 1, attr);
|
|
|
define_native_function(vm.names.equals, equals, 1, attr);
|
|
|
define_native_function(vm.names.valueOf, value_of, 0, attr);
|
|
|
}
|
|
@@ -59,6 +60,24 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::calendar_getter)
|
|
|
return Value(&temporal_date->calendar());
|
|
|
}
|
|
|
|
|
|
+// 3.3.22 Temporal.PlainDate.prototype.withCalendar ( calendar ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.withcalendar
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with_calendar)
|
|
|
+{
|
|
|
+ // 1. Let temporalDate be the this value.
|
|
|
+ // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
|
|
+ auto* temporal_date = typed_this(global_object);
|
|
|
+ if (vm.exception())
|
|
|
+ return {};
|
|
|
+
|
|
|
+ // 3. Let calendar be ? ToTemporalCalendar(calendar).
|
|
|
+ auto calendar = to_temporal_calendar(global_object, vm.argument(0));
|
|
|
+ if (vm.exception())
|
|
|
+ return {};
|
|
|
+
|
|
|
+ // 4. Return ? CreateTemporalDate(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], calendar).
|
|
|
+ return create_temporal_date(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), *calendar);
|
|
|
+}
|
|
|
+
|
|
|
// 3.3.25 Temporal.PlainDate.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.equals
|
|
|
JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::equals)
|
|
|
{
|