[PATCH] Make msvcrt time test pass when daylight savings is in effect (bug 9916).

Jon Griffiths jon_p_griffiths at yahoo.com
Sat May 3 09:53:06 CDT 2008


---
 dlls/msvcrt/tests/time.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/dlls/msvcrt/tests/time.c b/dlls/msvcrt/tests/time.c
index 1fe6cbf..15b99fa 100644
--- a/dlls/msvcrt/tests/time.c
+++ b/dlls/msvcrt/tests/time.c
@@ -53,6 +53,7 @@ static void test_mktime(void)
 {
     TIME_ZONE_INFORMATION tzinfo;
     DWORD res =  GetTimeZoneInformation(&tzinfo);
+    LONG bias;
     struct tm my_tm, sav_tm;
     time_t nulltime, local_time;
     char TZ_env[256];
@@ -60,7 +61,8 @@ static void test_mktime(void)
 
     ok (res != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
     /* Bias may be positive or negative, to use offset of one day */
-    secs= SECSPERDAY - tzinfo.Bias * SECSPERMIN;
+    bias = tzinfo.Bias + (res == TIME_ZONE_ID_DAYLIGHT ? tzinfo.DaylightBias : tzinfo.StandardBias);
+    secs= SECSPERDAY - bias * SECSPERMIN;
     my_tm.tm_mday = 1 + secs/SECSPERDAY;
     secs = secs % SECSPERDAY;
     my_tm.tm_hour = secs / SECSPERHOUR;
@@ -155,7 +157,8 @@ static void test_localtime(void)
 {
     TIME_ZONE_INFORMATION tzinfo;
     DWORD res =  GetTimeZoneInformation(&tzinfo);
-    time_t gmt = (time_t)(SECSPERDAY + tzinfo.Bias * SECSPERMIN);
+    LONG bias = tzinfo.Bias + (res == TIME_ZONE_ID_DAYLIGHT ? tzinfo.DaylightBias : tzinfo.StandardBias);
+    time_t gmt = (time_t)(SECSPERDAY + bias * SECSPERMIN);
 
     char TZ_env[256];
     struct tm* lt;
@@ -183,7 +186,8 @@ static void test_localtime(void)
     /* June 22 */
     gmt += 201 * SECSPERDAY;
     lt = localtime(&gmt);
-    gmt += (lt->tm_isdst ? tzinfo.DaylightBias : tzinfo.StandardBias) * SECSPERMIN;
+    bias = tzinfo.Bias + (lt->tm_isdst ? tzinfo.DaylightBias : tzinfo.StandardBias);
+    gmt += bias * SECSPERMIN;
     lt = localtime(&gmt);
     ok(((lt->tm_year == 70) && (lt->tm_mon  == 6) && (lt->tm_yday  == 202) &&
 	(lt->tm_mday == 22) && (lt->tm_wday == 3) && (lt->tm_hour  == 0) &&
-- 
1.5.2.5


--0-502943404-1209826935=:31189--



More information about the wine-patches mailing list