Date.prototype.toISOString and Invalid Date
dhtmlkitchen at gmail.com
Thu Jun 11 01:24:59 PDT 2009
On Wed, Jun 10, 2009 at 8:56 PM, Adam Peller<apeller at us.ibm.com> wrote:
> Douglas Crockford writes:
>>Adam Peller scripsit:
>>> I don't feel strongly on this, but it does strike me as odd that
>>> a function intended to avoid culturally-sensitive output would use
>>> an English phrase. I'd lean towards IE/Opera, using notation from
>>> ECMAScript that is equally cryptic to all cultures :-) At least that
>>> would be consistent with Number.toString() and would reinforce the fact
>>> that there are other methods to produce strings in the user's locale.
>>I think this is what exceptions are for.
>>An English string makes little sense.
>>NaN is nonsense.
> For toISOString I also favor an exception. The toString reference threw me
> off, since toString would not be able to throw in the invalid case and
> remain compatible. toString Implementations could certainly call
> toISOString, catch the exception, and choose some nonsensical, unspecified
Implementation of toString would probably not want to use try catch.
They might rather do something along the lines of:-
If the date is finite, return an implementation-dependent string
(which could be the resutl of toISOString). Otherwise, return an
implementation-dependent string (such as "invalid date").
A native method for generating a few of the popular or common ISO 8601
formats, such as the extended YYYY-MM-DD seems useful, to me. Is it
It seems that an "es5-discuss" list was created. I'm only subscribing
to es-discuss. It that a deprecated list? What is the difference
between these lists?
More information about the es-discuss