-
-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES 5.1 Extended years and Date.prototype.toISOString #66
Comments
Some browser implementations (Opera) fails too Date.parse fails with extended years too. |
test case for Date.parse: Date.parse("+033658-09-27T01:46:40.000Z") === 1e15 |
Pinging @kitcambridge, who recently rewrote |
I'm on it...I originally avoided implementing extended years due to cases where |
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/UTC The UTC method differs from the Date constructor in two ways. So Date constructor can be used instead of Date.UTC with adjustment to local time, am i right? |
and why "Date.UTC would choke on them" would choke on extended years? |
I did not add support for extended years to
Here are the corresponding millisecond values produced by a native implementation of
Contrastingly, here are the values produced by my
Quite a disparity. The second reason that I did not implement extended year support is practicality. According to section 15.9.1.1 of the spec, valid ECMAScript date values (i.e., the primitive millisecond values of date objects, obtained by This implication does not hold true for extended years, however. Notice that, in the first example, |
Date.UTC(0, 0, 1) == -2208988800000; // Incorrect. |
15.9.1.1 am i right? |
@Yaffle That's why. Because the date time string components are currently converted to numbers and passed directly to |
@Yaffle Yes, you're correct. Apologies. |
also in which browser use receive: Date.parse("-283457-03-21T15:00:59.008Z") == -9007199254740992; |
@Yaffle |
Date.parse("+275760-09-13T00:00:00.000Z") === 8.64e15 - biggest correct value |
@kitcambridge in my Firefox and Safari it doesn't work |
@Yaffle Yikes, those inconsistencies aren't encouraging at all! The latest WebKit nightly builds seem to support extended years as well. Should we just patch |
I can't understand why it's impossible to support extended years in Date.parse... |
Current implementaion also fails for year between 0 and 99, It seems, there is simple workaround: |
here is my patched Date.parse with some tests (tested in IE7-9, FF 6, Opera 12, Chrome 14): |
and my patched "toISOString" |
Your implementaion is not full compatible with ES!
see http://es5.github.com/#x15.9.1.15
when year < 0 or year > 9999
6 digits format with sign for year < 0 should be used
test case:
alert(new Date(-1,1,0).toISOString()); // alerts "0-1-01-30T18:00:00.000Z"
The text was updated successfully, but these errors were encountered: