2000-09-29 22:48:04 +02:00
|
|
|
/*
|
2002-12-13 21:30:06 +01:00
|
|
|
* Win32 kernel time functions
|
2000-09-29 22:48:04 +02:00
|
|
|
*
|
|
|
|
* Copyright 1995 Martin von Loewis and Cameron Heide
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
|
2002-03-11 06:08:38 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
#include <string.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2000-11-01 04:11:12 +01:00
|
|
|
#include <stdlib.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
2002-08-26 23:53:24 +02:00
|
|
|
#ifdef HAVE_SYS_TIMES_H
|
|
|
|
# include <sys/times.h>
|
|
|
|
#endif
|
2003-01-07 21:36:20 +01:00
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2000-09-29 22:48:04 +02:00
|
|
|
#include "file.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
2000-09-29 22:48:04 +02:00
|
|
|
#include "winerror.h"
|
2001-02-26 23:33:29 +01:00
|
|
|
#include "winnls.h"
|
2001-04-09 20:45:49 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(win32);
|
2000-09-29 22:48:04 +02:00
|
|
|
|
|
|
|
/* maximum time adjustment in seconds for SetLocalTime and SetSystemTime */
|
|
|
|
#define SETTIME_MAX_ADJUST 120
|
2002-06-13 23:44:15 +02:00
|
|
|
#define CALINFO_MAX_YEAR 2029
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2001-04-09 20:45:49 +02:00
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* SetLocalTime (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Set the local time using current time zone and daylight
|
2000-12-20 00:33:03 +01:00
|
|
|
* savings settings.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* Success: TRUE. The time was set
|
|
|
|
* Failure: FALSE, if the time was invalid or caller does not have
|
|
|
|
* permission to change the time.
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2001-02-12 04:49:57 +01:00
|
|
|
BOOL WINAPI SetLocalTime(
|
|
|
|
const SYSTEMTIME *systime) /* [in] The desired local time. */
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
2002-12-13 21:30:06 +01:00
|
|
|
FILETIME ft;
|
2002-12-13 21:53:04 +01:00
|
|
|
LARGE_INTEGER st, st2;
|
2002-12-13 21:30:06 +01:00
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
SystemTimeToFileTime( systime, &ft );
|
2002-12-13 21:53:04 +01:00
|
|
|
st.s.LowPart = ft.dwLowDateTime;
|
|
|
|
st.s.HighPart = ft.dwHighDateTime;
|
|
|
|
RtlLocalTimeToSystemTime( &st, &st2 );
|
2002-12-13 21:30:06 +01:00
|
|
|
|
2002-12-13 21:53:04 +01:00
|
|
|
if ((status = NtSetSystemTime(&st2, NULL)))
|
2002-12-13 21:30:06 +01:00
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* GetSystemTimeAdjustment (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Get the period between clock interrupts and the amount the clock
|
|
|
|
* is adjusted each interrupt so as to keep it in sync with an external source.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* TRUE.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Only the special case of disabled time adjustments is supported.
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2002-05-30 22:05:48 +02:00
|
|
|
BOOL WINAPI GetSystemTimeAdjustment(
|
|
|
|
PDWORD lpTimeAdjustment, /* [out] The clock adjustment per interupt in 100's of nanoseconds. */
|
|
|
|
PDWORD lpTimeIncrement, /* [out] The time between clock interupts in 100's of nanoseconds. */
|
|
|
|
PBOOL lpTimeAdjustmentDisabled) /* [out] The clock synchonisation has been disabled. */
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
*lpTimeAdjustment = 0;
|
|
|
|
*lpTimeIncrement = 0;
|
|
|
|
*lpTimeAdjustmentDisabled = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* SetSystemTime (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Set the system time in utc.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* Success: TRUE. The time was set
|
|
|
|
* Failure: FALSE, if the time was invalid or caller does not have
|
|
|
|
* permission to change the time.
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2000-12-20 00:33:03 +01:00
|
|
|
BOOL WINAPI SetSystemTime(
|
2001-02-12 04:49:57 +01:00
|
|
|
const SYSTEMTIME *systime) /* [in] The desired system time. */
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
2002-12-13 21:53:04 +01:00
|
|
|
FILETIME ft;
|
2002-11-25 02:12:39 +01:00
|
|
|
LARGE_INTEGER t;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
2002-12-13 21:53:04 +01:00
|
|
|
SystemTimeToFileTime( systime, &ft );
|
|
|
|
t.s.LowPart = ft.dwLowDateTime;
|
|
|
|
t.s.HighPart = ft.dwHighDateTime;
|
2002-11-25 02:12:39 +01:00
|
|
|
if ((status = NtSetSystemTime(&t, NULL)))
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* GetTimeZoneInformation (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Get information about the current local time zone.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* Success: TIME_ZONE_ID_STANDARD. tzinfo contains the time zone info.
|
|
|
|
* Failure: TIME_ZONE_ID_INVALID.
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2000-12-20 00:33:03 +01:00
|
|
|
DWORD WINAPI GetTimeZoneInformation(
|
2003-03-18 19:35:48 +01:00
|
|
|
LPTIME_ZONE_INFORMATION tzinfo) /* [out] Destination for time zone information */
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
2002-11-25 02:12:39 +01:00
|
|
|
NTSTATUS status;
|
|
|
|
if ((status = RtlQueryTimeZoneInformation(tzinfo)))
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
2000-10-31 02:01:12 +01:00
|
|
|
return TIME_ZONE_ID_STANDARD;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* SetTimeZoneInformation (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Change the settings of the current local time zone.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* Success: TRUE. The time zone was updated with the settings from tzinfo
|
|
|
|
* Failure: FALSE.
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2000-12-20 00:33:03 +01:00
|
|
|
BOOL WINAPI SetTimeZoneInformation(
|
2001-02-12 04:49:57 +01:00
|
|
|
const LPTIME_ZONE_INFORMATION tzinfo) /* [in] The new time zone. */
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
2002-11-25 02:12:39 +01:00
|
|
|
NTSTATUS status;
|
|
|
|
if ((status = RtlSetTimeZoneInformation(tzinfo)))
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-19 05:12:42 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* _DayLightCompareDate
|
|
|
|
*
|
|
|
|
* Compares two dates without looking at the year
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* -1 if date < compareDate
|
|
|
|
* 0 if date == compareDate
|
|
|
|
* 1 if date > compareDate
|
|
|
|
* -2 if an error occures
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int _DayLightCompareDate(
|
|
|
|
const LPSYSTEMTIME date, /* [in] The date to compare. */
|
|
|
|
const LPSYSTEMTIME compareDate) /* [in] The daylight saving begin or end date */
|
|
|
|
{
|
|
|
|
int limit_day;
|
|
|
|
|
|
|
|
if (compareDate->wYear != 0)
|
|
|
|
{
|
|
|
|
if (date->wMonth < compareDate->wMonth)
|
|
|
|
return -1; /* We are in a year before the date limit. */
|
|
|
|
|
|
|
|
if (date->wMonth > compareDate->wMonth)
|
|
|
|
return 1; /* We are in a year after the date limit. */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (date->wMonth < compareDate->wMonth)
|
|
|
|
return -1; /* We are in a month before the date limit. */
|
|
|
|
|
|
|
|
if (date->wMonth > compareDate->wMonth)
|
|
|
|
return 1; /* We are in a month after the date limit. */
|
|
|
|
|
|
|
|
if (compareDate->wDayOfWeek <= 6)
|
|
|
|
{
|
|
|
|
SYSTEMTIME tmp;
|
|
|
|
FILETIME tmp_ft;
|
|
|
|
|
|
|
|
/* compareDate->wDay is interpreted as number of the week in the month. */
|
|
|
|
/* 5 means: the last week in the month */
|
|
|
|
int weekofmonth = compareDate->wDay;
|
|
|
|
|
|
|
|
/* calculate day of week for the first day in the month */
|
|
|
|
memcpy(&tmp, date, sizeof(SYSTEMTIME));
|
|
|
|
tmp.wDay = 1;
|
|
|
|
tmp.wDayOfWeek = -1;
|
|
|
|
|
|
|
|
if (weekofmonth == 5)
|
|
|
|
{
|
|
|
|
/* Go to the beginning of the next month. */
|
|
|
|
if (++tmp.wMonth > 12)
|
|
|
|
{
|
|
|
|
tmp.wMonth = 1;
|
|
|
|
++tmp.wYear;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SystemTimeToFileTime(&tmp, &tmp_ft))
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
if (weekofmonth == 5)
|
|
|
|
{
|
|
|
|
LONGLONG t, one_day;
|
|
|
|
|
|
|
|
t = tmp_ft.dwHighDateTime;
|
|
|
|
t <<= 32;
|
|
|
|
t += (UINT)tmp_ft.dwLowDateTime;
|
|
|
|
|
|
|
|
/* substract one day */
|
|
|
|
one_day = 24*60*60;
|
|
|
|
one_day *= 10000000;
|
|
|
|
t -= one_day;
|
|
|
|
|
|
|
|
tmp_ft.dwLowDateTime = (UINT)t;
|
|
|
|
tmp_ft.dwHighDateTime = (UINT)(t >> 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!FileTimeToSystemTime(&tmp_ft, &tmp))
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
if (weekofmonth == 5)
|
|
|
|
{
|
|
|
|
/* calculate the last matching day of the week in this month */
|
|
|
|
int dif = tmp.wDayOfWeek - compareDate->wDayOfWeek;
|
|
|
|
if (dif < 0)
|
|
|
|
dif += 7;
|
|
|
|
|
|
|
|
limit_day = tmp.wDay - dif;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* calulcate the matching day of the week in the given week */
|
|
|
|
int dif = compareDate->wDayOfWeek - tmp.wDayOfWeek;
|
|
|
|
if (dif < 0)
|
|
|
|
dif += 7;
|
|
|
|
|
|
|
|
limit_day = tmp.wDay + 7*(weekofmonth-1) + dif;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
limit_day = compareDate->wDay;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (date->wDay < limit_day)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (date->wDay > limit_day)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0; /* date is equal to the date limit. */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _GetTimezoneBias
|
|
|
|
*
|
|
|
|
* Calculates the local time bias for a given time zone
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* Returns TRUE when the time zone bias was calculated.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static BOOL _GetTimezoneBias(
|
|
|
|
const LPTIME_ZONE_INFORMATION lpTimeZoneInformation, /* [in] The time zone data. */
|
|
|
|
LPSYSTEMTIME lpSystemTime, /* [in] The system time. */
|
|
|
|
LONG* pBias) /* [out] The calulated bias in minutes */
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
BOOL beforedaylightsaving, afterdaylightsaving;
|
|
|
|
BOOL daylightsaving = FALSE;
|
|
|
|
LONG bias = lpTimeZoneInformation->Bias;
|
|
|
|
|
|
|
|
if (lpTimeZoneInformation->DaylightDate.wMonth != 0)
|
|
|
|
{
|
|
|
|
if (lpTimeZoneInformation->StandardDate.wMonth == 0 ||
|
|
|
|
lpTimeZoneInformation->StandardDate.wDay<1 ||
|
|
|
|
lpTimeZoneInformation->StandardDate.wDay>5 ||
|
|
|
|
lpTimeZoneInformation->DaylightDate.wDay<1 ||
|
|
|
|
lpTimeZoneInformation->DaylightDate.wDay>5)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for daylight saving */
|
|
|
|
ret = _DayLightCompareDate(lpSystemTime, &lpTimeZoneInformation->StandardDate);
|
|
|
|
if (ret == -2)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
beforedaylightsaving = ret < 0;
|
|
|
|
|
|
|
|
_DayLightCompareDate(lpSystemTime, &lpTimeZoneInformation->DaylightDate);
|
|
|
|
if (ret == -2)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
afterdaylightsaving = ret >= 0;
|
|
|
|
|
|
|
|
if (!beforedaylightsaving && !afterdaylightsaving)
|
|
|
|
daylightsaving = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (daylightsaving)
|
|
|
|
bias += lpTimeZoneInformation->DaylightBias;
|
|
|
|
else if (lpTimeZoneInformation->StandardDate.wMonth != 0)
|
|
|
|
bias += lpTimeZoneInformation->StandardBias;
|
|
|
|
|
|
|
|
*pBias = bias;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* SystemTimeToTzSpecificLocalTime (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Convert a utc system time to a local time in a given time zone.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* Success: TRUE. lpLocalTime contains the converted time
|
|
|
|
* Failure: FALSE.
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2002-12-19 05:12:42 +01:00
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
BOOL WINAPI SystemTimeToTzSpecificLocalTime(
|
2001-02-12 04:49:57 +01:00
|
|
|
LPTIME_ZONE_INFORMATION lpTimeZoneInformation, /* [in] The desired time zone. */
|
|
|
|
LPSYSTEMTIME lpUniversalTime, /* [in] The utc time to base local time on. */
|
|
|
|
LPSYSTEMTIME lpLocalTime) /* [out] The local time in the time zone. */
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
2002-12-19 05:12:42 +01:00
|
|
|
FILETIME ft;
|
|
|
|
LONG lBias;
|
|
|
|
LONGLONG t, bias;
|
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
|
|
|
|
if (lpTimeZoneInformation != NULL)
|
|
|
|
{
|
|
|
|
memcpy(&tzinfo, lpTimeZoneInformation, sizeof(TIME_ZONE_INFORMATION));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_INVALID)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SystemTimeToFileTime(lpUniversalTime, &ft))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
t = ft.dwHighDateTime;
|
|
|
|
t <<= 32;
|
|
|
|
t += (UINT)ft.dwLowDateTime;
|
|
|
|
|
|
|
|
if (!_GetTimezoneBias(&tzinfo, lpUniversalTime, &lBias))
|
|
|
|
return FALSE;
|
|
|
|
|
2003-02-11 23:12:41 +01:00
|
|
|
bias = (LONGLONG)lBias * 600000000; /* 60 seconds per minute, 100000 [100-nanoseconds-ticks] per second */
|
|
|
|
t -= bias;
|
2002-12-19 05:12:42 +01:00
|
|
|
|
|
|
|
ft.dwLowDateTime = (UINT)t;
|
|
|
|
ft.dwHighDateTime = (UINT)(t >> 32);
|
|
|
|
|
|
|
|
return FileTimeToSystemTime(&ft, lpLocalTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TzSpecificLocalTimeToSystemTime (KERNEL32.@)
|
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Converts a local time to a time in utc.
|
2002-12-19 05:12:42 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* Success: TRUE. lpUniversalTime contains the converted time
|
|
|
|
* Failure: FALSE.
|
2002-12-19 05:12:42 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI TzSpecificLocalTimeToSystemTime(
|
|
|
|
LPTIME_ZONE_INFORMATION lpTimeZoneInformation, /* [in] The desired time zone. */
|
|
|
|
LPSYSTEMTIME lpLocalTime, /* [in] The local time. */
|
|
|
|
LPSYSTEMTIME lpUniversalTime) /* [out] The calculated utc time. */
|
|
|
|
{
|
|
|
|
FILETIME ft;
|
|
|
|
LONG lBias;
|
|
|
|
LONGLONG t, bias;
|
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
|
|
|
|
if (lpTimeZoneInformation != NULL)
|
|
|
|
{
|
|
|
|
memcpy(&tzinfo, lpTimeZoneInformation, sizeof(TIME_ZONE_INFORMATION));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_INVALID)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SystemTimeToFileTime(lpLocalTime, &ft))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
t = ft.dwHighDateTime;
|
|
|
|
t <<= 32;
|
|
|
|
t += (UINT)ft.dwLowDateTime;
|
|
|
|
|
|
|
|
if (!_GetTimezoneBias(&tzinfo, lpUniversalTime, &lBias))
|
|
|
|
return FALSE;
|
|
|
|
|
2003-02-11 23:12:41 +01:00
|
|
|
bias = (LONGLONG)lBias * 600000000; /* 60 seconds per minute, 100000 [100-nanoseconds-ticks] per second */
|
|
|
|
t += bias;
|
2002-12-19 05:12:42 +01:00
|
|
|
|
|
|
|
ft.dwLowDateTime = (UINT)t;
|
|
|
|
ft.dwHighDateTime = (UINT)(t >> 32);
|
|
|
|
|
|
|
|
return FileTimeToSystemTime(&ft, lpUniversalTime);
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
2000-10-01 03:40:42 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* GetSystemTimeAsFileTime (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Get the current time in utc format.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
2000-10-01 03:40:42 +02:00
|
|
|
*/
|
2000-12-20 00:33:03 +01:00
|
|
|
VOID WINAPI GetSystemTimeAsFileTime(
|
2003-03-18 19:35:48 +01:00
|
|
|
LPFILETIME time) /* [out] Destination for the current utc time */
|
2000-10-01 03:40:42 +02:00
|
|
|
{
|
2002-12-13 21:53:04 +01:00
|
|
|
LARGE_INTEGER t;
|
|
|
|
NtQuerySystemTime( &t );
|
|
|
|
time->dwLowDateTime = t.s.LowPart;
|
|
|
|
time->dwHighDateTime = t.s.HighPart;
|
2000-10-01 03:40:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
/*********************************************************************
|
2000-12-20 00:33:03 +01:00
|
|
|
* TIME_ClockTimeToFileTime (olorin@fandra.org, 20-Sep-1998)
|
|
|
|
*
|
|
|
|
* Used by GetProcessTimes to convert clock_t into FILETIME.
|
|
|
|
*
|
2000-09-29 22:48:04 +02:00
|
|
|
* Differences to UnixTimeToFileTime:
|
|
|
|
* 1) Divided by CLK_TCK
|
2002-06-01 01:06:46 +02:00
|
|
|
* 2) Time is relative. There is no 'starting date', so there is
|
2000-09-29 22:48:04 +02:00
|
|
|
* no need in offset correction, like in UnixTimeToFileTime
|
|
|
|
*/
|
|
|
|
static void TIME_ClockTimeToFileTime(clock_t unix_time, LPFILETIME filetime)
|
|
|
|
{
|
2002-05-29 19:04:10 +02:00
|
|
|
ULONGLONG secs = RtlEnlargedUnsignedMultiply( unix_time, 10000000 );
|
|
|
|
secs = RtlExtendedLargeIntegerDivide( secs, CLK_TCK, NULL );
|
|
|
|
filetime->dwLowDateTime = (DWORD)secs;
|
|
|
|
filetime->dwHighDateTime = (DWORD)(secs >> 32);
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* GetProcessTimes (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Get the user and kernel execution times of a process,
|
2000-12-20 00:33:03 +01:00
|
|
|
* along with the creation and exit times if known.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* TRUE.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* NOTES
|
|
|
|
* olorin@fandra.org:
|
|
|
|
* Would be nice to subtract the cpu time used by Wine at startup.
|
|
|
|
* Also, there is a need to separate times used by different applications.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* BUGS
|
2003-03-18 19:35:48 +01:00
|
|
|
* lpCreationTime and lpExitTime are not initialised in the Wine implementation.
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2000-12-20 00:33:03 +01:00
|
|
|
BOOL WINAPI GetProcessTimes(
|
2001-02-12 04:49:57 +01:00
|
|
|
HANDLE hprocess, /* [in] The process to be queried (obtained from PROCESS_QUERY_INFORMATION). */
|
|
|
|
LPFILETIME lpCreationTime, /* [out] The creation time of the process. */
|
|
|
|
LPFILETIME lpExitTime, /* [out] The exit time of the process if exited. */
|
|
|
|
LPFILETIME lpKernelTime, /* [out] The time spent in kernal routines in 100's of nanoseconds. */
|
|
|
|
LPFILETIME lpUserTime) /* [out] The time spent in user routines in 100's of nanoseconds. */
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
struct tms tms;
|
|
|
|
|
|
|
|
times(&tms);
|
|
|
|
TIME_ClockTimeToFileTime(tms.tms_utime,lpUserTime);
|
|
|
|
TIME_ClockTimeToFileTime(tms.tms_stime,lpKernelTime);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-02-26 23:33:29 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-19 05:36:23 +02:00
|
|
|
* GetCalendarInfoA (KERNEL32.@)
|
2001-02-26 23:33:29 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
int WINAPI GetCalendarInfoA(LCID Locale, CALID Calendar, CALTYPE CalType,
|
|
|
|
LPSTR lpCalData, int cchData, LPDWORD lpValue)
|
|
|
|
{
|
2002-05-14 23:44:07 +02:00
|
|
|
int ret;
|
|
|
|
LPWSTR lpCalDataW = NULL;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
FIXME("(%08lx,%08lx,%08lx,%p,%d,%p): quarter-stub\n",
|
2001-02-26 23:33:29 +01:00
|
|
|
Locale, Calendar, CalType, lpCalData, cchData, lpValue);
|
2002-05-14 23:44:07 +02:00
|
|
|
/* FIXME: Should verify if Locale is allowable in ANSI, as per MSDN */
|
2001-09-11 01:08:39 +02:00
|
|
|
|
2002-05-14 23:44:07 +02:00
|
|
|
if(cchData)
|
|
|
|
if(!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchData*sizeof(WCHAR)))) return 0;
|
|
|
|
|
|
|
|
ret = GetCalendarInfoW(Locale, Calendar, CalType, lpCalDataW, cchData, lpValue);
|
|
|
|
if(ret && lpCalDataW && lpCalData)
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpCalDataW, cchData, lpCalData, cchData, NULL, NULL);
|
|
|
|
if(lpCalDataW)
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpCalDataW);
|
|
|
|
|
|
|
|
return ret;
|
2001-02-26 23:33:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-19 05:36:23 +02:00
|
|
|
* GetCalendarInfoW (KERNEL32.@)
|
2001-02-26 23:33:29 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* See GetCalendarInfoA.
|
2001-02-26 23:33:29 +01:00
|
|
|
*/
|
|
|
|
int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType,
|
|
|
|
LPWSTR lpCalData, int cchData, LPDWORD lpValue)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
|
|
|
FIXME("(%08lx,%08lx,%08lx,%p,%d,%p): quarter-stub\n",
|
2001-02-26 23:33:29 +01:00
|
|
|
Locale, Calendar, CalType, lpCalData, cchData, lpValue);
|
2002-05-14 23:44:07 +02:00
|
|
|
|
|
|
|
if (CalType & CAL_NOUSEROVERRIDE)
|
|
|
|
FIXME("flag CAL_NOUSEROVERRIDE used, not fully implemented\n");
|
|
|
|
if (CalType & CAL_USE_CP_ACP)
|
|
|
|
FIXME("flag CAL_USE_CP_ACP used, not fully implemented\n");
|
|
|
|
|
|
|
|
if (CalType & CAL_RETURN_NUMBER) {
|
|
|
|
if (lpCalData != NULL)
|
|
|
|
WARN("lpCalData not NULL (%p) when it should!\n", lpCalData);
|
|
|
|
if (cchData != 0)
|
|
|
|
WARN("cchData not 0 (%d) when it should!\n", cchData);
|
|
|
|
} else {
|
|
|
|
if (lpValue != NULL)
|
|
|
|
WARN("lpValue not NULL (%p) when it should!\n", lpValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: No verification is made yet wrt Locale
|
|
|
|
* for the CALTYPES not requiring GetLocaleInfoA */
|
|
|
|
switch (CalType & ~(CAL_NOUSEROVERRIDE|CAL_RETURN_NUMBER|CAL_USE_CP_ACP)) {
|
|
|
|
case CAL_ICALINTVALUE:
|
|
|
|
FIXME("Unimplemented caltype %ld\n", CalType & 0xffff);
|
|
|
|
return E_FAIL;
|
|
|
|
case CAL_SCALNAME:
|
|
|
|
FIXME("Unimplemented caltype %ld\n", CalType & 0xffff);
|
|
|
|
return E_FAIL;
|
|
|
|
case CAL_IYEAROFFSETRANGE:
|
|
|
|
FIXME("Unimplemented caltype %ld\n", CalType & 0xffff);
|
|
|
|
return E_FAIL;
|
|
|
|
case CAL_SERASTRING:
|
|
|
|
FIXME("Unimplemented caltype %ld\n", CalType & 0xffff);
|
|
|
|
return E_FAIL;
|
|
|
|
case CAL_SSHORTDATE:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SSHORTDATE, lpCalData, cchData);
|
|
|
|
case CAL_SLONGDATE:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SLONGDATE, lpCalData, cchData);
|
|
|
|
case CAL_SDAYNAME1:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SDAYNAME1, lpCalData, cchData);
|
|
|
|
case CAL_SDAYNAME2:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SDAYNAME2, lpCalData, cchData);
|
|
|
|
case CAL_SDAYNAME3:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SDAYNAME3, lpCalData, cchData);
|
|
|
|
case CAL_SDAYNAME4:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SDAYNAME4, lpCalData, cchData);
|
|
|
|
case CAL_SDAYNAME5:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SDAYNAME5, lpCalData, cchData);
|
|
|
|
case CAL_SDAYNAME6:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SDAYNAME6, lpCalData, cchData);
|
|
|
|
case CAL_SDAYNAME7:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SDAYNAME7, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVDAYNAME1:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME1, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVDAYNAME2:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME2, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVDAYNAME3:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME3, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVDAYNAME4:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME4, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVDAYNAME5:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME5, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVDAYNAME6:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME6, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVDAYNAME7:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVDAYNAME7, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME1:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME1, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME2:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME2, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME3:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME3, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME4:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME4, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME5:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME5, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME6:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME6, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME7:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME7, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME8:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME8, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME9:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME9, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME10:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME10, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME11:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME11, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME12:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME12, lpCalData, cchData);
|
|
|
|
case CAL_SMONTHNAME13:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SMONTHNAME13, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME1:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME1, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME2:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME2, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME3:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME3, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME4:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME4, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME5:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME5, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME6:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME6, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME7:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME7, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME8:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME8, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME9:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME9, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME10:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME10, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME11:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME11, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME12:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME12, lpCalData, cchData);
|
|
|
|
case CAL_SABBREVMONTHNAME13:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SABBREVMONTHNAME13, lpCalData, cchData);
|
|
|
|
case CAL_SYEARMONTH:
|
|
|
|
return GetLocaleInfoW(Locale, LOCALE_SYEARMONTH, lpCalData, cchData);
|
|
|
|
case CAL_ITWODIGITYEARMAX:
|
2002-06-13 23:44:15 +02:00
|
|
|
if (lpValue) *lpValue = CALINFO_MAX_YEAR;
|
|
|
|
break;
|
2002-05-14 23:44:07 +02:00
|
|
|
default: MESSAGE("Unknown caltype %ld\n",CalType & 0xffff);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2001-02-26 23:33:29 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-19 05:36:23 +02:00
|
|
|
* SetCalendarInfoA (KERNEL32.@)
|
2001-02-26 23:33:29 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
int WINAPI SetCalendarInfoA(LCID Locale, CALID Calendar, CALTYPE CalType, LPCSTR lpCalData)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
FIXME("(%08lx,%08lx,%08lx,%s): stub\n",
|
2001-02-26 23:33:29 +01:00
|
|
|
Locale, Calendar, CalType, debugstr_a(lpCalData));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-19 05:36:23 +02:00
|
|
|
* SetCalendarInfoW (KERNEL32.@)
|
2001-02-26 23:33:29 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* See SetCalendarInfoA.
|
2001-02-26 23:33:29 +01:00
|
|
|
*/
|
|
|
|
int WINAPI SetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPCWSTR lpCalData)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
FIXME("(%08lx,%08lx,%08lx,%s): stub\n",
|
2001-02-26 23:33:29 +01:00
|
|
|
Locale, Calendar, CalType, debugstr_w(lpCalData));
|
|
|
|
return 0;
|
|
|
|
}
|
2002-12-11 01:19:56 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* LocalFileTimeToFileTime (KERNEL32.@)
|
|
|
|
*/
|
2002-12-13 21:53:04 +01:00
|
|
|
BOOL WINAPI LocalFileTimeToFileTime( const FILETIME *localft, LPFILETIME utcft )
|
2002-12-11 01:19:56 +01:00
|
|
|
{
|
|
|
|
NTSTATUS status;
|
2002-12-13 21:53:04 +01:00
|
|
|
LARGE_INTEGER local, utc;
|
|
|
|
|
|
|
|
local.s.LowPart = localft->dwLowDateTime;
|
|
|
|
local.s.HighPart = localft->dwHighDateTime;
|
|
|
|
if (!(status = RtlLocalTimeToSystemTime( &local, &utc )))
|
|
|
|
{
|
|
|
|
utcft->dwLowDateTime = utc.s.LowPart;
|
|
|
|
utcft->dwHighDateTime = utc.s.HighPart;
|
|
|
|
}
|
|
|
|
else SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
|
2002-12-11 01:19:56 +01:00
|
|
|
return !status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* FileTimeToLocalFileTime (KERNEL32.@)
|
|
|
|
*/
|
2002-12-13 21:53:04 +01:00
|
|
|
BOOL WINAPI FileTimeToLocalFileTime( const FILETIME *utcft, LPFILETIME localft )
|
2002-12-11 01:19:56 +01:00
|
|
|
{
|
|
|
|
NTSTATUS status;
|
2002-12-13 21:53:04 +01:00
|
|
|
LARGE_INTEGER local, utc;
|
|
|
|
|
|
|
|
utc.s.LowPart = utcft->dwLowDateTime;
|
|
|
|
utc.s.HighPart = utcft->dwHighDateTime;
|
|
|
|
if (!(status = RtlSystemTimeToLocalTime( &utc, &local )))
|
|
|
|
{
|
|
|
|
localft->dwLowDateTime = local.s.LowPart;
|
|
|
|
localft->dwHighDateTime = local.s.HighPart;
|
|
|
|
}
|
|
|
|
else SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
|
2002-12-11 01:19:56 +01:00
|
|
|
return !status;
|
|
|
|
}
|
2002-12-13 21:30:06 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* FileTimeToSystemTime (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileTimeToSystemTime( const FILETIME *ft, LPSYSTEMTIME syst )
|
|
|
|
{
|
|
|
|
TIME_FIELDS tf;
|
2002-12-13 21:53:04 +01:00
|
|
|
LARGE_INTEGER t;
|
2002-12-13 21:30:06 +01:00
|
|
|
|
2002-12-13 21:53:04 +01:00
|
|
|
t.s.LowPart = ft->dwLowDateTime;
|
|
|
|
t.s.HighPart = ft->dwHighDateTime;
|
|
|
|
RtlTimeToTimeFields(&t, &tf);
|
2002-12-13 21:30:06 +01:00
|
|
|
|
|
|
|
syst->wYear = tf.Year;
|
|
|
|
syst->wMonth = tf.Month;
|
|
|
|
syst->wDay = tf.Day;
|
|
|
|
syst->wHour = tf.Hour;
|
|
|
|
syst->wMinute = tf.Minute;
|
|
|
|
syst->wSecond = tf.Second;
|
|
|
|
syst->wMilliseconds = tf.Milliseconds;
|
|
|
|
syst->wDayOfWeek = tf.Weekday;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* SystemTimeToFileTime (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SystemTimeToFileTime( const SYSTEMTIME *syst, LPFILETIME ft )
|
|
|
|
{
|
|
|
|
TIME_FIELDS tf;
|
2002-12-13 21:53:04 +01:00
|
|
|
LARGE_INTEGER t;
|
2002-12-13 21:30:06 +01:00
|
|
|
|
|
|
|
tf.Year = syst->wYear;
|
|
|
|
tf.Month = syst->wMonth;
|
|
|
|
tf.Day = syst->wDay;
|
|
|
|
tf.Hour = syst->wHour;
|
|
|
|
tf.Minute = syst->wMinute;
|
|
|
|
tf.Second = syst->wSecond;
|
|
|
|
tf.Milliseconds = syst->wMilliseconds;
|
|
|
|
|
2002-12-13 21:53:04 +01:00
|
|
|
RtlTimeFieldsToTime(&tf, &t);
|
|
|
|
ft->dwLowDateTime = t.s.LowPart;
|
|
|
|
ft->dwHighDateTime = t.s.HighPart;
|
2002-12-13 21:30:06 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* CompareFileTime (KERNEL32.@)
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* Compare two FILETIME's to each other.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* x [I] First time
|
|
|
|
* y [I] time to compare to x
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* -1, 0, or 1 indicating that x is less than, equal to, or greater
|
|
|
|
* than y respectively.
|
2002-12-13 21:30:06 +01:00
|
|
|
*/
|
2002-12-13 21:53:04 +01:00
|
|
|
INT WINAPI CompareFileTime( const FILETIME *x, const FILETIME *y )
|
2002-12-13 21:30:06 +01:00
|
|
|
{
|
|
|
|
if (!x || !y) return -1;
|
|
|
|
|
|
|
|
if (x->dwHighDateTime > y->dwHighDateTime)
|
|
|
|
return 1;
|
|
|
|
if (x->dwHighDateTime < y->dwHighDateTime)
|
|
|
|
return -1;
|
|
|
|
if (x->dwLowDateTime > y->dwLowDateTime)
|
|
|
|
return 1;
|
|
|
|
if (x->dwLowDateTime < y->dwLowDateTime)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* GetLocalTime (KERNEL32.@)
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* Get the current local time.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
2002-12-13 21:30:06 +01:00
|
|
|
*/
|
2003-03-18 19:35:48 +01:00
|
|
|
VOID WINAPI GetLocalTime(LPSYSTEMTIME systime) /* [O] Destination for current time */
|
2002-12-13 21:30:06 +01:00
|
|
|
{
|
|
|
|
FILETIME lft;
|
2002-12-13 21:53:04 +01:00
|
|
|
LARGE_INTEGER ft, ft2;
|
2002-12-13 21:30:06 +01:00
|
|
|
|
|
|
|
NtQuerySystemTime(&ft);
|
2002-12-13 21:53:04 +01:00
|
|
|
RtlSystemTimeToLocalTime(&ft, &ft2);
|
|
|
|
lft.dwLowDateTime = ft2.s.LowPart;
|
|
|
|
lft.dwHighDateTime = ft2.s.HighPart;
|
2002-12-13 21:30:06 +01:00
|
|
|
FileTimeToSystemTime(&lft, systime);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* GetSystemTime (KERNEL32.@)
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* Get the current system time.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
2002-12-13 21:30:06 +01:00
|
|
|
*/
|
2003-03-18 19:35:48 +01:00
|
|
|
VOID WINAPI GetSystemTime(LPSYSTEMTIME systime) /* [O] Destination for current time */
|
2002-12-13 21:30:06 +01:00
|
|
|
{
|
|
|
|
FILETIME ft;
|
2002-12-13 21:53:04 +01:00
|
|
|
LARGE_INTEGER t;
|
2002-12-13 21:30:06 +01:00
|
|
|
|
2002-12-13 21:53:04 +01:00
|
|
|
NtQuerySystemTime(&t);
|
|
|
|
ft.dwLowDateTime = t.s.LowPart;
|
|
|
|
ft.dwHighDateTime = t.s.HighPart;
|
2002-12-13 21:30:06 +01:00
|
|
|
FileTimeToSystemTime(&ft, systime);
|
|
|
|
}
|