|
@@ -27,6 +27,7 @@ void PlainDatePrototype::initialize(GlobalObject& global_object)
|
|
|
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), "Temporal.PlainDate"), Attribute::Configurable);
|
|
|
|
|
|
define_native_accessor(vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
|
|
|
+ define_native_accessor(vm.names.year, year_getter, {}, Attribute::Configurable);
|
|
|
|
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
|
define_native_function(vm.names.withCalendar, with_calendar, 1, attr);
|
|
@@ -60,6 +61,22 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::calendar_getter)
|
|
|
return Value(&temporal_date->calendar());
|
|
|
}
|
|
|
|
|
|
+// 3.3.4 get Temporal.PlainDate.prototype.year, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.year
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::year_getter)
|
|
|
+{
|
|
|
+ // 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 temporalDate.[[Calendar]].
|
|
|
+ auto& calendar = temporal_date->calendar();
|
|
|
+
|
|
|
+ // 4. Return ? CalendarYear(calendar, temporalDate).
|
|
|
+ return Value(calendar_year(global_object, calendar, *temporal_date));
|
|
|
+}
|
|
|
+
|
|
|
// 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)
|
|
|
{
|