- Fix SystemTimeToTzSpecificLocalTime. +378 passed tests

svn path=/trunk/; revision=38366
This commit is contained in:
Dmitry Chapyshev 2008-12-27 05:31:06 +00:00
parent 51dc30a02c
commit 0e4778a15d

View file

@ -141,8 +141,6 @@ static DWORD TIME_CompTimeZoneID ( const TIME_ZONE_INFORMATION *pTZinfo,
SYSTEMTIME SysTime; SYSTEMTIME SysTime;
FILETIME ftTemp; FILETIME ftTemp;
ZeroMemory (&SysTime, sizeof (SysTime));
if (pTZinfo->DaylightDate.wMonth != 0) if (pTZinfo->DaylightDate.wMonth != 0)
{ {
/* if year is 0 then date is in day-of-week format, otherwise /* if year is 0 then date is in day-of-week format, otherwise
@ -162,7 +160,7 @@ static DWORD TIME_CompTimeZoneID ( const TIME_ZONE_INFORMATION *pTZinfo,
if (!islocal) { if (!islocal) {
FILETIME2LL( lpFileTime, llTime ); FILETIME2LL( lpFileTime, llTime );
llTime -= ( pTZinfo->Bias + pTZinfo->DaylightBias ) llTime -= ( pTZinfo->Bias + pTZinfo->DaylightBias )
* (LONGLONG) TICKSPERMIN; * (LONGLONG)TICKSPERMIN;
LL2FILETIME( llTime, &ftTemp) LL2FILETIME( llTime, &ftTemp)
lpFileTime = &ftTemp; lpFileTime = &ftTemp;
} }
@ -178,7 +176,7 @@ static DWORD TIME_CompTimeZoneID ( const TIME_ZONE_INFORMATION *pTZinfo,
if (!islocal) { if (!islocal) {
llTime -= ( pTZinfo->StandardBias - pTZinfo->DaylightBias ) llTime -= ( pTZinfo->StandardBias - pTZinfo->DaylightBias )
* (LONGLONG) TICKSPERMIN; * (LONGLONG)TICKSPERMIN;
LL2FILETIME( llTime, &ftTemp) LL2FILETIME( llTime, &ftTemp)
FileTimeToSystemTime(lpFileTime, &SysTime); FileTimeToSystemTime(lpFileTime, &SysTime);
} }
@ -620,29 +618,38 @@ SystemTimeToTzSpecificLocalTime(
LPSYSTEMTIME lpLocalTime LPSYSTEMTIME lpLocalTime
) )
{ {
TIME_ZONE_INFORMATION TimeZoneInformation; TIME_ZONE_INFORMATION TzInfo;
LPTIME_ZONE_INFORMATION lpTzInfo; FILETIME FileTime;
LARGE_INTEGER FileTime; LONGLONG llTime;
LONG lBias;
if (!lpTimeZoneInformation) if (lpTimeZoneInformation != NULL)
{ {
GetTimeZoneInformation(&TimeZoneInformation); TzInfo = *lpTimeZoneInformation;
lpTzInfo = &TimeZoneInformation;
} }
else else
lpTzInfo = (LPTIME_ZONE_INFORMATION)lpTimeZoneInformation; {
if (GetTimeZoneInformation(&TzInfo) == TIME_ZONE_ID_INVALID)
return FALSE;
}
if (!lpUniversalTime) if (!lpUniversalTime || !lpLocalTime)
return FALSE; return FALSE;
if (!lpLocalTime) if (!SystemTimeToFileTime(lpUniversalTime, &FileTime))
return FALSE; return FALSE;
SystemTimeToFileTime(lpUniversalTime, (PFILETIME)&FileTime); FILETIME2LL(&FileTime, llTime)
FileTime.QuadPart -= (lpTzInfo->Bias * TICKSPERMIN);
FileTimeToSystemTime((PFILETIME)&FileTime, lpLocalTime);
return TRUE; if (!TIME_GetTimezoneBias(&TzInfo, &FileTime, FALSE, &lBias))
return FALSE;
/* convert minutes to 100-nanoseconds-ticks */
llTime -= (LONGLONG)lBias * TICKSPERMIN;
LL2FILETIME( llTime, &FileTime)
return FileTimeToSystemTime(&FileTime, lpLocalTime);
} }