RtlLocalTimeToSystemTime and RtlSystemTimeToLocalTime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



is there any reason why this hasnt made it into cvs yet?

ChangeLog:
 * dlls/ntdll/ntdll.spec
 * dlls/ntdlls/time.c
 * file/dos_fs.c
 * include/winternl.h
 * dlls/kernel/time.c
   - Implement RtlLocalTimeToSystemTime and RtlSystemTimeToLocalTime
   - Use new time functions to reimplement FileTimeToLocalTime and
LocalTimeToFileTime.

nog.

--- ../cleanwine/include/winternl.h	2002-11-25 08:58:12.000000000 +0200
+++ include/winternl.h	2002-11-29 09:07:53.000000000 +0200
@@ -1034,7 +1034,7 @@
 ULONG     WINAPI RtlSizeHeap(HANDLE,ULONG,PVOID);
 LPDWORD   WINAPI RtlSubAuthoritySid(PSID,DWORD);
 LPBYTE    WINAPI RtlSubAuthorityCountSid(PSID);
-void      WINAPI RtlSystemTimeToLocalTime(PLARGE_INTEGER,PLARGE_INTEGER);
+NTSTATUS  WINAPI RtlSystemTimeToLocalTime(PLARGE_INTEGER,PLARGE_INTEGER);
 
 void      WINAPI RtlTimeToTimeFields(const LARGE_INTEGER*,PTIME_FIELDS);
 BOOLEAN   WINAPI RtlTimeFieldsToTime(PTIME_FIELDS,PLARGE_INTEGER);
--- ../cleanwine/files/dos_fs.c	2002-11-21 09:37:00.000000000 +0200
+++ files/dos_fs.c	2002-11-29 08:54:47.000000000 +0200
@@ -2481,56 +2481,6 @@
     return TRUE;
 }
 
-
-/***********************************************************************
- *           LocalFileTimeToFileTime   (KERNEL32.@)
- */
-BOOL WINAPI LocalFileTimeToFileTime( const FILETIME *localft,
-                                       LPFILETIME utcft )
-{
-    struct tm *xtm;
-    DWORD remainder;
-    time_t utctime;
-
-    /* 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;
-}
-
-
-/***********************************************************************
- *           FileTimeToLocalFileTime   (KERNEL32.@)
- */
-BOOL WINAPI FileTimeToLocalFileTime( const FILETIME *utcft,
-                                       LPFILETIME localft )
-{
-    DWORD remainder;
-    /* Converts from UTC to local. */
-    time_t unixtime = DOSFS_FileTimeToUnixTime( utcft, &remainder );
-#ifdef HAVE_TIMEGM
-    struct tm *xtm = localtime( &unixtime );
-    time_t localtime;
-
-    localtime = timegm(xtm);
-    DOSFS_UnixTimeToFileTime( localtime, localft, remainder );
-
-#else
-    struct tm *xtm;
-    time_t time;
-
-    xtm = gmtime( &unixtime );
-    time = mktime(xtm);
-    if(xtm->tm_isdst > 0) time-=3600;
-    DOSFS_UnixTimeToFileTime( 2*unixtime-time, localft, remainder );
-#endif
-    return TRUE;
-}
-
-
 /***********************************************************************
  *           FileTimeToSystemTime   (KERNEL32.@)
  */
--- ../cleanwine/dlls/kernel/time.c	2002-11-25 08:58:04.000000000 +0200
+++ dlls/kernel/time.c	2002-11-29 09:04:03.000000000 +0200
@@ -470,3 +470,29 @@
 	  Locale, Calendar, CalType, debugstr_w(lpCalData));
     return 0;
 }
