Tcl Source Code

Artifact [8b5bba3e82]
Login

Artifact 8b5bba3e82a79280d2774098d53035bc53f70da9:

Attachment "tclWinFile.c.diff" to ticket [1353840fff] added by matt-newman 2005-11-11 18:05:43.
Index: win/tclWinFile.c
===================================================================
RCS file: /cvs/kit/tcl/win/tclWinFile.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -b -w -r1.1 -r1.2
--- win/tclWinFile.c	2005/06/22 21:23:34	1.1
+++ win/tclWinFile.c	2005/11/08 09:07:10	1.2
@@ -1862,29 +1862,13 @@
 
 static time_t
 ToCTime(
-    FILETIME fileTime)		/* UTC Time to convert to local time_t. */
+    FILETIME fileTime)
 {
-    FILETIME localFileTime;
-    SYSTEMTIME systemTime;
-    struct tm tm;
-
-    if (FileTimeToLocalFileTime(&fileTime, &localFileTime) == 0) {
-	return 0;
-    }
-    if (FileTimeToSystemTime(&localFileTime, &systemTime) == 0) {
-	return 0;
-    }
-    tm.tm_sec = systemTime.wSecond;
-    tm.tm_min = systemTime.wMinute;
-    tm.tm_hour = systemTime.wHour;
-    tm.tm_mday = systemTime.wDay;
-    tm.tm_mon = systemTime.wMonth - 1;
-    tm.tm_year = systemTime.wYear - 1900;
-    tm.tm_wday = 0;
-    tm.tm_yday = 0;
-    tm.tm_isdst = -1;
-
-    return mktime(&tm);
+    LONGLONG ll = fileTime.dwHighDateTime;
+    ll <<= 32;
+    ll += fileTime.dwLowDateTime;
+    ll -= 116444736000000000;
+    return (time_t) (ll / (LONGLONG)10000000);
 }
 
 #if 0