Title: [174377] trunk/Source/WTF
- Revision
- 174377
- Author
- [email protected]
- Date
- 2014-10-06 18:15:19 -0700 (Mon, 06 Oct 2014)
Log Message
[Win] DateMath's calculateUTFOffset does not account for DST.
https://bugs.webkit.org/show_bug.cgi?id=137458
<rdar://problem/18559172>
Reviewed by Geoffrey Garen.
Check the return value of GetTimeZoneInformation and use the
proper bias against UTC (depending on whether we are in daylight
savings time, or standard time).
Also, handle possible error cases in the FileTimeToSystemTime
and SystemTimeToTzSpecificLocalTime, rather than using potentially
uninitialized values.
* wtf/DateMath.cpp:
(WTF::calculateUTCOffset): Use proper daylight-savings-time state.
(WTF::calculateDSTOffset): Avoid uninitialized data due to failing
API calls.
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (174376 => 174377)
--- trunk/Source/WTF/ChangeLog 2014-10-07 01:10:04 UTC (rev 174376)
+++ trunk/Source/WTF/ChangeLog 2014-10-07 01:15:19 UTC (rev 174377)
@@ -1,3 +1,24 @@
+2014-10-06 Brent Fulgham <[email protected]>
+
+ [Win] DateMath's calculateUTFOffset does not account for DST.
+ https://bugs.webkit.org/show_bug.cgi?id=137458
+ <rdar://problem/18559172>
+
+ Reviewed by Geoffrey Garen.
+
+ Check the return value of GetTimeZoneInformation and use the
+ proper bias against UTC (depending on whether we are in daylight
+ savings time, or standard time).
+
+ Also, handle possible error cases in the FileTimeToSystemTime
+ and SystemTimeToTzSpecificLocalTime, rather than using potentially
+ uninitialized values.
+
+ * wtf/DateMath.cpp:
+ (WTF::calculateUTCOffset): Use proper daylight-savings-time state.
+ (WTF::calculateDSTOffset): Avoid uninitialized data due to failing
+ API calls.
+
2014-10-06 Christophe Dumez <[email protected]>
Add is<>() / downcast<>() support for RenderObject subclasses
Modified: trunk/Source/WTF/wtf/DateMath.cpp (174376 => 174377)
--- trunk/Source/WTF/wtf/DateMath.cpp 2014-10-07 01:10:04 UTC (rev 174376)
+++ trunk/Source/WTF/wtf/DateMath.cpp 2014-10-07 01:15:19 UTC (rev 174377)
@@ -367,8 +367,16 @@
{
#if OS(WINDOWS)
TIME_ZONE_INFORMATION timeZoneInformation;
- GetTimeZoneInformation(&timeZoneInformation);
- int32_t bias = timeZoneInformation.Bias + timeZoneInformation.StandardBias;
+ DWORD rc = ::GetTimeZoneInformation(&timeZoneInformation);
+ if (rc == TIME_ZONE_ID_INVALID)
+ return 0;
+
+ int32_t bias = 0;
+ if (rc == TIME_ZONE_ID_DAYLIGHT)
+ bias = timeZoneInformation.Bias + timeZoneInformation.DaylightBias;
+ else if (rc == TIME_ZONE_ID_STANDARD || rc == TIME_ZONE_ID_UNKNOWN)
+ bias = timeZoneInformation.Bias + timeZoneInformation.StandardBias;
+
return -bias * 60 * 1000;
#else
time_t localTime = time(0);
@@ -426,8 +434,10 @@
FILETIME utcFileTime;
UnixTimeToFileTime(localTime, &utcFileTime);
SYSTEMTIME utcSystemTime, localSystemTime;
- FileTimeToSystemTime(&utcFileTime, &utcSystemTime);
- SystemTimeToTzSpecificLocalTime(0, &utcSystemTime, &localSystemTime);
+ if (!::FileTimeToSystemTime(&utcFileTime, &utcSystemTime))
+ return 0;
+ if (!::SystemTimeToTzSpecificLocalTime(nullptr, &utcSystemTime, &localSystemTime))
+ return 0;
double offsetTime = (localTime * msPerSecond) + utcOffset;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes