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); |
} |