|
@@ -6,6 +6,8 @@
|
|
|
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
#include <LibJS/Runtime/Temporal/Calendar.h>
|
|
|
+#include <LibJS/Runtime/Temporal/PlainDate.h>
|
|
|
+#include <LibJS/Runtime/Temporal/PlainDateTime.h>
|
|
|
#include <LibJS/Runtime/Temporal/PlainTime.h>
|
|
|
#include <LibJS/Runtime/Temporal/PlainTimePrototype.h>
|
|
|
|
|
@@ -35,6 +37,7 @@ void PlainTimePrototype::initialize(GlobalObject& global_object)
|
|
|
define_native_accessor(vm.names.nanosecond, nanosecond_getter, {}, Attribute::Configurable);
|
|
|
|
|
|
u8 attr = Attribute::Writable | Attribute::Configurable;
|
|
|
+ define_native_function(vm.names.toPlainDateTime, to_plain_date_time, 1, attr);
|
|
|
define_native_function(vm.names.valueOf, value_of, 0, attr);
|
|
|
}
|
|
|
|
|
@@ -142,6 +145,24 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::nanosecond_getter)
|
|
|
return Value(temporal_time->iso_nanosecond());
|
|
|
}
|
|
|
|
|
|
+// 4.3.17 Temporal.PlainTime.prototype.toPlainDateTime ( temporalDate )
|
|
|
+JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_plain_date_time)
|
|
|
+{
|
|
|
+ // 1. Let temporalTime be the this value.
|
|
|
+ // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
|
|
+ auto* temporal_time = typed_this(global_object);
|
|
|
+ if (vm.exception())
|
|
|
+ return {};
|
|
|
+
|
|
|
+ // 3. Set temporalDate to ? ToTemporalDate(temporalDate).
|
|
|
+ auto* temporal_date = to_temporal_date(global_object, vm.argument(0));
|
|
|
+ if (vm.exception())
|
|
|
+ return {};
|
|
|
+
|
|
|
+ // 4. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]).
|
|
|
+ return create_temporal_date_time(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), temporal_date->calendar());
|
|
|
+}
|
|
|
+
|
|
|
// 4.3.23 Temporal.PlainTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.valueof
|
|
|
JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::value_of)
|
|
|
{
|