Time related functions patches (bug #725)

Vincent Béron vberon at mecano.gme.usherb.ca
Mon May 27 21:51:50 CDT 2002


Note to self: read the docs thoroughly before submitting a patch.

These 2 patches replace the similarly named patches in the parent
message. There was a slight problem in the daylight saving part.

Changelog:
 - Fix LocalFileTimeToFileTime (was offset if daylight was active).
 - Fix FileTimeToLocalFileTime (the case when timegm is absent was
wrong, and gave different results than timegm).

Vincent
-------------- next part --------------
diff -urN wine-orig/files/dos_fs.c wine-pas-compil?/files/dos_fs.c
--- wine-orig/files/dos_fs.c	Thu May 23 16:36:46 2002
+++ wine-pas-compil?/files/dos_fs.c	Sun May 26 21:20:25 2002
@@ -2174,11 +2174,14 @@
 {
     struct tm *xtm;
     DWORD remainder;
+    time_t utctime;
 
-    /* convert from local to UTC. Perhaps not correct. FIXME */
-    time_t unixtime = DOSFS_FileTimeToUnixTime( localft, &remainder );
-    xtm = gmtime( &unixtime );
-    DOSFS_UnixTimeToFileTime( mktime(xtm), utcft, remainder );
+    /* Converts from local to UTC. */
+    time_t localtime = DOSFS_FileTimeToUnixTime( localft, &remainder );
+    xtm = gmtime( &localtime );
+    utctime = mktime(xtm);
+    if(xtm->tm_isdst > 0) utctime-=3600;
+    DOSFS_UnixTimeToFileTime( utctime, utcft, remainder );
     return TRUE; 
 }
 
-------------- next part --------------
diff -urN wine-orig/files/dos_fs.c wine-pas-compil?/files/dos_fs.c
--- wine-orig/files/dos_fs.c	Thu May 23 16:36:46 2002
+++ wine-pas-compil?/files/dos_fs.c	Sun May 26 21:20:25 2002
@@ -2193,7 +2193,7 @@
                                        LPFILETIME localft )
 {
     DWORD remainder;
-    /* convert from UTC to local. Perhaps not correct. FIXME */
+    /* Converts from UTC to local. */
     time_t unixtime = DOSFS_FileTimeToUnixTime( utcft, &remainder );
 #ifdef HAVE_TIMEGM
     struct tm *xtm = localtime( &unixtime );
@@ -2203,14 +2203,13 @@
     DOSFS_UnixTimeToFileTime( localtime, localft, remainder );
 
 #else
-    struct tm *xtm,*gtm;
-    time_t time1,time2;
+    struct tm *xtm;
+    time_t time;
 
-    xtm = localtime( &unixtime );
-    gtm = gmtime( &unixtime );
-    time1 = mktime(xtm);
-    time2 = mktime(gtm);
-    DOSFS_UnixTimeToFileTime( 2*time1-time2, localft, remainder );
+    xtm = gmtime( &unixtime );
+    time = mktime(xtm);
+    if(xtm->tm_isdst > 0) time-=3600;
+    DOSFS_UnixTimeToFileTime( 2*unixtime-time, localft, remainder );
 #endif
     return TRUE; 
 }


More information about the wine-devel mailing list