I tried to understand the semantics of Date() constructors with arguments, as defined in sections 20.3.2.1 and 20.3.2.2 of ECMA-262, 10th edition. The step 3 in both sections says:
If NewTarget is undefined, then
a. Let now be the Number that is the time value (UTC) identifying the current time.
b. Return ToDateString(now).
If I understand correctly, "NewTarget is undefined" means that the constructor is being called as a function. This step seems to say that if Date() with argument(s) is called as a function, the argument(s) are ignored and current time is returned. Or, just maybe, it is an unedited copy-paste from the Date() with no arguments?
I am new to reading the ECMAScript specification, which is not particularly fool-friendly, so I thought I will ask a question before formally reporting an issue: What am I missing?
It's been that way since the first edition of the ECMAScript spec:
When Date is called as a function rather than as a constructor, it returns a string representing the current time(UTC). [...] The arguments are accepted but are completely ignored.
Again, it doesnβt ignore parameters; the Date function is overloaded in the spec, so the zero-parameter one only applies to a zero argument invocation.
But this question isn't about zero-argument invocations, it's about invocations "with arguments". So the first or second overloads are relevant, and both of them ignore parameters when you invoke Date "as a function".