|
@@ -67,6 +67,7 @@ void ZonedDateTimePrototype::initialize(GlobalObject& global_object)
|
|
|
define_native_function(vm.names.toPlainTime, to_plain_time, 0, attr);
|
|
|
define_native_function(vm.names.toPlainDateTime, to_plain_date_time, 0, attr);
|
|
|
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);
|
|
|
}
|
|
|
|
|
@@ -834,6 +835,43 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_year_month)
|
|
|
return year_month_from_fields(global_object, calendar, *fields);
|
|
|
}
|
|
|
|
|
|
+// 6.3.51 Temporal.ZonedDateTime.prototype.toPlainMonthDay ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.toplainmonthday
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_month_day)
|
|
|
+{
|
|
|
+ // 1. Let zonedDateTime be the this value.
|
|
|
+ // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
|
|
+ auto* zoned_date_time = typed_this(global_object);
|
|
|
+ if (vm.exception())
|
|
|
+ return {};
|
|
|
+
|
|
|
+ // 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
|
|
+ auto& time_zone = zoned_date_time->time_zone();
|
|
|
+
|
|
|
+ // 4. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
|
|
+ auto* instant = create_temporal_instant(global_object, zoned_date_time->nanoseconds());
|
|
|
+
|
|
|
+ // 5. Let calendar be zonedDateTime.[[Calendar]].
|
|
|
+ auto& calendar = zoned_date_time->calendar();
|
|
|
+
|
|
|
+ // 6. Let temporalDateTime be ? BuiltinTimeZoneGetPlainDateTimeFor(timeZone, instant, calendar).
|
|
|
+ auto* temporal_date_time = builtin_time_zone_get_plain_date_time_for(global_object, &time_zone, *instant, calendar);
|
|
|
+ if (vm.exception())
|
|
|
+ return {};
|
|
|
+
|
|
|
+ // 7. Let fieldNames be ? CalendarFields(calendar, « "day", "monthCode" »).
|
|
|
+ auto field_names = calendar_fields(global_object, calendar, { "day"sv, "monthCode"sv });
|
|
|
+ if (vm.exception())
|
|
|
+ return {};
|
|
|
+
|
|
|
+ // 8. Let fields be ? PrepareTemporalFields(temporalDateTime, fieldNames, «»).
|
|
|
+ auto* fields = prepare_temporal_fields(global_object, *temporal_date_time, field_names, {});
|
|
|
+ if (vm.exception())
|
|
|
+ return {};
|
|
|
+
|
|
|
+ // 9. Return ? MonthDayFromFields(calendar, fields).
|
|
|
+ return month_day_from_fields(global_object, calendar, *fields);
|
|
|
+}
|
|
|
+
|
|
|
// 6.3.52 Temporal.ZonedDateTime.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.getisofields
|
|
|
JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields)
|
|
|
{
|