mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 12:19:49 +00:00
kernel32: Fixed TIME_CompTimeZoneID behavior on dates close to New Year's Eve.
This commit is contained in:
parent
b057c5f140
commit
e5a25ec5c5
2 changed files with 48 additions and 13 deletions
|
@ -336,6 +336,29 @@ static void test_GetTimeZoneInformation(void)
|
|||
l_time = system_time_to_minutes(&local);
|
||||
ok(l_time - s_time == diff, "got %d, expected %d\n",
|
||||
(LONG)(l_time - s_time), diff);
|
||||
|
||||
/* test 23:01, 31st of December date */
|
||||
memset(&tzinfo, 0, sizeof(tzinfo));
|
||||
tzinfo.StandardDate.wMonth = 10;
|
||||
tzinfo.StandardDate.wDay = 5;
|
||||
tzinfo.StandardDate.wHour = 2;
|
||||
tzinfo.StandardDate.wMinute = 0;
|
||||
tzinfo.DaylightDate.wMonth = 4;
|
||||
tzinfo.DaylightDate.wDay = 1;
|
||||
tzinfo.DaylightDate.wHour = 2;
|
||||
tzinfo.Bias = 0;
|
||||
tzinfo.StandardBias = 0;
|
||||
tzinfo.DaylightBias = -60;
|
||||
utc.wYear = 2012;
|
||||
utc.wMonth = 12;
|
||||
utc.wDay = 31;
|
||||
utc.wHour = 23;
|
||||
utc.wMinute = 1;
|
||||
res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &local);
|
||||
ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
|
||||
ok(local.wYear==2012 && local.wMonth==12 && local.wDay==31 && local.wHour==23 && local.wMinute==1,
|
||||
"got (%d-%d-%d %02d:%02d), expected (2012-12-31 23:01)\n",
|
||||
local.wYear, local.wMonth, local.wDay, local.wHour, local.wMinute);
|
||||
}
|
||||
|
||||
static void test_FileTimeToSystemTime(void)
|
||||
|
|
|
@ -152,7 +152,7 @@ static int TIME_DayLightCompareDate( const SYSTEMTIME *date,
|
|||
static DWORD TIME_CompTimeZoneID ( const TIME_ZONE_INFORMATION *pTZinfo,
|
||||
FILETIME *lpFileTime, BOOL islocal )
|
||||
{
|
||||
int ret;
|
||||
int ret, year;
|
||||
BOOL beforeStandardDate, afterDaylightDate;
|
||||
DWORD retval = TIME_ZONE_ID_INVALID;
|
||||
LONGLONG llTime = 0; /* initialized to prevent gcc complaining */
|
||||
|
@ -177,20 +177,29 @@ static DWORD TIME_CompTimeZoneID ( const TIME_ZONE_INFORMATION *pTZinfo,
|
|||
|
||||
if (!islocal) {
|
||||
FILETIME2LL( lpFileTime, llTime );
|
||||
llTime -= ( pTZinfo->Bias + pTZinfo->DaylightBias )
|
||||
* (LONGLONG)600000000;
|
||||
llTime -= pTZinfo->Bias * (LONGLONG)600000000;
|
||||
LL2FILETIME( llTime, &ftTemp)
|
||||
lpFileTime = &ftTemp;
|
||||
}
|
||||
|
||||
FileTimeToSystemTime(lpFileTime, &SysTime);
|
||||
|
||||
/* check for daylight savings */
|
||||
ret = TIME_DayLightCompareDate( &SysTime, &pTZinfo->StandardDate);
|
||||
if (ret == -2)
|
||||
return TIME_ZONE_ID_INVALID;
|
||||
year = SysTime.wYear;
|
||||
|
||||
beforeStandardDate = ret < 0;
|
||||
if (!islocal) {
|
||||
llTime -= pTZinfo->DaylightBias * (LONGLONG)600000000;
|
||||
LL2FILETIME( llTime, &ftTemp)
|
||||
FileTimeToSystemTime(lpFileTime, &SysTime);
|
||||
}
|
||||
|
||||
/* check for daylight savings */
|
||||
if(year == SysTime.wYear) {
|
||||
ret = TIME_DayLightCompareDate( &SysTime, &pTZinfo->StandardDate);
|
||||
if (ret == -2)
|
||||
return TIME_ZONE_ID_INVALID;
|
||||
|
||||
beforeStandardDate = ret < 0;
|
||||
} else
|
||||
beforeStandardDate = SysTime.wYear < year;
|
||||
|
||||
if (!islocal) {
|
||||
llTime -= ( pTZinfo->StandardBias - pTZinfo->DaylightBias )
|
||||
|
@ -199,11 +208,14 @@ static DWORD TIME_CompTimeZoneID ( const TIME_ZONE_INFORMATION *pTZinfo,
|
|||
FileTimeToSystemTime(lpFileTime, &SysTime);
|
||||
}
|
||||
|
||||
ret = TIME_DayLightCompareDate( &SysTime, &pTZinfo->DaylightDate);
|
||||
if (ret == -2)
|
||||
return TIME_ZONE_ID_INVALID;
|
||||
if(year == SysTime.wYear) {
|
||||
ret = TIME_DayLightCompareDate( &SysTime, &pTZinfo->DaylightDate);
|
||||
if (ret == -2)
|
||||
return TIME_ZONE_ID_INVALID;
|
||||
|
||||
afterDaylightDate = ret >= 0;
|
||||
afterDaylightDate = ret >= 0;
|
||||
} else
|
||||
afterDaylightDate = SysTime.wYear > year;
|
||||
|
||||
retval = TIME_ZONE_ID_STANDARD;
|
||||
if( pTZinfo->DaylightDate.wMonth < pTZinfo->StandardDate.wMonth ) {
|
||||
|
|
Loading…
Reference in a new issue