- Implement RtlLocalTimeToSystemTime and RtlSystemTimeToLocalTime.

- Use new time functions to reimplement FileTimeToLocalTime and
  LocalTimeToFileTime.
This commit is contained in:
György 'Nog' Jeney 2002-12-11 00:19:56 +00:00 committed by Alexandre Julliard
parent 2837103fec
commit 4d6ba25d4b
5 changed files with 61 additions and 59 deletions

View File

@ -470,3 +470,29 @@ int WINAPI SetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPCWST
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;
}

View File

@ -450,7 +450,7 @@
@ stdcall RtlLengthRequiredSid(long) RtlLengthRequiredSid
@ stdcall RtlLengthSecurityDescriptor(ptr) RtlLengthSecurityDescriptor
@ stdcall RtlLengthSid(ptr) RtlLengthSid
@ stub RtlLocalTimeToSystemTime
@ stdcall RtlLocalTimeToSystemTime(ptr ptr) RtlLocalTimeToSystemTime
@ stdcall RtlLockHeap(long) RtlLockHeap
@ stub RtlLookupElementGenericTable
@ stdcall RtlMakeSelfRelativeSD(ptr ptr ptr) RtlMakeSelfRelativeSD
@ -521,7 +521,7 @@
@ stdcall RtlSubAuthoritySid(ptr long) RtlSubAuthoritySid
@ stub RtlSubtreePredecessor
@ stub RtlSubtreeSuccessor
@ stdcall RtlSystemTimeToLocalTime (long long) RtlSystemTimeToLocalTime
@ stdcall RtlSystemTimeToLocalTime(ptr ptr) RtlSystemTimeToLocalTime
@ stdcall RtlTimeFieldsToTime(ptr ptr) RtlTimeFieldsToTime
@ stdcall RtlTimeToElapsedTimeFields(long long) RtlTimeToElapsedTimeFields
@ stdcall RtlTimeToSecondsSince1970(ptr ptr) RtlTimeToSecondsSince1970

View File

@ -414,6 +414,29 @@ BOOLEAN WINAPI RtlTimeFieldsToTime(
}
/************ 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( const LARGE_INTEGER *LocalTime,
PLARGE_INTEGER SystemTime)
{
TIME_ZONE_INFORMATION tzinfo;
TRACE("(%p, %p)\n", LocalTime, SystemTime);
RtlQueryTimeZoneInformation(&tzinfo);
SystemTime->QuadPart = LocalTime->QuadPart + tzinfo.Bias * 60 * (LONGLONG)10000000;
return STATUS_SUCCESS;
}
/******************************************************************************
* RtlSystemTimeToLocalTime [NTDLL.@]
@ -427,13 +450,16 @@ BOOLEAN WINAPI RtlTimeFieldsToTime(
* RETURNS:
* Nothing.
*/
VOID WINAPI RtlSystemTimeToLocalTime(
IN PLARGE_INTEGER SystemTime,
OUT PLARGE_INTEGER LocalTime)
NTSTATUS WINAPI RtlSystemTimeToLocalTime( const LARGE_INTEGER *SystemTime,
PLARGE_INTEGER LocalTime )
{
FIXME("(%p, %p),stub!\n",SystemTime,LocalTime);
TIME_ZONE_INFORMATION tzinfo;
memcpy (LocalTime, SystemTime, sizeof (PLARGE_INTEGER));
TRACE("(%p, %p)\n", SystemTime, LocalTime);
RtlQueryTimeZoneInformation(&tzinfo);
LocalTime->QuadPart = SystemTime->QuadPart - tzinfo.Bias * 60 * (LONGLONG)10000000;
return STATUS_SUCCESS;
}
/******************************************************************************

View File

@ -2481,56 +2481,6 @@ BOOL WINAPI FileTimeToDosDateTime( const FILETIME *ft, LPWORD fatdate,
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.@)
*/

View File

@ -992,7 +992,7 @@ NTSTATUS WINAPI RtlLeaveCriticalSection(RTL_CRITICAL_SECTION *);
DWORD WINAPI RtlLengthRequiredSid(DWORD);
ULONG WINAPI RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR);
DWORD WINAPI RtlLengthSid(PSID);
NTSTATUS WINAPI RtlLocalTimeToSystemTime(PLARGE_INTEGER,PLARGE_INTEGER);
NTSTATUS WINAPI RtlLocalTimeToSystemTime(const LARGE_INTEGER*,PLARGE_INTEGER);
BOOLEAN WINAPI RtlLockHeap(HANDLE);
NTSTATUS WINAPI RtlMakeSelfRelativeSD(PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR,LPDWORD);
@ -1034,7 +1034,7 @@ NTSTATUS WINAPI RtlSetTimeZoneInformation(const TIME_ZONE_INFORMATION*);
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(const LARGE_INTEGER*,PLARGE_INTEGER);
void WINAPI RtlTimeToTimeFields(const LARGE_INTEGER*,PTIME_FIELDS);
BOOLEAN WINAPI RtlTimeFieldsToTime(PTIME_FIELDS,PLARGE_INTEGER);