diff --git a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h index 6a23ea170d..4ad8139274 100644 --- a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h +++ b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h @@ -135,6 +135,7 @@ namespace JS { P(getPrototypeOf) \ P(getSeconds) \ P(getTime) \ + P(getTimezoneOffset) \ P(getUTCDate) \ P(getUTCDay) \ P(getUTCFullYear) \ diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index 4091fc7353..75d7771a7c 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -54,6 +54,7 @@ void DatePrototype::initialize(GlobalObject& global_object) define_native_function(vm.names.getSeconds, get_seconds, 0, attr); define_native_function(vm.names.setSeconds, set_seconds, 2, attr); define_native_function(vm.names.getTime, get_time, 0, 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.getUTCDay, get_utc_day, 0, attr); define_native_function(vm.names.getUTCFullYear, get_utc_full_year, 0, attr); @@ -445,6 +446,19 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_time) return Value(this_object->time()); } +JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_timezone_offset) +{ + auto* this_object = typed_this(vm, global_object); + if (!this_object) + return {}; + + if (this_object->is_invalid()) + return js_nan(); + + // FIXME: Make this actually do something once we support timezones instead of just UTC + return Value(0); +} + JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_date) { auto* this_object = typed_this(vm, global_object); diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.h b/Userland/Libraries/LibJS/Runtime/DatePrototype.h index 2ded6d79ad..a4241ce1a6 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.h @@ -35,6 +35,7 @@ private: JS_DECLARE_NATIVE_FUNCTION(get_seconds); JS_DECLARE_NATIVE_FUNCTION(set_seconds); JS_DECLARE_NATIVE_FUNCTION(get_time); + JS_DECLARE_NATIVE_FUNCTION(get_timezone_offset); JS_DECLARE_NATIVE_FUNCTION(get_utc_date); JS_DECLARE_NATIVE_FUNCTION(get_utc_day); JS_DECLARE_NATIVE_FUNCTION(get_utc_full_year);