summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-07-22 19:47:07 +0100
committerLinus Groh <mail@linusgroh.de>2021-07-22 21:19:40 +0100
commit4be3196882f592635c4f89c8d2cc9e520418f8e6 (patch)
treebfb910fad3da4beb9d12ab6ec31742eea1069cee /Userland/Libraries/LibJS/Runtime
parent42b6bffbf2b6aa34f4f82cd4c3c34ed5528790ad (diff)
downloadserenity-4be3196882f592635c4f89c8d2cc9e520418f8e6.zip
LibJS: Start implementing Temporal.PlainDateTime
This commit adds the PlainDateTime object itself, its constructor and prototype (currently empty), and the CreateTemporalDateTime abstract operation.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorTypes.h1
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp73
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.h37
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp166
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h28
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp23
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h22
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp2
9 files changed, 354 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
index 39e1ce7799..cc296cefe6 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
+++ b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
@@ -174,6 +174,7 @@
M(TemporalInvalidISODate, "Invalid ISO date") \
M(TemporalInvalidMonthCode, "Invalid month code") \
M(TemporalInvalidPlainDate, "Invalid plain date") \
+ M(TemporalInvalidPlainDateTime, "Invalid plain date time") \
M(TemporalInvalidTime, "Invalid time") \
M(TemporalInvalidTimeZoneName, "Invalid time zone name") \
M(TemporalMissingRequiredProperty, "Required property {} is missing or undefined") \
diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
index 1e3c12402a..c669a45a51 100644
--- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
@@ -77,6 +77,8 @@
#include <LibJS/Runtime/Temporal/InstantPrototype.h>
#include <LibJS/Runtime/Temporal/PlainDateConstructor.h>
#include <LibJS/Runtime/Temporal/PlainDatePrototype.h>
+#include <LibJS/Runtime/Temporal/PlainDateTimeConstructor.h>
+#include <LibJS/Runtime/Temporal/PlainDateTimePrototype.h>
#include <LibJS/Runtime/Temporal/Temporal.h>
#include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
#include <LibJS/Runtime/Temporal/TimeZonePrototype.h>
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp
index b047d0b19c..646151a8ea 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp
@@ -4,14 +4,37 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/Date.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/Temporal/PlainDate.h>
#include <LibJS/Runtime/Temporal/PlainDateTime.h>
+#include <LibJS/Runtime/Temporal/PlainDateTimeConstructor.h>
#include <LibJS/Runtime/Temporal/PlainTime.h>
namespace JS::Temporal {
+// 5 Temporal.PlainDateTime Objects, https://tc39.es/proposal-temporal/#sec-temporal-plaindatetime-objects
+PlainDateTime::PlainDateTime(i32 iso_year, u8 iso_month, u8 iso_day, u8 iso_hour, u8 iso_minute, u8 iso_second, u8 iso_millisecond, u8 iso_microsecond, u8 iso_nanosecond, Object& calendar, Object& prototype)
+ : Object(prototype)
+ , m_iso_year(iso_year)
+ , m_iso_month(iso_month)
+ , m_iso_day(iso_day)
+ , m_iso_hour(iso_hour)
+ , m_iso_minute(iso_minute)
+ , m_iso_second(iso_second)
+ , m_iso_millisecond(iso_millisecond)
+ , m_iso_microsecond(iso_microsecond)
+ , m_iso_nanosecond(iso_nanosecond)
+ , m_calendar(calendar)
+{
+}
+
+void PlainDateTime::visit_edges(Visitor& visitor)
+{
+ visitor.visit(&m_calendar);
+}
+
// 5.5.1 GetEpochFromISOParts ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond ), https://tc39.es/proposal-temporal/#sec-temporal-getepochfromisoparts
BigInt* get_epoch_from_iso_parts(GlobalObject& global_object, i32 year, i32 month, i32 day, i32 hour, i32 minute, i32 second, i32 millisecond, i32 microsecond, i32 nanosecond)
{
@@ -69,4 +92,54 @@ bool iso_date_time_within_limits(GlobalObject& global_object, i32 year, i32 mont
return true;
}
+// 5.5.6 CreateTemporalDateTime ( isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporaldatetime
+PlainDateTime* create_temporal_date_time(GlobalObject& global_object, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object& calendar, FunctionObject* new_target)
+{
+ auto& vm = global_object.vm();
+
+ // 1. Assert: isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, and nanosecond are integers.
+ // 2. Assert: Type(calendar) is Object.
+
+ // 3. If ! IsValidISODate(isoYear, isoMonth, isoDay) is false, throw a RangeError exception.
+ if (!is_valid_iso_date(iso_year, iso_month, iso_day)) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 4. If ! IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception.
+ if (!is_valid_time(hour, minute, second, millisecond, microsecond, nanosecond)) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 5. If ! ISODateTimeWithinLimits(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond) is false, then
+ if (!iso_date_time_within_limits(global_object, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond)) {
+ // a. Throw a RangeError exception.
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 6. If newTarget is not present, set it to %Temporal.PlainDateTime%.
+ if (!new_target)
+ new_target = global_object.temporal_plain_date_time_constructor();
+
+ // 7. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.PlainDateTime.prototype%", ยซ [[InitializedTemporalDateTime]], [[ISOYear]], [[ISOMonth]], [[ISODay]], [[ISOHour]], [[ISOMinute]], [[ISOSecond]], [[ISOMillisecond]], [[ISOMicrosecond]], [[ISONanosecond]], [[Calendar]] ยป).
+ // 8. Set object.[[ISOYear]] to isoYear.
+ // 9. Set object.[[ISOMonth]] to isoMonth.
+ // 10. Set object.[[ISODay]] to isoDay.
+ // 11. Set object.[[ISOHour]] to hour.
+ // 12. Set object.[[ISOMinute]] to minute.
+ // 13. Set object.[[ISOSecond]] to second.
+ // 14. Set object.[[ISOMillisecond]] to millisecond.
+ // 15. Set object.[[ISOMicrosecond]] to microsecond.
+ // 16. Set object.[[ISONanosecond]] to nanosecond.
+ // 17. Set object.[[Calendar]] to calendar.
+ auto* object = ordinary_create_from_constructor<PlainDateTime>(global_object, *new_target, &GlobalObject::temporal_plain_date_prototype, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, calendar);
+ if (vm.exception())
+ return {};
+
+ // 18. Return object.
+ return object;
+}
+
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.h
index f5b6452464..a6eabc176c 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
+ * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -10,7 +11,43 @@
namespace JS::Temporal {
+class PlainDateTime final : public Object {
+ JS_OBJECT(PlainDateTime, Object);
+
+public:
+ PlainDateTime(i32 iso_year, u8 iso_month, u8 iso_day, u8 iso_hour, u8 iso_minute, u8 iso_second, u8 iso_millisecond, u8 iso_microsecond, u8 iso_nanosecond, Object& calendar, Object& prototype);
+ virtual ~PlainDateTime() override = default;
+
+ [[nodiscard]] i32 iso_year() const { return m_iso_year; }
+ [[nodiscard]] u8 iso_month() const { return m_iso_month; }
+ [[nodiscard]] u8 iso_day() const { return m_iso_day; }
+ [[nodiscard]] u8 iso_hour() const { return m_iso_hour; }
+ [[nodiscard]] u8 iso_minute() const { return m_iso_minute; }
+ [[nodiscard]] u8 iso_second() const { return m_iso_second; }
+ [[nodiscard]] u8 iso_millisecond() const { return m_iso_millisecond; }
+ [[nodiscard]] u8 iso_microsecond() const { return m_iso_microsecond; }
+ [[nodiscard]] u8 iso_nanosecond() const { return m_iso_nanosecond; }
+ [[nodiscard]] Object const& calendar() const { return m_calendar; }
+ [[nodiscard]] Object& calendar() { return m_calendar; }
+
+private:
+ virtual void visit_edges(Visitor&) override;
+
+ // 5.4 Properties of Temporal.PlainDateTime Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-plaindatetime-instances
+ i32 m_iso_year { 0 }; // [[ISOYear]]
+ u8 m_iso_month { 0 }; // [[ISOMonth]]
+ u8 m_iso_day { 0 }; // [[ISODay]]
+ u8 m_iso_hour { 0 }; // [[ISOHour]]
+ u8 m_iso_minute { 0 }; // [[ISOMinute]]
+ u8 m_iso_second { 0 }; // [[ISOSecond]]
+ u16 m_iso_millisecond { 0 }; // [[ISOMillisecond]]
+ u16 m_iso_microsecond { 0 }; // [[ISOMicrosecond]]
+ u16 m_iso_nanosecond { 0 }; // [[ISONanosecond]]
+ Object& m_calendar; // [[Calendar]]
+};
+
BigInt* get_epoch_from_iso_parts(GlobalObject&, i32 year, i32 month, i32 day, i32 hour, i32 minute, i32 second, i32 millisecond, i32 microsecond, i32 nanosecond);
bool iso_date_time_within_limits(GlobalObject&, i32 year, i32 month, i32 day, i32 hour, i32 minute, i32 second, i32 millisecond, i32 microsecond, i32 nanosecond);
+PlainDateTime* create_temporal_date_time(GlobalObject&, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object& calendar, FunctionObject* new_target = nullptr);
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp
new file mode 100644
index 0000000000..717b995ba0
--- /dev/null
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <AK/Checked.h>
+#include <LibJS/Runtime/GlobalObject.h>
+#include <LibJS/Runtime/Temporal/Calendar.h>
+#include <LibJS/Runtime/Temporal/PlainDateTime.h>
+#include <LibJS/Runtime/Temporal/PlainDateTimeConstructor.h>
+
+namespace JS::Temporal {
+
+// 5.1 The Temporal.PlainDateTime Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plaindatetime-constructor
+PlainDateTimeConstructor::PlainDateTimeConstructor(GlobalObject& global_object)
+ : NativeFunction(vm().names.PlainDateTime.as_string(), *global_object.function_prototype())
+{
+}
+
+void PlainDateTimeConstructor::initialize(GlobalObject& global_object)
+{
+ NativeFunction::initialize(global_object);
+
+ auto& vm = this->vm();
+
+ // 5.2.1 Temporal.PlainDateTime.prototype, https://tc39.es/proposal-temporal/#sec-temporal-plaindatetime-prototype
+ define_direct_property(vm.names.prototype, global_object.temporal_plain_date_time_prototype(), 0);
+
+ define_direct_property(vm.names.length, Value(3), Attribute::Configurable);
+}
+
+// 5.1.1 Temporal.PlainDateTime ( isoYear, isoMonth, isoDay [ , hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond [ , calendarLike ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime
+Value PlainDateTimeConstructor::call()
+{
+ auto& vm = this->vm();
+
+ // 1. If NewTarget is undefined, throw a TypeError exception.
+ vm.throw_exception<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.PlainDateTime");
+ return {};
+}
+
+// 5.1.1 Temporal.PlainDateTime ( isoYear, isoMonth, isoDay [ , hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond [ , calendarLike ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime
+Value PlainDateTimeConstructor::construct(FunctionObject& new_target)
+{
+ auto& vm = this->vm();
+ auto& global_object = this->global_object();
+
+ // 2. Let isoYear be ? ToIntegerOrInfinity(isoYear).
+ auto iso_year = vm.argument(0).to_integer_or_infinity(global_object);
+ if (vm.exception())
+ return {};
+
+ // 3. If isoYear is +โˆž or -โˆž, throw a RangeError exception.
+ if (Value(iso_year).is_infinity()) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 4. Let isoMonth be ? ToIntegerOrInfinity(isoMonth).
+ auto iso_month = vm.argument(1).to_integer_or_infinity(global_object);
+ if (vm.exception())
+ return {};
+
+ // 5. If isoMonth is +โˆž or -โˆž, throw a RangeError exception.
+ if (Value(iso_month).is_infinity()) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 6. Let isoDay be ? ToIntegerOrInfinity(isoDay).
+ auto iso_day = vm.argument(2).to_integer_or_infinity(global_object);
+ if (vm.exception())
+ return {};
+
+ // 7. If isoDay is +โˆž or -โˆž, throw a RangeError exception.
+ if (Value(iso_day).is_infinity()) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 8. Let hour be ? ToIntegerOrInfinity(hour).
+ auto hour = vm.argument(3).to_integer_or_infinity(global_object);
+ if (vm.exception())
+ return {};
+
+ // 9. If hour is +โˆž or -โˆž, throw a RangeError exception.
+ if (Value(hour).is_infinity()) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // Let minute be ? ToIntegerOrInfinity(minute).
+ auto minute = vm.argument(4).to_integer_or_infinity(global_object);
+ if (vm.exception())
+ return {};
+
+ // 11. If minute is +โˆž or -โˆž, throw a RangeError exception.
+ if (Value(minute).is_infinity()) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 12. Let second be ? ToIntegerOrInfinity(second).
+ auto second = vm.argument(5).to_integer_or_infinity(global_object);
+ if (vm.exception())
+ return {};
+
+ // 13. If second is +โˆž or -โˆž, throw a RangeError exception.
+ if (Value(second).is_infinity()) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 14. Let millisecond be ? ToIntegerOrInfinity(millisecond).
+ auto millisecond = vm.argument(6).to_integer_or_infinity(global_object);
+ if (vm.exception())
+ return {};
+
+ // 15. If millisecond is +โˆž or -โˆž, throw a RangeError exception.
+ if (Value(millisecond).is_infinity()) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 16. Let microsecond be ? ToIntegerOrInfinity(microsecond).
+ auto microsecond = vm.argument(7).to_integer_or_infinity(global_object);
+ if (vm.exception())
+ return {};
+
+ // 17. If microsecond is +โˆž or -โˆž, throw a RangeError exception.
+ if (Value(microsecond).is_infinity()) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 18. Let nanosecond be ? ToIntegerOrInfinity(nanosecond).
+ auto nanosecond = vm.argument(8).to_integer_or_infinity(global_object);
+ if (vm.exception())
+ return {};
+
+ // 19. If nanosecond is +โˆž or -โˆž, throw a RangeError exception.
+ if (Value(nanosecond).is_infinity()) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 20. Let calendar be ? ToTemporalCalendarWithISODefault(calendarLike).
+ auto* calendar = to_temporal_calendar_with_iso_default(global_object, vm.argument(9));
+ if (vm.exception())
+ return {};
+
+ // IMPLEMENTATION DEFINED: This is an optimization that allows us to treat these doubles as normal integers from this point onwards.
+ // This does not change the exposed behaviour as the call to CreateTemporalDateTime will immediately check that these values are valid
+ // ISO values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31, for hours: 0 - 23, for minutes and seconds: 0 - 59,
+ // milliseconds, microseconds, and nanoseconds: 0 - 999) all of which are subsets of this check.
+ if (!AK::is_within_range<i32>(iso_year) || !AK::is_within_range<u8>(iso_month) || !AK::is_within_range<u8>(iso_day) || !AK::is_within_range<u8>(hour) || !AK::is_within_range<u8>(minute) || !AK::is_within_range<u8>(second) || !AK::is_within_range<u16>(millisecond) || !AK::is_within_range<u16>(microsecond) || !AK::is_within_range<u16>(nanosecond)) {
+ vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime);
+ return {};
+ }
+
+ // 21. Return ? CreateTemporalDateTime(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar, NewTarget).
+ return create_temporal_date_time(global_object, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, *calendar, &new_target);
+}
+
+}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h
new file mode 100644
index 0000000000..a4263ed7ff
--- /dev/null
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibJS/Runtime/NativeFunction.h>
+
+namespace JS::Temporal {
+
+class PlainDateTimeConstructor final : public NativeFunction {
+ JS_OBJECT(PlainDateTimeConstructor, NativeFunction);
+
+public:
+ explicit PlainDateTimeConstructor(GlobalObject&);
+ virtual void initialize(GlobalObject&) override;
+ virtual ~PlainDateTimeConstructor() override = default;
+
+ virtual Value call() override;
+ virtual Value construct(FunctionObject& new_target) override;
+
+private:
+ virtual bool has_constructor() const override { return true; }
+};
+
+}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp
new file mode 100644
index 0000000000..05d2ff891d
--- /dev/null
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibJS/Runtime/GlobalObject.h>
+#include <LibJS/Runtime/Temporal/PlainDateTimePrototype.h>
+
+namespace JS::Temporal {
+
+// 5.3 Properties of the Temporal.PlainDateTime Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plaindatetime-prototype-object
+PlainDateTimePrototype::PlainDateTimePrototype(GlobalObject& global_object)
+ : Object(*global_object.object_prototype())
+{
+}
+
+void PlainDateTimePrototype::initialize(GlobalObject& global_object)
+{
+ Object::initialize(global_object);
+}
+
+}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h
new file mode 100644
index 0000000000..434d542324
--- /dev/null
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibJS/Runtime/Object.h>
+
+namespace JS::Temporal {
+
+class PlainDateTimePrototype final : public Object {
+ JS_OBJECT(PlainDateTimePrototype, Object);
+
+public:
+ explicit PlainDateTimePrototype(GlobalObject&);
+ virtual void initialize(GlobalObject&) override;
+ virtual ~PlainDateTimePrototype() override = default;
+};
+
+}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
index 4fa31a57d9..0c77d6a768 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
@@ -10,6 +10,7 @@
#include <LibJS/Runtime/Temporal/InstantConstructor.h>
#include <LibJS/Runtime/Temporal/Now.h>
#include <LibJS/Runtime/Temporal/PlainDateConstructor.h>
+#include <LibJS/Runtime/Temporal/PlainDateTimeConstructor.h>
#include <LibJS/Runtime/Temporal/Temporal.h>
#include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
@@ -33,6 +34,7 @@ void Temporal::initialize(GlobalObject& global_object)
define_direct_property(vm.names.Duration, global_object.temporal_duration_constructor(), attr);
define_direct_property(vm.names.Instant, global_object.temporal_instant_constructor(), attr);
define_direct_property(vm.names.PlainDate, global_object.temporal_plain_date_constructor(), attr);
+ define_direct_property(vm.names.PlainDateTime, global_object.temporal_plain_date_time_constructor(), attr);
define_direct_property(vm.names.TimeZone, global_object.temporal_time_zone_constructor(), attr);
}