Revision: 24922
Author: [email protected]
Date: Tue Oct 28 08:55:28 2014 UTC
Log: Windows: use SystemTimeToTzSpecificLocalTime instead of
localtime_s.
The localtime_s function produces incorrect results for russian time zone.
BUG=chromium:417640
LOG=Y
[email protected]
Review URL: https://codereview.chromium.org/654843012
https://code.google.com/p/v8/source/detail?r=24922
Modified:
/branches/bleeding_edge/src/base/platform/platform-win32.cc
=======================================
--- /branches/bleeding_edge/src/base/platform/platform-win32.cc Mon Oct 20
12:04:22 2014 UTC
+++ /branches/bleeding_edge/src/base/platform/platform-win32.cc Tue Oct 28
08:55:28 2014 UTC
@@ -344,6 +344,14 @@
DWORD elapsed = ticks_now - init_ticks;
this->time_.t_ = init_time.t_ + (static_cast<int64_t>(elapsed) * 10000);
}
+
+
+int64_t FileTimeToInt64(FILETIME ft) {
+ ULARGE_INTEGER result;
+ result.LowPart = ft.dwLowDateTime;
+ result.HighPart = ft.dwHighDateTime;
+ return static_cast<int64_t>(result.QuadPart);
+}
// Return the local timezone offset in milliseconds east of UTC. This
@@ -352,35 +360,12 @@
// Also, adding the time-zone offset to the input must not overflow.
// The function EquivalentTime() in date.js guarantees this.
int64_t Win32Time::LocalOffset(TimezoneCache* cache) {
- cache->InitializeIfNeeded();
-
- Win32Time rounded_to_second(*this);
- rounded_to_second.t() = rounded_to_second.t() / 1000 / kTimeScaler *
- 1000 * kTimeScaler;
- // Convert to local time using POSIX localtime function.
- // Windows XP Service Pack 3 made SystemTimeToTzSpecificLocalTime()
- // very slow. Other browsers use localtime().
-
- // Convert from JavaScript milliseconds past 1/1/1970 0:00:00 to
- // POSIX seconds past 1/1/1970 0:00:00.
- double unchecked_posix_time = rounded_to_second.ToJSTime() / 1000;
- if (unchecked_posix_time > INT_MAX || unchecked_posix_time < 0) {
- return 0;
- }
- // Because _USE_32BIT_TIME_T is defined, time_t is a 32-bit int.
- time_t posix_time = static_cast<time_t>(unchecked_posix_time);
-
- // Convert to local time, as struct with fields for day, hour, year, etc.
- tm posix_local_time_struct;
- if (localtime_s(&posix_local_time_struct, &posix_time)) return 0;
-
- if (posix_local_time_struct.tm_isdst > 0) {
- return (cache->tzinfo_.Bias + cache->tzinfo_.DaylightBias) *
-kMsPerMinute;
- } else if (posix_local_time_struct.tm_isdst == 0) {
- return (cache->tzinfo_.Bias + cache->tzinfo_.StandardBias) *
-kMsPerMinute;
- } else {
- return cache->tzinfo_.Bias * -kMsPerMinute;
- }
+ FILETIME local;
+ SYSTEMTIME system_utc, system_local;
+ FileTimeToSystemTime(&time_.ft_, &system_utc);
+ SystemTimeToTzSpecificLocalTime(NULL, &system_utc, &system_local);
+ SystemTimeToFileTime(&system_local, &local);
+ return (FileTimeToInt64(local) - FileTimeToInt64(time_.ft_)) /
kTimeScaler;
}
--
--
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.