Author: dchapyshev
Date: Fri Dec 26 23:31:06 2008
New Revision: 38366
URL:
http://svn.reactos.org/svn/reactos?rev=38366&view=rev
Log:
- Fix SystemTimeToTzSpecificLocalTime. +378 passed tests
Modified:
trunk/reactos/dll/win32/kernel32/misc/time.c
Modified: trunk/reactos/dll/win32/kernel32/misc/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/ti…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/time.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/time.c [iso-8859-1] Fri Dec 26 23:31:06 2008
@@ -141,8 +141,6 @@
SYSTEMTIME SysTime;
FILETIME ftTemp;
- ZeroMemory (&SysTime, sizeof (SysTime));
-
if (pTZinfo->DaylightDate.wMonth != 0)
{
/* if year is 0 then date is in day-of-week format, otherwise
@@ -162,7 +160,7 @@
if (!islocal) {
FILETIME2LL( lpFileTime, llTime );
llTime -= ( pTZinfo->Bias + pTZinfo->DaylightBias )
- * (LONGLONG) TICKSPERMIN;
+ * (LONGLONG)TICKSPERMIN;
LL2FILETIME( llTime, &ftTemp)
lpFileTime = &ftTemp;
}
@@ -178,7 +176,7 @@
if (!islocal) {
llTime -= ( pTZinfo->StandardBias - pTZinfo->DaylightBias )
- * (LONGLONG) TICKSPERMIN;
+ * (LONGLONG)TICKSPERMIN;
LL2FILETIME( llTime, &ftTemp)
FileTimeToSystemTime(lpFileTime, &SysTime);
}
@@ -620,29 +618,38 @@
LPSYSTEMTIME lpLocalTime
)
{
- TIME_ZONE_INFORMATION TimeZoneInformation;
- LPTIME_ZONE_INFORMATION lpTzInfo;
- LARGE_INTEGER FileTime;
-
- if (!lpTimeZoneInformation)
+ TIME_ZONE_INFORMATION TzInfo;
+ FILETIME FileTime;
+ LONGLONG llTime;
+ LONG lBias;
+
+ if (lpTimeZoneInformation != NULL)
{
- GetTimeZoneInformation(&TimeZoneInformation);
- lpTzInfo = &TimeZoneInformation;
+ TzInfo = *lpTimeZoneInformation;
}
else
- lpTzInfo = (LPTIME_ZONE_INFORMATION)lpTimeZoneInformation;
-
- if (!lpUniversalTime)
+ {
+ if (GetTimeZoneInformation(&TzInfo) == TIME_ZONE_ID_INVALID)
+ return FALSE;
+ }
+
+ if (!lpUniversalTime || !lpLocalTime)
return FALSE;
- if (!lpLocalTime)
- return FALSE;
-
- SystemTimeToFileTime(lpUniversalTime, (PFILETIME)&FileTime);
- FileTime.QuadPart -= (lpTzInfo->Bias * TICKSPERMIN);
- FileTimeToSystemTime((PFILETIME)&FileTime, lpLocalTime);
-
- return TRUE;
+ if (!SystemTimeToFileTime(lpUniversalTime, &FileTime))
+ return FALSE;
+
+ FILETIME2LL(&FileTime, llTime)
+
+ 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);
}