Reviewers: Mads Ager,

Description:
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.


Please review this at http://codereview.chromium.org/1075016

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/date.js
  M     src/macros.py
  M     test/mjsunit/date.js


Index: test/mjsunit/date.js
===================================================================
--- test/mjsunit/date.js        (revision 4222)
+++ test/mjsunit/date.js        (working copy)
@@ -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()));
Index: src/macros.py
===================================================================
--- src/macros.py       (revision 4222)
+++ src/macros.py       (working copy)
@@ -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());
Index: src/date.js
===================================================================
--- src/date.js (revision 4222)
+++ src/date.js (working copy)
@@ -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;
     }



--
v8-dev mailing list
v8-dev@googlegroups.com
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.

Reply via email to