|
@@ -53,6 +53,7 @@ void PlainDatePrototype::initialize(GlobalObject& global_object)
|
|
|
define_native_function(vm.names.toPlainYearMonth, to_plain_year_month, 0, attr);
|
|
|
define_native_function(vm.names.toPlainMonthDay, to_plain_month_day, 0, attr);
|
|
|
define_native_function(vm.names.getISOFields, get_iso_fields, 0, attr);
|
|
|
+ define_native_function(vm.names.add, add, 1, attr);
|
|
|
define_native_function(vm.names.withCalendar, with_calendar, 1, attr);
|
|
|
define_native_function(vm.names.equals, equals, 1, attr);
|
|
|
define_native_function(vm.names.toPlainDateTime, to_plain_date_time, 0, attr);
|
|
@@ -335,6 +336,23 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::get_iso_fields)
|
|
|
return fields;
|
|
|
}
|
|
|
|
|
|
+// 3.3.19 Temporal.PlainDate.prototype.add ( temporalDurationLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.add
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::add)
|
|
|
+{
|
|
|
+ // 1. Let temporalDate be the this value.
|
|
|
+ // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
|
|
+ auto* temporal_date = TRY(typed_this_object(global_object));
|
|
|
+
|
|
|
+ // 3. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
|
|
+ auto* duration = TRY(to_temporal_duration(global_object, vm.argument(0)));
|
|
|
+
|
|
|
+ // 4. Set options to ? GetOptionsObject(options).
|
|
|
+ auto* options = TRY(get_options_object(global_object, vm.argument(1)));
|
|
|
+
|
|
|
+ // 5. Return ? CalendarDateAdd(temporalDate.[[Calendar]], temporalDate, duration, options).
|
|
|
+ return TRY(calendar_date_add(global_object, temporal_date->calendar(), *temporal_date, *duration, options));
|
|
|
+}
|
|
|
+
|
|
|
// 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)
|
|
|
{
|