Revision: 4232
Author: [email protected]
Date: Tue Mar 23 07:47:02 2010
Log: Fix bug http://code.google.com/p/v8/issues/detail?id=659. Move the
limits check for date before the time zone offset is applied.
Review URL: http://codereview.chromium.org/1075016
http://code.google.com/p/v8/source/detail?r=4232
Modified:
/branches/bleeding_edge/src/date.js
/branches/bleeding_edge/src/macros.py
/branches/bleeding_edge/test/mjsunit/date.js
=======================================
--- /branches/bleeding_edge/src/date.js Tue Mar 23 04:40:38 2010
+++ /branches/bleeding_edge/src/date.js Tue Mar 23 07:47:02 2010
@@ -223,6 +223,10 @@
}
function LocalTimeNoCheck(time) {
+ if (time < -MAX_TIME_MS || time > MAX_TIME_MS) {
+ return $NaN;
+ }
+
// Inline the DST offset cache checks for speed.
var cache = DST_offset_cache;
if (cache.start <= time && time <= cache.end) {
@@ -265,8 +269,7 @@
function YearFromTime(t) {
if (t !== ymd_from_time_cached_time) {
- // Limits according to ECMA 262 15.9.1.1
- if (!$isFinite(t) || t < -8640000000000000 || t > 8640000000000000) {
+ if (!$isFinite(t)) {
return $NaN;
}
@@ -279,8 +282,7 @@
function MonthFromTime(t) {
if (t !== ymd_from_time_cached_time) {
- // Limits according to ECMA 262 15.9.1.1
- if (!$isFinite(t) || t < -8640000000000000 || t > 8640000000000000) {
+ if (!$isFinite(t)) {
return $NaN;
}
%DateYMDFromTime(t, ymd_from_time_cache);
@@ -292,8 +294,7 @@
function DateFromTime(t) {
if (t !== ymd_from_time_cached_time) {
- // Limits according to ECMA 262 15.9.1.1
- if (!$isFinite(t) || t < -8640000000000000 || t > 8640000000000000) {
+ if (!$isFinite(t)) {
return $NaN;
}
=======================================
--- /branches/bleeding_edge/src/macros.py Tue Mar 23 04:40:38 2010
+++ /branches/bleeding_edge/src/macros.py Tue Mar 23 07:47:02 2010
@@ -128,6 +128,9 @@
# REGEXP_NUMBER_OF_CAPTURES
macro NUMBER_OF_CAPTURES(array) = ((array)[0]);
+# Limit according to ECMA 262 15.9.1.1
+const MAX_TIME_MS = 8640000000000000;
+
# Gets the value of a Date object. If arg is not a Date object
# a type error is thrown.
macro DATE_VALUE(arg) = (%_ClassOf(arg) === 'Date' ? %_ValueOf(arg) :
ThrowDateTypeError());
=======================================
--- /branches/bleeding_edge/test/mjsunit/date.js Wed Mar 3 06:19:04 2010
+++ /branches/bleeding_edge/test/mjsunit/date.js Tue Mar 23 07:47:02 2010
@@ -46,12 +46,18 @@
var dMax = new Date(8.64e15);
assertEquals(8.64e15, dMax.getTime());
+assertEquals(275760, dMax.getFullYear());
+assertEquals(8, dMax.getMonth());
+assertEquals(13, dMax.getDate());
var dOverflow = new Date(8.64e15+1);
assertTrue(isNaN(dOverflow.getTime()));
var dMin = new Date(-8.64e15);
assertEquals(-8.64e15, dMin.getTime());
+assertEquals(-271821, dMin.getFullYear());
+assertEquals(3, dMin.getMonth());
+assertEquals(20, dMin.getDate());
var dUnderflow = new Date(-8.64e15-1);
assertTrue(isNaN(dUnderflow.getTime()));
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
To unsubscribe from this group, send email to v8-dev+unsubscribegooglegroups.com or reply
to this email with the words "REMOVE ME" as the subject.