kriskowal/es5-shim — pull request #147 by angelyordanov (2012-12-18 08:49:43+00:00)
Title: Date.parse should treat ISO 8601 milliseconds part as fraction of a second.

I've noticed that the shim implementation of Date.parse was not parsing ASP.NET Web API generated JSON dates which look like this - "2012-12-18T10:33:01.4300913+02:00".

The problem appeared to be the extra digits in the millisecond part.

After some investigation and checking the ISO8601 spec(http://dotat.at/tmp/ISO_8601-2004_E.pdf) it turns out that the numbers after the "." are not the actual milliseconds but a fraction of a second.

Here is what the spec says.

>**4.2.2.4 Representations with decimal fraction**
> If necessary for a particular application a decimal fraction of hour, minute or second may be included. If a decimal fraction is included, lower order time elements (if any) shall be omitted and the decimal fraction shall be divided from the integer part by the decimal sign specified in ISO 31-0, i.e. the comma [,] or full stop [.]. Of these, the comma is the preferred sign. If the magnitude of the number is less than unity, the decimal sign shall be preceded by two zeros in accordance with 3.6.
> The interchange parties, dependent upon the application, shall agree the number of digits in the decimal fraction. The format shall be [hhmmss,ss], [hhmm,mm] or [hh,hh] as appropriate (hour minute second, hour minute, and hour, respectively), with as many digits as necessary following the decimal sign. **A decimal fraction shall have at least one digit.** In the examples below it has been agreed to give the smallest time element a decimal fraction with one digit.

All browsers I've checked (IE10,IE9, Latest Chrome, Firefox, Opera) support this.

The spec defines fractions from hours and minutes as well but no browser does support this.

I have implemented a fix and added tests to cover this.

Let me know what you think.
Thanks.