From 60e70e5ee457f80d399a834f83e1e5ff8c6146eb Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sun, 6 Jun 2021 17:34:04 +0300 Subject: [PATCH] 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. --- Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h | 7 +++++++ Userland/Libraries/LibJS/Runtime/DatePrototype.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h index b731a74393a..1026bdc70c2 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 5594757bb4e..2b02851d4bb 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);