Commit a6d11cd7 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

[Win] Some JavaScript date tests are failing.

https://bugs.webkit.org/show_bug.cgi?id=124946

Patch by peavo@outlook.com <peavo@outlook.com> on 2013-11-30
Reviewed by Brent Fulgham.

Use native Win32 api functions to compute Daylight saving time offset.

* wtf/DateMath.cpp:
(WTF::UnixTimeToFileTime): Added method to calculate Win32 specific struct FILETIME from time_t value.
(WTF::calculateDSTOffset): Use native Win32 api functions to compute Daylight saving time offset.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159892 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a9c75620
2013-11-30 peavo@outlook.com <peavo@outlook.com>
[Win] Some JavaScript date tests are failing.
https://bugs.webkit.org/show_bug.cgi?id=124946
Reviewed by Brent Fulgham.
Use native Win32 api functions to compute Daylight saving time offset.
* wtf/DateMath.cpp:
(WTF::UnixTimeToFileTime): Added method to calculate Win32 specific struct FILETIME from time_t value.
(WTF::calculateDSTOffset): Use native Win32 api functions to compute Daylight saving time offset.
2013-11-28 Thiago de Barros Lacerda <thiago.lacerda@openbossa.org>
Nix Upstream: Updating Nix WTF files
......
......@@ -411,6 +411,19 @@ static int32_t calculateUTCOffset()
#endif
}
#if OS(WINDOWS)
// Code taken from http://support.microsoft.com/kb/167296
static void UnixTimeToFileTime(time_t t, LPFILETIME pft)
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = Int32x32To64(t, 10000000) + 116444736000000000;
pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32;
}
#endif
/*
* Get the DST offset for the time passed in.
*/
......@@ -420,6 +433,22 @@ static double calculateDSTOffset(time_t localTime, double utcOffset)
UNUSED_PARAM(localTime);
UNUSED_PARAM(utcOffset);
return 0;
#elif OS(WINDOWS)
FILETIME utcFileTime;
UnixTimeToFileTime(localTime, &utcFileTime);
SYSTEMTIME utcSystemTime, localSystemTime;
FileTimeToSystemTime(&utcFileTime, &utcSystemTime);
SystemTimeToTzSpecificLocalTime(0, &utcSystemTime, &localSystemTime);
double offsetTime = (localTime * msPerSecond) + utcOffset;
// Offset from UTC but doesn't include DST obviously
int offsetHour = msToHours(offsetTime);
int offsetMinute = msToMinutes(offsetTime);
double diff = ((localSystemTime.wHour - offsetHour) * secondsPerHour) + ((localSystemTime.wMinute - offsetMinute) * 60);
return diff * msPerSecond;
#else
//input is UTC so we have to shift back to local time to determine DST thus the + getUTCOffset()
double offsetTime = (localTime * msPerSecond) + utcOffset;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment