From e8f860048ebb3a480c9ec3b8899c3fb84e7226c9 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 5 Jan 2022 11:05:56 -0500 Subject: [PATCH] LibJS: Set the length of Date.UTC to 7 This is a bit unusual because there is only 1 required argument, but the spec dictates that the length is 7. --- Userland/Libraries/LibJS/Runtime/DateConstructor.cpp | 2 +- Userland/Libraries/LibJS/Tests/builtins/Date/Date.UTC.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp index d936ada9e6..9dc4436c8f 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -156,7 +156,7 @@ void DateConstructor::initialize(GlobalObject& global_object) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(vm.names.now, now, 0, attr); define_native_function(vm.names.parse, parse, 1, attr); - define_native_function(vm.names.UTC, utc, 1, attr); + define_native_function(vm.names.UTC, utc, 7, attr); define_direct_property(vm.names.length, Value(7), Attribute::Configurable); } diff --git a/Userland/Libraries/LibJS/Tests/builtins/Date/Date.UTC.js b/Userland/Libraries/LibJS/Tests/builtins/Date/Date.UTC.js index d5c8082729..158ad7eaf7 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Date/Date.UTC.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Date/Date.UTC.js @@ -1,3 +1,7 @@ +test("length is 7", () => { + expect(Date.UTC).toHaveLength(7); +}); + test("basic functionality", () => { expect(Date.UTC(2020)).toBe(1577836800000); expect(Date.UTC(2000, 10)).toBe(973036800000);