|
@@ -48,6 +48,7 @@ void PlainDateTimePrototype::initialize(GlobalObject& global_object)
|
|
define_native_accessor(vm.names.inLeapYear, in_leap_year_getter, {}, Attribute::Configurable);
|
|
define_native_accessor(vm.names.inLeapYear, in_leap_year_getter, {}, Attribute::Configurable);
|
|
|
|
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
|
|
+ define_native_function(vm.names.withCalendar, with_calendar, 1, attr);
|
|
define_native_function(vm.names.valueOf, value_of, 0, attr);
|
|
define_native_function(vm.names.valueOf, value_of, 0, attr);
|
|
define_native_function(vm.names.toPlainDate, to_plain_date, 0, attr);
|
|
define_native_function(vm.names.toPlainDate, to_plain_date, 0, attr);
|
|
define_native_function(vm.names.getISOFields, get_iso_fields, 0, attr);
|
|
define_native_function(vm.names.getISOFields, get_iso_fields, 0, attr);
|
|
@@ -349,6 +350,24 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::in_leap_year_getter)
|
|
return calendar_in_leap_year(global_object, calendar, *date_time);
|
|
return calendar_in_leap_year(global_object, calendar, *date_time);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 5.3.25 Temporal.PlainDateTime.prototype.withCalendar ( calendar ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.withcalendar
|
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_calendar)
|
|
|
|
+{
|
|
|
|
+ // 1. Let temporalDateTime be the this value.
|
|
|
|
+ // 2. Perform ? RequireInternalSlot(temporalDateTime, [[InitializedTemporalDateTime]]).
|
|
|
|
+ auto* date_time = 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 ? CreateTemporalDateTime(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]], calendar).
|
|
|
|
+ return create_temporal_date_time(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), *calendar);
|
|
|
|
+}
|
|
|
|
+
|
|
// 5.3.35 Temporal.PlainDateTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.valueof
|
|
// 5.3.35 Temporal.PlainDateTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.valueof
|
|
JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::value_of)
|
|
JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::value_of)
|
|
{
|
|
{
|