Reviewers: rossberg,

Message:
PTAL

Description:
Fix Date DST computation.

BUG=v8:3116
LOG=N

Please review this at https://codereview.chromium.org/525363002/

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

Affected files (+11, -3 lines):
  M src/date.h


Index: src/date.h
diff --git a/src/date.h b/src/date.h
index 633dd9f38e721668abbc80f9c262ef5111e44de6..2e5ce39a042c791de83a4446c960225a4784cf61 100644
--- a/src/date.h
+++ b/src/date.h
@@ -103,14 +103,22 @@ class DateCache {
   }

   // ECMA 262 - 15.9.1.9
+  // LocalTime(t) = t + LocalTZA + DaylightSavingTA(t)
+  // ECMA 262 assumes that DaylightSavingTA is computed using UTC time,
+  // but we fetch DST from OS using local time, therefore we need:
+  // LocalTime(t) = t + LocalTZA + DaylightSavingTA(t + LocalTZA).
   int64_t ToLocal(int64_t time_ms) {
- return time_ms + LocalOffsetInMs() + DaylightSavingsOffsetInMs(time_ms);
+    time_ms += LocalOffsetInMs();
+    return time_ms + DaylightSavingsOffsetInMs(time_ms);
   }

   // ECMA 262 - 15.9.1.9
+  // UTC(t) = t - LocalTZA - DaylightSavingTA(t - LocalTZA)
+  // ECMA 262 assumes that DaylightSavingTA is computed using UTC time,
+  // but we fetch DST from OS using local time, therefore we need:
+  // UTC(t) = t - LocalTZA - DaylightSavingTA(t).
   int64_t ToUTC(int64_t time_ms) {
-    time_ms -= LocalOffsetInMs();
-    return time_ms - DaylightSavingsOffsetInMs(time_ms);
+ return time_ms - LocalOffsetInMs() - DaylightSavingsOffsetInMs(time_ms);
   }




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to