summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Temporal
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Temporal')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp20
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Now.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
index f33e1c3529..5f702ad883 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp
@@ -35,6 +35,7 @@ void Now::initialize(GlobalObject& global_object)
define_native_function(vm.names.timeZone, time_zone, 0, attr);
define_native_function(vm.names.instant, instant, 0, attr);
define_native_function(vm.names.plainDate, plain_date, 1, attr);
+ define_native_function(vm.names.plainDateISO, plain_date_iso, 0, attr);
}
// 2.1.1 Temporal.Now.timeZone ( ), https://tc39.es/proposal-temporal/#sec-temporal.now.timezone
@@ -66,6 +67,25 @@ JS_DEFINE_NATIVE_FUNCTION(Now::plain_date)
return create_temporal_date(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->calendar());
}
+// 2.1.8 Temporal.Now.plainDateISO ( [ temporalTimeZoneLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.now.plaindateiso
+JS_DEFINE_NATIVE_FUNCTION(Now::plain_date_iso)
+{
+ auto temporal_time_zone_like = vm.argument(0);
+
+ // 1. Let calendar be ? GetISO8601Calendar().
+ auto* calendar = get_iso8601_calendar(global_object);
+ if (vm.exception())
+ return {};
+
+ // 2. Let dateTime be ? SystemDateTime(temporalTimeZoneLike, calendar).
+ auto* date_time = system_date_time(global_object, temporal_time_zone_like, calendar);
+ if (vm.exception())
+ return {};
+
+ // 3. Return ? CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]).
+ return create_temporal_date(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->calendar());
+}
+
// 2.2.1 SystemTimeZone ( ), https://tc39.es/proposal-temporal/#sec-temporal-systemtimezone
TimeZone* system_time_zone(GlobalObject& global_object)
{
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.h b/Userland/Libraries/LibJS/Runtime/Temporal/Now.h
index e22a44ee16..7d85c612bb 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.h
@@ -22,6 +22,7 @@ private:
JS_DECLARE_NATIVE_FUNCTION(time_zone);
JS_DECLARE_NATIVE_FUNCTION(instant);
JS_DECLARE_NATIVE_FUNCTION(plain_date);
+ JS_DECLARE_NATIVE_FUNCTION(plain_date_iso);
};
TimeZone* system_time_zone(GlobalObject&);