+
+/*********************************************************************
+ *      LocalFileTimeToFileTime                         (KERNEL32.@)
+ */
+BOOL WINAPI LocalFileTimeToFileTime( const FILETIME *localft,
+                                       LPFILETIME utcft )
+{
+    NTSTATUS status;
+    if ((status = RtlLocalTimeToSystemTime((PLARGE_INTEGER)localft,
+                                           (PLARGE_INTEGER)utcft)))
+        SetLastError( RtlNtStatusToDosError(status) );
+    return !status;
+}
+
+/*********************************************************************
+ *      FileTimeToLocalFileTime                         (KERNEL32.@)
+ */
+BOOL WINAPI FileTimeToLocalFileTime( const FILETIME *utcft,
+                                       LPFILETIME localft )
+{
+    NTSTATUS status;
+    if ((status = RtlSystemTimeToLocalTime((PLARGE_INTEGER)utcft,
+                                           (PLARGE_INTEGER)localft)))
+        SetLastError( RtlNtStatusToDosError(status) );
+    return !status;
+}
--- ../cleanwine/dlls/ntdll/time.c	2002-11-28 19:30:35.000000000 +0200
+++ dlls/ntdll/time.c	2002-11-29 09:07:29.000000000 +0200
@@ -414,6 +414,32 @@
 }
 /************ end of code by Rex Jolliff (rex@lvcablemodem.com) ***************/
 
+/******************************************************************************
+ *        RtlLocalTimeToSystemTime [NTDLL.@]
+ *
+ * Converts local time to system time.
+ *
+ * PARAMS:
+ *   LocalTime [I]: Localtime to convert.
+ *   SystemTime [O]: SystemTime of the supplied localtime.
+ *
+ * RETURNS:
+ *   Status.
+ */
+NTSTATUS WINAPI RtlLocalTimeToSystemTime(PLARGE_INTEGER LocalTime,
+                                         PLARGE_INTEGER SystemTime)
+{
+    TIME_ZONE_INFORMATION tzinfo;
+
+    TRACE("(%p, %p)\n", LocalTime, SystemTime);
+
+    RtlQueryTimeZoneInformation(&tzinfo);
+
+    *(LONGLONG *)SystemTime = RtlLargeIntegerAdd(*(LONGLONG *)LocalTime,
+                                                 tzinfo.Bias * 60 * 10000000);
+
+    return STATUS_SUCCESS;
+}
 
 /******************************************************************************
  *       RtlSystemTimeToLocalTime [NTDLL.@]
@@ -427,13 +453,19 @@
  * RETURNS:
  *   Nothing.
  */
-VOID WINAPI RtlSystemTimeToLocalTime(
+NTSTATUS WINAPI RtlSystemTimeToLocalTime(
 	IN  PLARGE_INTEGER SystemTime,
 	OUT PLARGE_INTEGER LocalTime)
 {
-	FIXME("(%p, %p),stub!\n",SystemTime,LocalTime);
+    TIME_ZONE_INFORMATION tzinfo;
+
+    TRACE("(%p, %p)\n", SystemTime, LocalTime);
 
-	memcpy (LocalTime, SystemTime, sizeof (PLARGE_INTEGER));
+    RtlQueryTimeZoneInformation(&tzinfo);
+
+    *(LONGLONG *)LocalTime = RtlLargeIntegerSubtract(*(LONGLONG *)SystemTime,
+                                                   tzinfo.Bias * 60 * 10000000);
+    return STATUS_SUCCESS;
 }
 
 /******************************************************************************
--- ../cleanwine/dlls/ntdll/ntdll.spec	2002-11-28 19:30:35.000000000 +0200
+++ dlls/ntdll/ntdll.spec	2002-11-29 10:03:32.000000000 +0200
@@ -450,7 +450,7 @@
 @ stdcall RtlLengthRequiredSid(long) RtlLengthRequiredSid
 @ stdcall RtlLengthSecurityDescriptor(ptr) RtlLengthSecurityDescriptor
 @ stdcall RtlLengthSid(ptr) RtlLengthSid
-@ stub RtlLocalTimeToSystemTime
+@ stdcall RtlLocalTimeToSystemTime(long long) RtlLocalTimeToSystemTime
 @ stdcall RtlLockHeap(long) RtlLockHeap
 @ stub RtlLookupElementGenericTable
 @ stdcall RtlMakeSelfRelativeSD(ptr ptr ptr) RtlMakeSelfRelativeSD



[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux