JavaScript iso8601 Date Parsing (xbrowser polyfill)
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README
date_iso8601_polyfill.js
date_iso8601_polyfill_es6.js

README

date_iso8601_polyfill.js  - original version of the polyfill compatible with ES5.1 spec
                            http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15  

date_iso8601_polyfill_es6.js  - updated version of the polyfill compatible with ES6 spec
                                http://people.mozilla.org/~jorendorff/es6-draft.html#sec-15.9.1.15

polyfilling JavaScript's subset of iso8601 dates to work on all browsers - ck 2/7/2012

the new version that is compatible with ES6 assumes dates are in local time when no
timezone specifier is given.  this is more inline with what the actual iso8601 standard
says... for a more detailed explanation see below.

original testing ground (ES5.1 version): http://jsbin.com/akagim/10

ref:
http://dev.w3.org/html5/spec/common-microsyntaxes.html
http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-15.9.1.15
http://msdn.microsoft.com/en-us/library/windows/apps/ff743760(v=vs.94).aspx
http://msdn.microsoft.com/en-us/library/windows/apps/wz6stk2z(v=vs.94).aspx
http://msdn.microsoft.com/en-us/library/windows/apps/k4w173wk(v=vs.94).aspx

--- Microsoft Connect requires login to view:

IE9 had an issue where it didn't accept milliseconds correctly: (fixed in IE10)
https://connect.microsoft.com/IE/feedback/details/723740/date-parse-and-new-date-fail-on-valid-formats
still an issue in IE10:
https://connect.microsoft.com/IE/feedback/details/776783/date-parse-and-new-date-fail-on-valid-formats
  - IE team basically said *won't fix*... read below as to why..

--- Test a browser to see if the shim will be used:

http://jsbin.com/efivib/1/edit


---! Standards aren't standard until they're standard... OH SNAP!

it would seem that the ECMA folks seemed to have changed their mind on what the spec should say for ECMAScript-262 v6.0

this is very ironic because I seemed to have banged heads with someone on github about this exact detail.  It breaks 
down like this:  

iso8601 says: "Times without a timezone specification, be it a 'Z' or and actual offset, are assumed 
to be in local time.  This can be ambiguous and result in unwanted behavior unless you know that both 
the communicator and reciever are guranteed to be in the same timezone, as such a timezone should 
always be specified, even though it is optional."... or something like that, lol.

ECMAScript-262 v5.1 says: "The value of an absent time zone offset is “Z”."

ECMAScript-262 v6 says: "If the time zone offset is absent, the date-time is interpreted as a local time."

crap... well ES6 is so new it's still in "early draft" status and right now and the browsers breakdown like this:

ES5.1 compliant date parsing: chrome, mobile safari, opera
ES6.0 compliant date parsing: IE10, firefox, desktop safari


... like i said, crap.


Anyway I'm putting up a second vresion of this file that is compliant with ES6 spec, you can decide for
yourself which you would rather use... either one will "shim" the "non-comliant" versions into compliancy