ntdll: Take into account timezone bias changes when detecting daylight saving rules.
Dmitry Timoshkov
dmitry at baikal.ru
Tue Oct 18 01:34:05 CDT 2011
This patch should fix the problem reported in the bug 28560.
---
dlls/ntdll/time.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c
index 5a120f4..d233f23 100644
--- a/dlls/ntdll/time.c
+++ b/dlls/ntdll/time.c
@@ -728,18 +728,20 @@ static time_t find_dst_change(unsigned long min, unsigned long max, int *is_dst)
static int init_tz_info(RTL_TIME_ZONE_INFORMATION *tzi)
{
static RTL_TIME_ZONE_INFORMATION cached_tzi;
- static int current_year = -1;
+ static int current_year = -1, current_bias = 65535;
struct tm *tm;
time_t year_start, year_end, tmp, dlt = 0, std = 0;
- int is_dst, current_is_dst;
+ int is_dst, current_is_dst, bias;
RtlEnterCriticalSection( &TIME_tz_section );
year_start = time(NULL);
- tm = localtime(&year_start);
+ tm = gmtime(&year_start);
+ bias = (LONG)(mktime(tm) - year_start) / 60;
+ tm = localtime(&year_start);
current_is_dst = tm->tm_isdst;
- if (current_year == tm->tm_year)
+ if (current_year == tm->tm_year && current_bias == bias)
{
*tzi = cached_tzi;
RtlLeaveCriticalSection( &TIME_tz_section );
@@ -748,8 +750,11 @@ static int init_tz_info(RTL_TIME_ZONE_INFORMATION *tzi)
memset(tzi, 0, sizeof(*tzi));
- TRACE("tz data will be valid through year %d\n", tm->tm_year + 1900);
+ TRACE("tz data will be valid through year %d, bias %d\n", tm->tm_year + 1900, bias);
current_year = tm->tm_year;
+ current_bias = bias;
+
+ tzi->Bias = bias;
tm->tm_isdst = 0;
tm->tm_mday = 1;
@@ -764,10 +769,6 @@ static int init_tz_info(RTL_TIME_ZONE_INFORMATION *tzi)
year_end = mktime(tm);
TRACE("year_end: %s", ctime(&year_end));
- tm = gmtime(&year_start);
- tzi->Bias = (LONG)(mktime(tm) - year_start) / 60;
- TRACE("bias: %d\n", tzi->Bias);
-
tmp = find_dst_change(year_start, year_end, &is_dst);
if (is_dst)
dlt = tmp;
--
1.7.5.1
More information about the wine-patches
mailing list