In comp.lang.javascript message <
[email protected]>, Sun,
2 Nov 2008 12:20:20 said:
It would be rather unwise to do that as when the first argument of the Date
constructor is a string value, it is specified in ECMAScript Ed. 3 Final,
section 15.9.3.2, that the value should be parsed "in exactly the same
manner as for the parse method (section 15.9.4.2); let V be the time value
for this date.".
However it is specified there that "The string may be interpreted as a local
time, a UTC time, or a time in some other time zone, depending on the
contents of the string."; in other words, it is _not_ specified there.
Therefore, using "YYYY/DD/MM" may or may not work in an implementation, and
for that matter that implementation would still be compliant with ECMAScript
Ed. 3.
In contrast, the numeric multi-argument variant is well-specified in section
15.9.3.1, and well-supported.
A wrapper method or developer's algorithm (subtract 1) can provide for the
syntactic sugar; however, for a developer it should not be unusual to
encounter zero-based indexes, so the Outside World argument must be
questioned here.
You are a legalistic twit. I've tested versions of five major browsers
myself, and all accept that form. I've asked for counterexamples, and
none have ever been provided. By your reasoning, no string form would
be usable.
Granted, there are two known traps with new Date(String).
One cannot safely use DD/MM/YYYY or MM/DD/YYYY, since both forms are in
use in the Real World, and a browser might choose to prefer either.
YYYY/MM/DD is safe; one has to be really stupid to choose YYYY/DD/MM or
YYYYDDMM - AFAIK, that has only ever been done at the Federal level.
And one cannot safely use alphabetic offset indicators other than GMT &
UTC, since they are not otherwise standardised. NASA do not show signs
of knowing that, though they have been told.
Neither trap applies in this case.
As for your silly "zero-based" argument - the Gregorian Month in the
real world is always numerically represented by 1 to 12, as per ISO
8601. Therefore, it is unreasonable to expect people editing code
always to remember to use numbers 0 to 11, whereas if they are editing a
YYYY/MM/DD string there will be no problem.
You should not be arguing against supporting an important and useful ISO
standard.
As far as I can see, de.c.l.j also find you to be offensively socially
abnormal (which is a relief, in a way). You should try to grow up and
act as a normal human being. Psycho-medical services can do wonders
these days, they say.