HTML date format and Date.parse()
allen at wirfs-brock.com
Sun Apr 28 07:36:29 PDT 2013
On Apr 25, 2013, at 10:43 PM, Jason Orendorff wrote:
> The HTML spec for parsing date and time values is slightly more lenient than ES.
The primary requirement of Date.parse is that it must be able to unambiguously recognize any date encoded in the date-time format defined in section 184.108.40.206: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-220.127.116.11 . This is the date generated by toISOString and the intend is to guarantee that dates generated via toISOString will always be recognized by Date.parse.
For such interchange purposes, I don't think is is necessary to relax the date format rules. Note that ISO 8601 says that formatting simplifications such as leaving out the T is permitted with mutual agreement between the parties interchanging a data. It isn't clear who the other party is that Ecma-262 could reach such an agreement with.
Regardless, the specification of Date.parse allows implementation dependent interpretation of inputs that don't conform to the 18.104.22.168 format so an implementation can accept other data formats. My understanding is that browsers implementations typically accept a lot of things as valid dates but that there is no browser independent specification for this.
I don't think it is necessarily a good idea for Ecma-262 to require all Es implementations to conform to the intersection of what browsers currently recognized. However, it seems quite reasonable that some W3C spec. (WebIDL? is anyplace else that takes about hosting ES in the browser) defines the browser required "implementation dependent" Date.parse fallback formats
> The differences are:
> - HTML allows more-than-4-digit years.
The Ecma-262 format allows 6 digits, as long there is a + or - prefix.
> - HTML allows the seconds and milliseconds to be omitted.
This is already allowed by 22.214.171.124:
"following time forms with an optional time zone offset appended:
> - HTML allows the "T" in the middle to be replaced with a single space.
> Can ES adopt these changes? It seems to me HTML and JS might as well
> have the same rules for this sort of thing.
Or maybe we should both just stick to a valid subset of ISO 8601.
Like I said above, I think it would be fine for there to be a spec. that adds additional browser implementation spec. format extensions for Date.parse. However, it should only just align with the HTML spec. It also needs to align with the current browser reality for Date.parse.
> HTML: 126.96.36.199 Local dates and times
> ES: 188.8.131.52 Date.parse (string)
> ES: 184.108.40.206 Date Time String Format
> Some old discussion in Mozilla's bug-tracking system, no real conclusion:
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss