From a76ef05c9057e7e5d712d2c3626b90df10a12769 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Wed, 29 Aug 2007 18:56:52 +0900 Subject: [PATCH] ntdll: Do not leave not initialized cached timezone information if a timezone doesn't have daylight saving rules. --- dlls/kernel32/tests/time.c | 6 ++- dlls/ntdll/time.c | 88 +++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 46 deletions(-) diff --git a/dlls/kernel32/tests/time.c b/dlls/kernel32/tests/time.c index cf557abf032..eaf4f7d200b 100644 --- a/dlls/kernel32/tests/time.c +++ b/dlls/kernel32/tests/time.c @@ -21,6 +21,7 @@ #include "wine/test.h" #include "winbase.h" +#include "winnls.h" static BOOL (WINAPI *pTzSpecificLocalTimeToSystemTime)(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME); static BOOL (WINAPI *pSystemTimeToTzSpecificLocalTime)(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME); @@ -221,6 +222,7 @@ static LONG get_tz_bias(const TIME_ZONE_INFORMATION *tzinfo, DWORD tz_id) static void test_GetTimeZoneInformation(void) { + char std_name[32], dlt_name[32]; TIME_ZONE_INFORMATION tzinfo, tzinfo1; BOOL res; DWORD tz_id; @@ -252,7 +254,9 @@ static void test_GetTimeZoneInformation(void) (tz_id == TIME_ZONE_ID_UNKNOWN ? "TIME_ZONE_ID_UNKNOWN" : "TIME_ZONE_ID_INVALID"))); - trace("bias %d\n", tzinfo.Bias); + WideCharToMultiByte(CP_ACP, 0, tzinfo.StandardName, -1, std_name, sizeof(std_name), NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, tzinfo.DaylightName, -1, dlt_name, sizeof(dlt_name), NULL, NULL); + trace("bias %d, %s - %s\n", tzinfo.Bias, std_name, dlt_name); trace("standard (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n", tzinfo.StandardDate.wDay, tzinfo.StandardDate.wMonth, tzinfo.StandardDate.wYear, tzinfo.StandardDate.wDayOfWeek, diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c index 36b1ef58f1b..957d587a88e 100644 --- a/dlls/ntdll/time.c +++ b/dlls/ntdll/time.c @@ -787,54 +787,52 @@ static int init_tz_info(RTL_TIME_ZONE_INFORMATION *tzi) TRACE("dlt: %s", ctime(&dlt)); if (dlt == std || !dlt || !std) - { - RtlLeaveCriticalSection( &TIME_tz_section ); TRACE("there is no daylight saving rules in this time zone\n"); - return 0; + else + { + tmp = dlt - tzi->Bias * 60; + tm = gmtime(&tmp); + TRACE("dlt gmtime: %s", asctime(tm)); + + tzi->DaylightBias = -60; + tzi->DaylightDate.wYear = tm->tm_year + 1900; + tzi->DaylightDate.wMonth = tm->tm_mon + 1; + tzi->DaylightDate.wDayOfWeek = tm->tm_wday; + tzi->DaylightDate.wDay = tm->tm_mday; + tzi->DaylightDate.wHour = tm->tm_hour; + tzi->DaylightDate.wMinute = tm->tm_min; + tzi->DaylightDate.wSecond = tm->tm_sec; + tzi->DaylightDate.wMilliseconds = 0; + + TRACE("daylight (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n", + tzi->DaylightDate.wDay, tzi->DaylightDate.wMonth, + tzi->DaylightDate.wYear, tzi->DaylightDate.wDayOfWeek, + tzi->DaylightDate.wHour, tzi->DaylightDate.wMinute, + tzi->DaylightDate.wSecond, tzi->DaylightDate.wMilliseconds, + tzi->DaylightBias); + + tmp = std - tzi->Bias * 60 - tzi->DaylightBias * 60; + tm = gmtime(&tmp); + TRACE("std gmtime: %s", asctime(tm)); + + tzi->StandardBias = 0; + tzi->StandardDate.wYear = tm->tm_year + 1900; + tzi->StandardDate.wMonth = tm->tm_mon + 1; + tzi->StandardDate.wDayOfWeek = tm->tm_wday; + tzi->StandardDate.wDay = tm->tm_mday; + tzi->StandardDate.wHour = tm->tm_hour; + tzi->StandardDate.wMinute = tm->tm_min; + tzi->StandardDate.wSecond = tm->tm_sec; + tzi->StandardDate.wMilliseconds = 0; + + TRACE("standard (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n", + tzi->StandardDate.wDay, tzi->StandardDate.wMonth, + tzi->StandardDate.wYear, tzi->StandardDate.wDayOfWeek, + tzi->StandardDate.wHour, tzi->StandardDate.wMinute, + tzi->StandardDate.wSecond, tzi->StandardDate.wMilliseconds, + tzi->StandardBias); } - tmp = dlt - tzi->Bias * 60; - tm = gmtime(&tmp); - TRACE("dlt gmtime: %s", asctime(tm)); - - tzi->DaylightBias = -60; - tzi->DaylightDate.wYear = tm->tm_year + 1900; - tzi->DaylightDate.wMonth = tm->tm_mon + 1; - tzi->DaylightDate.wDayOfWeek = tm->tm_wday; - tzi->DaylightDate.wDay = tm->tm_mday; - tzi->DaylightDate.wHour = tm->tm_hour; - tzi->DaylightDate.wMinute = tm->tm_min; - tzi->DaylightDate.wSecond = tm->tm_sec; - tzi->DaylightDate.wMilliseconds = 0; - - TRACE("daylight (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n", - tzi->DaylightDate.wDay, tzi->DaylightDate.wMonth, - tzi->DaylightDate.wYear, tzi->DaylightDate.wDayOfWeek, - tzi->DaylightDate.wHour, tzi->DaylightDate.wMinute, - tzi->DaylightDate.wSecond, tzi->DaylightDate.wMilliseconds, - tzi->DaylightBias); - - tmp = std - tzi->Bias * 60 - tzi->DaylightBias * 60; - tm = gmtime(&tmp); - TRACE("std gmtime: %s", asctime(tm)); - - tzi->StandardBias = 0; - tzi->StandardDate.wYear = tm->tm_year + 1900; - tzi->StandardDate.wMonth = tm->tm_mon + 1; - tzi->StandardDate.wDayOfWeek = tm->tm_wday; - tzi->StandardDate.wDay = tm->tm_mday; - tzi->StandardDate.wHour = tm->tm_hour; - tzi->StandardDate.wMinute = tm->tm_min; - tzi->StandardDate.wSecond = tm->tm_sec; - tzi->StandardDate.wMilliseconds = 0; - - TRACE("standard (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n", - tzi->StandardDate.wDay, tzi->StandardDate.wMonth, - tzi->StandardDate.wYear, tzi->StandardDate.wDayOfWeek, - tzi->StandardDate.wHour, tzi->StandardDate.wMinute, - tzi->StandardDate.wSecond, tzi->StandardDate.wMilliseconds, - tzi->StandardBias); - find_reg_tz_info(tzi); cached_tzi = *tzi;