summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-07-19 00:29:26 +0300
committerLinus Groh <mail@linusgroh.de>2021-07-19 09:11:20 +0100
commitcc00ccec4119c01110443f057d5771cc8fee6323 (patch)
treece06f75823bc3e6a92735c2468bafdb8a10f012e /Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h
parentff6ca0f02da0e3acf22a3be1a3f41299935e5a87 (diff)
downloadserenity-cc00ccec4119c01110443f057d5771cc8fee6323.zip
LibJS: Start implementing Temporal.PlainDate
This commit adds the PlainDate object itself, its constructor and prototype (currently empty), and several required abstract operations.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h
index 8471958743..fde86d4bd3 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h
@@ -10,6 +10,30 @@
namespace JS::Temporal {
+class PlainDate final : public Object {
+ JS_OBJECT(PlainDate, Object);
+
+public:
+ explicit PlainDate(i32 iso_year, i32 iso_month, i32 iso_day, Object& calendar, Object& prototype);
+ virtual ~PlainDate() override = default;
+
+ [[nodiscard]] i32 iso_year() const { return m_iso_year; }
+ [[nodiscard]] i32 iso_month() const { return m_iso_month; }
+ [[nodiscard]] i32 iso_day() const { return m_iso_day; }
+ [[nodiscard]] Object const& calendar() const { return m_calendar; }
+ [[nodiscard]] Object& calendar() { return m_calendar; }
+
+private:
+ virtual void visit_edges(Visitor&) override;
+
+ // 3.4 Properties of Temporal.PlainDate Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-plaindate-instances
+ i32 m_iso_year { 0 }; // [[ISOYear]]
+ i32 m_iso_month { 1 }; // [[ISOMonth]]
+ i32 m_iso_day { 1 }; // [[ISODay]]
+ Object& m_calendar; // [[Calendar]]
+};
+
+PlainDate* create_temporal_date(GlobalObject&, i32 iso_year, i32 iso_month, i32 iso_day, Object& calendar, FunctionObject* new_target);
bool is_valid_iso_date(i32 year, i32 month, i32 day);
}