summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-06-06 17:34:04 +0300
committerLinus Groh <mail@linusgroh.de>2021-06-06 19:14:11 +0100
commit60e70e5ee457f80d399a834f83e1e5ff8c6146eb (patch)
treeb2b6fa875ed62dd23659afa35960dbff17c2bc6e
parent46214f0657c35f9af266cd38985fe787e1f429d0 (diff)
downloadserenity-60e70e5ee457f80d399a834f83e1e5ff8c6146eb.zip
LibJS: Add Date.setUTC{Date, Month, Hours, ...}() aliases
These are a bit hacky, since they are supposed to be separate methods, but since serenity only supports UTC currently, they are equivalent.
-rw-r--r--Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h7
-rw-r--r--Userland/Libraries/LibJS/Runtime/DatePrototype.cpp7
2 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h
index b731a74393..1026bdc70c 100644
--- a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h
+++ b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h
@@ -224,6 +224,13 @@ namespace JS {
P(setPrototypeOf) \
P(setSeconds) \
P(setTime) \
+ P(setUTCDate) \
+ P(setUTCFullYear) \
+ P(setUTCHours) \
+ P(setUTCMilliseconds) \
+ P(setUTCMinutes) \
+ P(setUTCMonth) \
+ P(setUTCSeconds) \
P(setYear) \
P(shift) \
P(sign) \
diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp
index 5594757bb4..2b02851d4b 100644
--- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp
@@ -59,13 +59,20 @@ void DatePrototype::initialize(GlobalObject& global_object)
define_native_function(vm.names.setTime, set_time, 1, attr);
define_native_function(vm.names.getTimezoneOffset, get_timezone_offset, 0, attr);
define_native_function(vm.names.getUTCDate, get_utc_date, 0, attr);
+ define_native_function(vm.names.setUTCDate, set_date, 1, attr); // FIXME: This is a hack, Serenity doesn't currently support timezones other than UTC.
define_native_function(vm.names.getUTCDay, get_utc_day, 0, attr);
define_native_function(vm.names.getUTCFullYear, get_utc_full_year, 0, attr);
+ define_native_function(vm.names.setUTCFullYear, set_full_year, 3, attr); // FIXME: see above
define_native_function(vm.names.getUTCHours, get_utc_hours, 0, attr);
+ define_native_function(vm.names.setUTCHours, set_hours, 4, attr); // FIXME: see above
define_native_function(vm.names.getUTCMilliseconds, get_utc_milliseconds, 0, attr);
+ define_native_function(vm.names.setUTCMilliseconds, set_milliseconds, 1, attr); // FIXME: see above
define_native_function(vm.names.getUTCMinutes, get_utc_minutes, 0, attr);
+ define_native_function(vm.names.setUTCMinutes, set_minutes, 3, attr); // FIXME: see above
define_native_function(vm.names.getUTCMonth, get_utc_month, 0, attr);
+ define_native_function(vm.names.setUTCMonth, set_month, 2, attr); // FIXME: see above
define_native_function(vm.names.getUTCSeconds, get_utc_seconds, 0, attr);
+ define_native_function(vm.names.setUTCSeconds, set_seconds, 2, attr); // FIXME: see above
define_native_function(vm.names.toDateString, to_date_string, 0, attr);
define_native_function(vm.names.toUTCString, to_utc_string, 0, attr);
define_native_function(vm.names.toISOString, to_iso_string, 0, attr);