ECMAScript revision 5 adds native support for simplified ISO 8601 dates in the
Date.parse method, but some browsers currently on the market (Safari 5-, IE 8-, Firefox 3.6-) do not support it. This
is a simple shim for Date.parse that adds support for parsing ES5 simplified ISO 8601 strings to all browsers. This
following helpful ways:
- Hyphens and colons are optional.
- Dates and times without an explicit timezone are treated as being in local time.
- Time part can be separated by a space in addition to "T". (This is a violation of ISO 8601:2004(E).)
- Time part separator is optional.
- Sub-second precision part can also be separated by comma.
- Sub-second precision part can be any arbitrary precision, milliseconds or smaller.
If you want an ES5-conformant shim, please use the master branch instead.
- This library does not strictly implement the simplified ISO 8601 date time string format specified in the ES5 Errata and will not work identically to conforming implementations.
- Creating a new date using the
new Date(dateString)form will not be fixed by this shim.
Note: You must checkout using
git clone --recursive in order for unit tests to function.
© 2011 Colin Snover. MIT Licensed.