Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Remove Date.UTC after tc39/ecma262#642 is merged #31

Closed
evilpie opened this issue Apr 2, 2016 · 11 comments
Closed

Remove Date.UTC after tc39/ecma262#642 is merged #31

evilpie opened this issue Apr 2, 2016 · 11 comments

Comments

@evilpie
Copy link

evilpie commented Apr 2, 2016

Maybe I am wrong, but I tried to follow to spec along here. (https://tc39.github.io/ecma262/#sec-date.utc)

For zero arguments:
Date.UTC

  1. y = ToNumber(year) => y = NaN
  2. This step is somewhat confusing, but we should end up with yr = y = NaN
    MakeDay(yr, m, dt)
  3. Return NaN, yr is not finite.
    MakeDate
  4. Return NaN, day is not finite
    TimeClip
  5. Return NaN, time is not finite

For one argument MakeDay should also return NaN, because month is not finite, so the rest follows.

@claudepache
Copy link

You just missed the very beginning of the section you pointed to:

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

@claudepache
Copy link

claudepache commented Jul 21, 2016

According to my tests, in general, Chakra does not always return NaN when calling Date.UTC with less than two arguments. More precisely, it seems to implement the following variation of the Date.UTC algorithm:

  1. If year is supplied, let y be ? ToNumber(year); else let y be 0.
  2. If month is supplied, let m be ? ToNumber(month); else let m be 0.
  3. etc.

which is observable only when less than two arguments are provided.

@mathiasbynens
Copy link
Member

It would be nice to get implementations to agree on what should happen when Date.UTC is called with fewer than two arguments, and to remove this from the ECMAScript spec:

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

mathiasbynens added a commit that referenced this issue Jul 22, 2016
Chakra implements it differently (#31 (comment)), so this quirk doesn’t seem required for web compatibility.

Ref. #29 (comment).
@littledan
Copy link

@bterlson What are your thoughts here?

@bterlson
Copy link

As usual I agree with @mathiasbynens about what would be nice. I can't imagine that this is important for compat scenarios (certainly not missing year, though I could possibly imagine missing month). I'll open a bug on ChakraCore to align with the others here.

@domenic
Copy link
Member

domenic commented Jul 28, 2016

Let's repurpose this bug to remove the JavaScript Standard's line about Date.UTC once tc39/ecma262#642 is merged.

@domenic domenic changed the title Date.UTC should already return NaN with fewer than 2 arguments Remove Date.UTC after tc39/ecma262#642 is merged Jul 28, 2016
@domenic
Copy link
Member

domenic commented Jul 28, 2016

Oh, nevermind, I guess this was already removed in 750a6d7.

@domenic domenic closed this as completed Jul 28, 2016
@littledan
Copy link

Well, we still don't have consensus on TC39 to standardize returning NaN for Date.UTC with one argument. It would seem nice to write it down somewhere that that returns NaN.

@dilijev
Copy link

dilijev commented Jul 29, 2016

@littledan @bterlson At this time, is it worth implementing the behavior that 0 args should return NaN while we wait for consensus on the 1 argument option, or is a decision forthcoming?

@littledan
Copy link

From an implementor's point or view, I think it would be fine to ship the consensus from other browsers (0 or 1 arguments returns NaN) to maximize compatibility even if the committee allows something more general.

@littledan
Copy link

We have no guarantee when a further decision on Date.UTC will come FWIW. It may be a while.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

7 participants