Date.prototype.toISOString and Invalid Date

David-Sarah Hopwood david-sarah at jacaranda.org
Tue Jun 9 20:01:10 PDT 2009


Allen Wirfs-Brock wrote:
> Currently, implementations are inconsistent about what they produce for (new Date(NaN).toString()).
> IE and Opera produce "NaN", while FF and Safari produce "Invalid Date".

Note that other cases of invalid numbers such as (but not limited to)
'new Date(Infinity)', should be treated in the same way.

> Since toISOString is a new function, we have the opportunity to specify what we want the result to be.
> 
> Does anybody have an opinion. It could be either "NaN" or "Invalid Date" or something else. "Invalid Date" has the advantage that it is more end-user meaningful if it actually leaks through to be visible on a web page (although that is a pretty Anglo-centric perspective).
> 
> Unless, I here strong opinions otherwise I think I'll go with "Invalid Date".

Seems fine to me.

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com



More information about the es5-discuss mailing list