summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-03-30 12:55:27 +0100
committerBen Murdoch <benm@google.com>2010-03-31 13:34:38 +0100
commitd69d2e30f295acb0d25771f412ca271869d0ba43 (patch)
treee756e8cc6b6306bf908a4e50e14536b40ea3c130
parent74b3c146906ea120f97974b0e16aec75c17ebf66 (diff)
downloadandroid_external_v8-d69d2e30f295acb0d25771f412ca271869d0ba43.tar.gz
android_external_v8-d69d2e30f295acb0d25771f412ca271869d0ba43.tar.bz2
android_external_v8-d69d2e30f295acb0d25771f412ca271869d0ba43.zip
If the timezone changes, then we must invalidate the cached time values we have stored to avoid
a mismatch of the numerical timezone offset and the timezone string. This change should go to the upstream V8 project. Fix b/2529851 Change-Id: Ibc929ae5cbc2f7dd2d9ab1ee9b43faec74f540a1
-rw-r--r--src/date.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/date.js b/src/date.js
index 7d8f4588..b4027c13 100644
--- a/src/date.js
+++ b/src/date.js
@@ -613,6 +613,20 @@ function TimeString(time) {
function LocalTimezoneString(time) {
+ var old_timezone = timezone_cache_timezone;
+ var timezone = LocalTimezone(time);
+ if (old_timezone && timezone != old_timezone) {
+ // If the timezone string has changed from the one that we cached,
+ // the local time offset may now be wrong. So we need to update it
+ // and try again.
+ local_time_offset = %DateLocalTimeOffset();
+ // We also need to invalidate the DST cache as the new timezone may have
+ // different DST times.
+ var dst_cache = DST_offset_cache;
+ dst_cache.start = 0;
+ dst_cache.end = -1;
+ }
+
var timezoneOffset =
(local_time_offset + DaylightSavingsOffset(time)) / msPerMinute;
var sign = (timezoneOffset >= 0) ? 1 : -1;
@@ -620,7 +634,7 @@ function LocalTimezoneString(time) {
var min = FLOOR((sign * timezoneOffset)%60);
var gmt = ' GMT' + ((sign == 1) ? '+' : '-') +
TwoDigitString(hours) + TwoDigitString(min);
- return gmt + ' (' + LocalTimezone(time) + ')';
+ return gmt + ' (' + timezone + ')';
}