summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-08-21 08:40:58 -0400
committerAndreas Kling <kling@serenityos.org>2020-08-21 16:03:34 +0200
commitc8cf4651742053e11b72d736bb59a6714e89d8c7 (patch)
treedbf032347badbdda6e0ee00aba24f3ef72436caf
parent064159d2154235d004f39bbe24acf82024bca1cb (diff)
downloadserenity-c8cf4651742053e11b72d736bb59a6714e89d8c7.zip
LibJS: Implement Date.valueOf()
It does exactly the same thing as Date.getTime().
-rw-r--r--Libraries/LibJS/Runtime/DatePrototype.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibJS/Runtime/DatePrototype.cpp b/Libraries/LibJS/Runtime/DatePrototype.cpp
index 59b2948b24..510f2b3b66 100644
--- a/Libraries/LibJS/Runtime/DatePrototype.cpp
+++ b/Libraries/LibJS/Runtime/DatePrototype.cpp
@@ -73,6 +73,13 @@ void DatePrototype::initialize(GlobalObject& global_object)
define_native_function("toLocaleTimeString", to_locale_time_string, 0, attr);
define_native_function("toTimeString", to_time_string, 0, attr);
define_native_function("toString", to_string, 0, attr);
+
+ // Aliases.
+ define_native_function("valueOf", get_time, 0, attr);
+ // toJSON() isn't quite an alias for toISOString():
+ // - it returns null instead of throwing RangeError
+ // - its .length is 1, not 0
+ // - it can be transferred to other prototypes
}
DatePrototype::~DatePrototype()