mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 18:37:58 +03:00
LibJS: Stub out Date.prototype.getTimezoneOffset()
We only support UTC currently, so this always returns 0 as long as the date is not invalid.
This commit is contained in:
parent
44926b3f80
commit
3eb05d9413
Notes:
sideshowbarker
2024-07-18 12:44:54 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/3eb05d94136 Pull-request: https://github.com/SerenityOS/serenity/pull/7845 Reviewed-by: https://github.com/linusg
@ -135,6 +135,7 @@ namespace JS {
|
||||
P(getPrototypeOf) \
|
||||
P(getSeconds) \
|
||||
P(getTime) \
|
||||
P(getTimezoneOffset) \
|
||||
P(getUTCDate) \
|
||||
P(getUTCDay) \
|
||||
P(getUTCFullYear) \
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user