archives

« Bugzilla Issues Index

#3112 — Define behavior of `Date.UTC` when called with fewer than two arguments


Section 20.3.3.4 on `Date.UTC` says:

> When the UTC function is called with fewer than two arguments, the behaviour is implementation-dependent.

Please define this behavior rather than leaving it up to implementors. This would improve interoperability.

Web reality seems to except a return value of `NaN` in this case. http://javascript.spec.whatwg.org/#date.utc

Results for:

[ Date.UTC(), Date.UTC(1) ]

Safari/JavaScriptCore: [ NaN, NaN ]
Chrome/Opera/V8: [ NaN, NaN ]
Safari/JavaScriptCore: [ NaN, NaN ]
Old Opera/Carakan: [ NaN, NaN ]

Only Firefox returns a non-`NaN` value: [ -2208988800000, -2177452800000 ]


IE11: [-2208988800000, -2177452800000]


(In reply to Mathias Bynens from comment #0)
> Section 20.3.3.4 on `Date.UTC` says:
>
> > When the UTC function is called with fewer than two arguments, the behaviour is implementation-dependent.
>
> Please define this behavior rather than leaving it up to implementors. This
> would improve interoperability.
>
> Web reality seems to except a return value of `NaN` in this case.
> http://javascript.spec.whatwg.org/#date.utc
>
> Results for:
>
> [ Date.UTC(), Date.UTC(1) ]
>
> Safari/JavaScriptCore: [ NaN, NaN ]
> Chrome/Opera/V8: [ NaN, NaN ]
> Safari/JavaScriptCore: [ NaN, NaN ]
> Old Opera/Carakan: [ NaN, NaN ]
>
> Only Firefox returns a non-`NaN` value: [ -2208988800000, -2177452800000 ]

The above (plus the IE) result says to me that "web reality" is that the result is implementation defined, just like the spec. says.

We could consider changing the spec if implementations are willing to go along, but it should be a principle changed. Why shouldn't Date.UTC produce a valid timevalue when called with fewer than one arguments?


deferring to ES7 where we'll see if anybody wants to champion this