2000-09-29 20:48:04 +00:00
|
|
|
/*
|
2002-12-13 20:30:06 +00:00
|
|
|
* Win32 kernel time functions
|
2000-09-29 20:48:04 +00:00
|
|
|
*
|
|
|
|
* Copyright 1995 Martin von Loewis and Cameron Heide
|
2002-03-09 23:29:33 +00: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 20:48:04 +00:00
|
|
|
*/
|
|
|
|
|
2002-03-11 05:08:38 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-09-29 20:48:04 +00:00
|
|
|
#include <string.h>
|
2002-08-17 00:43:16 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2004-03-09 23:51:02 +00:00
|
|
|
#include <stdarg.h>
|
2000-11-01 03:11:12 +00:00
|
|
|
#include <stdlib.h>
|
2004-03-09 23:51:02 +00:00
|
|
|
#include <time.h>
|
2002-08-17 00:43:16 +00:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
2002-08-26 21:53:24 +00:00
|
|
|
#ifdef HAVE_SYS_TIMES_H
|
|
|
|
# include <sys/times.h>
|
|
|
|
#endif
|
2005-05-18 18:20:23 +00:00
|
|
|
#ifdef HAVE_MACHINE_LIMITS_H
|
|
|
|
#include <machine/limits.h>
|
|
|
|
#endif
|
2003-01-07 20:36:20 +00:00
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2004-03-09 23:51:02 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2002-09-12 22:07:02 +00:00
|
|
|
#include "winternl.h"
|
2005-06-20 18:37:17 +00:00
|
|
|
#include "ntstatus.h"
|
2003-12-01 22:47:28 +00:00
|
|
|
#include "kernel_private.h"
|
2001-04-09 18:45:49 +00:00
|
|
|
#include "wine/unicode.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
2000-09-29 20:48:04 +00:00
|
|
|
|
2004-02-26 05:29:55 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(time);
|
2000-09-29 20:48:04 +00:00
|
|
|
|
|
|
|
/* maximum time adjustment in seconds for SetLocalTime and SetSystemTime */
|
|
|
|
#define SETTIME_MAX_ADJUST 120
|
2002-06-13 21:44:15 +00:00
|
|
|
#define CALINFO_MAX_YEAR 2029
|
2000-09-29 20:48:04 +00:00
|
|
|
|
2004-09-10 19:35:06 +00:00
|
|
|
#define LL2FILETIME( ll, pft )\
|
|
|
|
(pft)->dwLowDateTime = (UINT)(ll); \
|
|
|
|
(pft)->dwHighDateTime = (UINT)((ll) >> 32);
|
|
|
|
#define FILETIME2LL( pft, ll) \
|
|
|
|
ll = (((LONGLONG)((pft)->dwHighDateTime))<<32) + (pft)-> dwLowDateTime ;
|
2001-04-09 18:45:49 +00:00
|
|
|
|
2004-10-29 21:27:18 +00:00
|
|
|
|
|
|
|
static const int MonthLengths[2][12] =
|
|
|
|
{
|
|
|
|
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
|
|
|
|
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline int IsLeapYear(int Year)
|
|
|
|
{
|
|
|
|
return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2000-09-29 20:48:04 +00:00
|
|
|
/***********************************************************************
|
2004-10-27 21:19:22 +00:00
|
|
|
* TIME_DayLightCompareDate
|
2002-12-19 04:12:42 +00:00
|
|
|
*
|
|
|
|
* Compares two dates without looking at the year
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* -1 if date < compareDate
|
|
|
|
* 0 if date == compareDate
|
|
|
|
* 1 if date > compareDate
|
2004-12-20 19:27:06 +00:00
|
|
|
* -2 if an error occurs
|
2002-12-19 04:12:42 +00:00
|
|
|
*/
|
2004-10-27 21:19:22 +00:00
|
|
|
static int TIME_DayLightCompareDate(
|
|
|
|
const SYSTEMTIME *date, /* [in] The local time to compare. */
|
|
|
|
const SYSTEMTIME *compareDate) /* [in] The daylight saving begin
|
2004-09-10 19:35:06 +00:00
|
|
|
or end date */
|
2002-12-19 04:12:42 +00:00
|
|
|
{
|
2004-09-10 19:35:06 +00:00
|
|
|
int limit_day, dayinsecs;
|
2002-12-19 04:12:42 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2004-10-29 21:27:18 +00:00
|
|
|
WORD First;
|
|
|
|
/* 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 the day of the first DayOfWeek in the month */
|
|
|
|
First = ( 6 + compareDate->wDayOfWeek - date->wDayOfWeek + date->wDay
|
|
|
|
) % 7 + 1;
|
|
|
|
limit_day = First + 7 * (weekofmonth - 1);
|
|
|
|
/* check needed for the 5th weekday of the month */
|
|
|
|
if(limit_day > MonthLengths[date->wMonth==2 && IsLeapYear(date->wYear)]
|
|
|
|
[date->wMonth - 1])
|
|
|
|
limit_day -= 7;
|
2002-12-19 04:12:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
limit_day = compareDate->wDay;
|
|
|
|
}
|
|
|
|
|
2004-09-10 19:35:06 +00:00
|
|
|
/* convert to seconds */
|
|
|
|
limit_day = ((limit_day * 24 + compareDate->wHour) * 60 +
|
|
|
|
compareDate->wMinute ) * 60;
|
|
|
|
dayinsecs = ((date->wDay * 24 + date->wHour) * 60 +
|
|
|
|
date->wMinute ) * 60 + date->wSecond;
|
|
|
|
/* and compare */
|
|
|
|
return dayinsecs < limit_day ? -1 :
|
|
|
|
dayinsecs > limit_day ? 1 :
|
|
|
|
0; /* date is equal to the date limit. */
|
2002-12-19 04:12:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2004-10-27 21:19:22 +00:00
|
|
|
* TIME_CompTimeZoneID
|
2002-12-19 04:12:42 +00:00
|
|
|
*
|
2004-10-27 21:19:22 +00:00
|
|
|
* Computes the local time bias for a given time and time zone
|
2002-12-19 04:12:42 +00:00
|
|
|
*
|
2004-10-27 21:19:22 +00:00
|
|
|
* Returns:
|
|
|
|
* TIME_ZONE_ID_INVALID An error occurred
|
|
|
|
* TIME_ZONE_ID_UNKNOWN There are no transition time known
|
|
|
|
* TIME_ZONE_ID_STANDARD Current time is standard time
|
|
|
|
* TIME_ZONE_ID_DAYLIGHT Current time is dayligh saving time
|
2002-12-19 04:12:42 +00:00
|
|
|
*/
|
2004-10-27 21:19:22 +00:00
|
|
|
static BOOL TIME_CompTimeZoneID (
|
|
|
|
const TIME_ZONE_INFORMATION *pTZinfo, /* [in] The time zone data. */
|
|
|
|
FILETIME *lpFileTime, /* [in] The system or local time. */
|
|
|
|
BOOL islocal /* [in] it is local time */
|
2004-09-10 19:35:06 +00:00
|
|
|
)
|
2002-12-19 04:12:42 +00:00
|
|
|
{
|
|
|
|
int ret;
|
2003-04-17 02:14:38 +00:00
|
|
|
BOOL beforeStandardDate, afterDaylightDate;
|
2004-10-27 21:19:22 +00:00
|
|
|
DWORD retval = TIME_ZONE_ID_INVALID;
|
2004-09-10 19:35:06 +00:00
|
|
|
LONGLONG llTime = 0; /* initialized to prevent gcc complaining */
|
2004-10-27 21:19:22 +00:00
|
|
|
SYSTEMTIME SysTime;
|
|
|
|
FILETIME ftTemp;
|
2002-12-19 04:12:42 +00:00
|
|
|
|
2004-10-27 21:19:22 +00:00
|
|
|
if (pTZinfo->DaylightDate.wMonth != 0)
|
2002-12-19 04:12:42 +00:00
|
|
|
{
|
2004-10-27 21:19:22 +00:00
|
|
|
if (pTZinfo->StandardDate.wMonth == 0 ||
|
|
|
|
pTZinfo->StandardDate.wDay<1 ||
|
|
|
|
pTZinfo->StandardDate.wDay>5 ||
|
|
|
|
pTZinfo->DaylightDate.wDay<1 ||
|
|
|
|
pTZinfo->DaylightDate.wDay>5)
|
2002-12-19 04:12:42 +00:00
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
2004-10-27 21:19:22 +00:00
|
|
|
return TIME_ZONE_ID_INVALID;
|
2002-12-19 04:12:42 +00:00
|
|
|
}
|
|
|
|
|
2004-09-10 19:35:06 +00:00
|
|
|
if (!islocal) {
|
2004-10-27 21:19:22 +00:00
|
|
|
FILETIME2LL( lpFileTime, llTime );
|
|
|
|
llTime -= ( pTZinfo->Bias + pTZinfo->DaylightBias )
|
|
|
|
* (LONGLONG)600000000;
|
|
|
|
LL2FILETIME( llTime, &ftTemp)
|
|
|
|
lpFileTime = &ftTemp;
|
2004-09-10 19:35:06 +00:00
|
|
|
}
|
2004-10-27 21:19:22 +00:00
|
|
|
|
|
|
|
FileTimeToSystemTime(lpFileTime, &SysTime);
|
2004-09-10 19:35:06 +00:00
|
|
|
|
2002-12-19 04:12:42 +00:00
|
|
|
/* check for daylight saving */
|
2004-10-27 21:19:22 +00:00
|
|
|
ret = TIME_DayLightCompareDate( &SysTime, &pTZinfo->StandardDate);
|
2003-04-17 02:14:38 +00:00
|
|
|
if (ret == -2)
|
2004-10-27 21:19:22 +00:00
|
|
|
return TIME_ZONE_ID_INVALID;
|
2002-12-19 04:12:42 +00:00
|
|
|
|
2003-04-17 02:14:38 +00:00
|
|
|
beforeStandardDate = ret < 0;
|
2002-12-19 04:12:42 +00:00
|
|
|
|
2004-09-10 19:35:06 +00:00
|
|
|
if (!islocal) {
|
2004-10-27 21:19:22 +00:00
|
|
|
llTime -= ( pTZinfo->StandardBias - pTZinfo->DaylightBias )
|
|
|
|
* (LONGLONG)600000000;
|
|
|
|
LL2FILETIME( llTime, &ftTemp)
|
|
|
|
FileTimeToSystemTime(lpFileTime, &SysTime);
|
2004-09-10 19:35:06 +00:00
|
|
|
}
|
|
|
|
|
2004-10-27 21:19:22 +00:00
|
|
|
ret = TIME_DayLightCompareDate( &SysTime, &pTZinfo->DaylightDate);
|
2003-04-17 02:14:38 +00:00
|
|
|
if (ret == -2)
|
2004-10-27 21:19:22 +00:00
|
|
|
return TIME_ZONE_ID_INVALID;
|
2002-12-19 04:12:42 +00:00
|
|
|
|
2003-04-17 02:14:38 +00:00
|
|
|
afterDaylightDate = ret >= 0;
|
2002-12-19 04:12:42 +00:00
|
|
|
|
2004-10-27 21:19:22 +00:00
|
|
|
retval = TIME_ZONE_ID_STANDARD;
|
|
|
|
if( pTZinfo->DaylightDate.wMonth < pTZinfo->StandardDate.wMonth ) {
|
|
|
|
/* Northern hemisphere */
|
2004-09-10 19:35:06 +00:00
|
|
|
if( beforeStandardDate && afterDaylightDate )
|
2004-10-27 21:19:22 +00:00
|
|
|
retval = TIME_ZONE_ID_DAYLIGHT;
|
2004-09-10 19:35:06 +00:00
|
|
|
} else /* Down south */
|
|
|
|
if( beforeStandardDate || afterDaylightDate )
|
2004-10-27 21:19:22 +00:00
|
|
|
retval = TIME_ZONE_ID_DAYLIGHT;
|
|
|
|
} else
|
|
|
|
/* No transition date */
|
|
|
|
retval = TIME_ZONE_ID_UNKNOWN;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TIME_TimeZoneID
|
|
|
|
*
|
|
|
|
* Calculates whether daylight saving is on now.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* TIME_ZONE_ID_INVALID An error occurred
|
|
|
|
* TIME_ZONE_ID_UNKNOWN There are no transition time known
|
|
|
|
* TIME_ZONE_ID_STANDARD Current time is standard time
|
|
|
|
* TIME_ZONE_ID_DAYLIGHT Current time is dayligh saving time
|
|
|
|
*/
|
|
|
|
static DWORD TIME_ZoneID(
|
|
|
|
const TIME_ZONE_INFORMATION *pTzi /* Timezone info */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FILETIME ftTime;
|
|
|
|
GetSystemTimeAsFileTime( &ftTime);
|
|
|
|
return TIME_CompTimeZoneID( pTzi, &ftTime, FALSE);
|
|
|
|
}
|
2002-12-19 04:12:42 +00:00
|
|
|
|
2004-10-27 21:19:22 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* TIME_GetTimezoneBias
|
|
|
|
*
|
|
|
|
* Calculates the local time bias for a given time zone
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* Returns TRUE when the time zone bias was calculated.
|
|
|
|
*/
|
|
|
|
static BOOL TIME_GetTimezoneBias(
|
|
|
|
const TIME_ZONE_INFORMATION
|
|
|
|
*pTZinfo, /* [in] The time zone data. */
|
|
|
|
FILETIME *lpFileTime, /* [in] The system or local time. */
|
|
|
|
BOOL islocal, /* [in] it is local time */
|
2005-02-25 14:07:56 +00:00
|
|
|
LONG *pBias /* [out] The calculated bias in minutes */
|
2004-10-27 21:19:22 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
LONG bias = pTZinfo->Bias;
|
|
|
|
DWORD tzid = TIME_CompTimeZoneID( pTZinfo, lpFileTime, islocal);
|
2002-12-19 04:12:42 +00:00
|
|
|
|
2004-10-27 21:19:22 +00:00
|
|
|
if( tzid == TIME_ZONE_ID_INVALID)
|
|
|
|
return FALSE;
|
|
|
|
if (tzid == TIME_ZONE_ID_DAYLIGHT)
|
|
|
|
bias += pTZinfo->DaylightBias;
|
|
|
|
else if (tzid == TIME_ZONE_ID_STANDARD)
|
|
|
|
bias += pTZinfo->StandardBias;
|
2002-12-19 04:12:42 +00:00
|
|
|
*pBias = bias;
|
2004-10-27 21:19:22 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetLocalTime (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Set the local time using current time zone and daylight
|
|
|
|
* savings settings.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. The time was set
|
|
|
|
* Failure: FALSE, if the time was invalid or caller does not have
|
|
|
|
* permission to change the time.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetLocalTime(
|
|
|
|
const SYSTEMTIME *systime) /* [in] The desired local time. */
|
|
|
|
{
|
|
|
|
FILETIME ft;
|
|
|
|
LARGE_INTEGER st, st2;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
2004-11-06 03:53:53 +00:00
|
|
|
if( !SystemTimeToFileTime( systime, &ft ))
|
|
|
|
return FALSE;
|
2004-10-27 21:19:22 +00:00
|
|
|
st.u.LowPart = ft.dwLowDateTime;
|
|
|
|
st.u.HighPart = ft.dwHighDateTime;
|
|
|
|
RtlLocalTimeToSystemTime( &st, &st2 );
|
|
|
|
|
|
|
|
if ((status = NtSetSystemTime(&st2, NULL)))
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetSystemTimeAdjustment (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE.
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Only the special case of disabled time adjustments is supported.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetSystemTimeAdjustment(
|
2005-02-25 14:07:56 +00:00
|
|
|
PDWORD lpTimeAdjustment, /* [out] The clock adjustment per interrupt in 100's of nanoseconds. */
|
|
|
|
PDWORD lpTimeIncrement, /* [out] The time between clock interrupts in 100's of nanoseconds. */
|
|
|
|
PBOOL lpTimeAdjustmentDisabled) /* [out] The clock synchronisation has been disabled. */
|
2004-10-27 21:19:22 +00:00
|
|
|
{
|
|
|
|
*lpTimeAdjustment = 0;
|
|
|
|
*lpTimeIncrement = 0;
|
|
|
|
*lpTimeAdjustmentDisabled = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-12-19 04:12:42 +00:00
|
|
|
|
2004-10-27 21:19:22 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* SetSystemTime (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Set the system time in utc.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. The time was set
|
|
|
|
* Failure: FALSE, if the time was invalid or caller does not have
|
|
|
|
* permission to change the time.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetSystemTime(
|
|
|
|
const SYSTEMTIME *systime) /* [in] The desired system time. */
|
|
|
|
{
|
|
|
|
FILETIME ft;
|
|
|
|
LARGE_INTEGER t;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
2004-11-06 03:53:53 +00:00
|
|
|
if( !SystemTimeToFileTime( systime, &ft ))
|
|
|
|
return FALSE;
|
2004-10-27 21:19:22 +00:00
|
|
|
t.u.LowPart = ft.dwLowDateTime;
|
|
|
|
t.u.HighPart = ft.dwHighDateTime;
|
|
|
|
if ((status = NtSetSystemTime(&t, NULL)))
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetSystemTimeAdjustment (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Enables or disables the timing adjustments to the system's clock.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE.
|
|
|
|
* Failure: FALSE.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetSystemTimeAdjustment(
|
|
|
|
DWORD dwTimeAdjustment,
|
|
|
|
BOOL bTimeAdjustmentDisabled)
|
|
|
|
{
|
|
|
|
/* Fake function for now... */
|
|
|
|
FIXME("(%08lx,%d): stub !\n", dwTimeAdjustment, bTimeAdjustmentDisabled);
|
2002-12-19 04:12:42 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-10-27 21:19:22 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetTimeZoneInformation (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Get information about the current local time zone.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TIME_ZONE_ID_INVALID An error occurred
|
|
|
|
* TIME_ZONE_ID_UNKNOWN There are no transition time known
|
|
|
|
* TIME_ZONE_ID_STANDARD Current time is standard time
|
|
|
|
* TIME_ZONE_ID_DAYLIGHT Current time is dayligh saving time
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetTimeZoneInformation(
|
|
|
|
LPTIME_ZONE_INFORMATION tzinfo) /* [out] Destination for time zone information */
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
2005-06-20 18:37:17 +00:00
|
|
|
|
|
|
|
status = RtlQueryTimeZoneInformation( (RTL_TIME_ZONE_INFORMATION*)tzinfo );
|
|
|
|
if ( status != STATUS_SUCCESS )
|
|
|
|
{
|
2004-10-27 21:19:22 +00:00
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return TIME_ZONE_ID_INVALID;
|
|
|
|
}
|
|
|
|
return TIME_ZoneID( tzinfo );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetTimeZoneInformation (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Change the settings of the current local time zone.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE. The time zone was updated with the settings from tzinfo
|
|
|
|
* Failure: FALSE.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetTimeZoneInformation(
|
|
|
|
const TIME_ZONE_INFORMATION *tzinfo) /* [in] The new time zone. */
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
2005-06-20 18:37:17 +00:00
|
|
|
status = RtlSetTimeZoneInformation( (RTL_TIME_ZONE_INFORMATION*) tzinfo );
|
|
|
|
if ( status != STATUS_SUCCESS )
|
2004-10-27 21:19:22 +00:00
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
|
|
|
}
|
2002-12-19 04:12:42 +00:00
|
|
|
|
2000-09-29 20:48:04 +00:00
|
|
|
/***********************************************************************
|
2001-06-13 20:13:18 +00:00
|
|
|
* SystemTimeToTzSpecificLocalTime (KERNEL32.@)
|
2000-12-19 23:33:03 +00:00
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* Convert a utc system time to a local time in a given time zone.
|
2000-12-19 23:33:03 +00:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 18:35:48 +00:00
|
|
|
* Success: TRUE. lpLocalTime contains the converted time
|
|
|
|
* Failure: FALSE.
|
2000-09-29 20:48:04 +00:00
|
|
|
*/
|
2002-12-19 04:12:42 +00:00
|
|
|
|
2000-09-29 20:48:04 +00:00
|
|
|
BOOL WINAPI SystemTimeToTzSpecificLocalTime(
|
2004-09-10 19:35:06 +00: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 20:48:04 +00:00
|
|
|
{
|
2002-12-19 04:12:42 +00:00
|
|
|
FILETIME ft;
|
|
|
|
LONG lBias;
|
2004-09-10 19:35:06 +00:00
|
|
|
LONGLONG llTime;
|
2002-12-19 04:12:42 +00:00
|
|
|
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;
|
2004-09-10 19:35:06 +00:00
|
|
|
FILETIME2LL( &ft, llTime)
|
2004-10-27 21:19:22 +00:00
|
|
|
if (!TIME_GetTimezoneBias(&tzinfo, &ft, FALSE, &lBias))
|
2002-12-19 04:12:42 +00:00
|
|
|
return FALSE;
|
2004-09-10 19:35:06 +00:00
|
|
|
/* convert minutes to 100-nanoseconds-ticks */
|
|
|
|
llTime -= (LONGLONG)lBias * 600000000;
|
|
|
|
LL2FILETIME( llTime, &ft)
|
2002-12-19 04:12:42 +00:00
|
|
|
|
|
|
|
return FileTimeToSystemTime(&ft, lpLocalTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TzSpecificLocalTimeToSystemTime (KERNEL32.@)
|
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* Converts a local time to a time in utc.
|
2002-12-19 04:12:42 +00:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 18:35:48 +00:00
|
|
|
* Success: TRUE. lpUniversalTime contains the converted time
|
|
|
|
* Failure: FALSE.
|
2002-12-19 04:12:42 +00: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;
|
2004-09-10 19:35:06 +00:00
|
|
|
LONGLONG t;
|
2002-12-19 04:12:42 +00:00
|
|
|
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;
|
2004-09-10 19:35:06 +00:00
|
|
|
FILETIME2LL( &ft, t)
|
2004-10-27 21:19:22 +00:00
|
|
|
if (!TIME_GetTimezoneBias(&tzinfo, &ft, TRUE, &lBias))
|
2002-12-19 04:12:42 +00:00
|
|
|
return FALSE;
|
2004-09-10 19:35:06 +00:00
|
|
|
/* convert minutes to 100-nanoseconds-ticks */
|
|
|
|
t += (LONGLONG)lBias * 600000000;
|
|
|
|
LL2FILETIME( t, &ft)
|
2002-12-19 04:12:42 +00:00
|
|
|
return FileTimeToSystemTime(&ft, lpUniversalTime);
|
2000-09-29 20:48:04 +00:00
|
|
|
}
|
|
|
|
|
2000-10-01 01:40:42 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 20:13:18 +00:00
|
|
|
* GetSystemTimeAsFileTime (KERNEL32.@)
|
2000-12-19 23:33:03 +00:00
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* Get the current time in utc format.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
2000-10-01 01:40:42 +00:00
|
|
|
*/
|
2000-12-19 23:33:03 +00:00
|
|
|
VOID WINAPI GetSystemTimeAsFileTime(
|
2003-03-18 18:35:48 +00:00
|
|
|
LPFILETIME time) /* [out] Destination for the current utc time */
|
2000-10-01 01:40:42 +00:00
|
|
|
{
|
2002-12-13 20:53:04 +00:00
|
|
|
LARGE_INTEGER t;
|
|
|
|
NtQuerySystemTime( &t );
|
2004-01-23 01:51:33 +00:00
|
|
|
time->dwLowDateTime = t.u.LowPart;
|
|
|
|
time->dwHighDateTime = t.u.HighPart;
|
2000-10-01 01:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 20:48:04 +00:00
|
|
|
/*********************************************************************
|
2000-12-19 23:33:03 +00:00
|
|
|
* TIME_ClockTimeToFileTime (olorin@fandra.org, 20-Sep-1998)
|
|
|
|
*
|
|
|
|
* Used by GetProcessTimes to convert clock_t into FILETIME.
|
|
|
|
*
|
2000-09-29 20:48:04 +00:00
|
|
|
* Differences to UnixTimeToFileTime:
|
|
|
|
* 1) Divided by CLK_TCK
|
2002-05-31 23:06:46 +00:00
|
|
|
* 2) Time is relative. There is no 'starting date', so there is
|
2003-08-18 19:47:42 +00:00
|
|
|
* no need for offset correction, like in UnixTimeToFileTime
|
2000-09-29 20:48:04 +00:00
|
|
|
*/
|
|
|
|
static void TIME_ClockTimeToFileTime(clock_t unix_time, LPFILETIME filetime)
|
|
|
|
{
|
2002-05-29 17:04:10 +00: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 20:48:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-13 20:13:18 +00:00
|
|
|
* GetProcessTimes (KERNEL32.@)
|
2000-09-29 20:48:04 +00:00
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* Get the user and kernel execution times of a process,
|
2000-12-19 23:33:03 +00:00
|
|
|
* along with the creation and exit times if known.
|
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 18:35:48 +00:00
|
|
|
* TRUE.
|
2000-12-19 23:33:03 +00:00
|
|
|
*
|
2003-03-18 18:35:48 +00: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-19 23:33:03 +00:00
|
|
|
*
|
|
|
|
* BUGS
|
2003-03-18 18:35:48 +00:00
|
|
|
* lpCreationTime and lpExitTime are not initialised in the Wine implementation.
|
2000-09-29 20:48:04 +00:00
|
|
|
*/
|
2000-12-19 23:33:03 +00:00
|
|
|
BOOL WINAPI GetProcessTimes(
|
2001-02-12 03:49:57 +00: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. */
|
2005-02-25 14:07:56 +00:00
|
|
|
LPFILETIME lpKernelTime, /* [out] The time spent in kernel routines in 100's of nanoseconds. */
|
2001-02-12 03:49:57 +00:00
|
|
|
LPFILETIME lpUserTime) /* [out] The time spent in user routines in 100's of nanoseconds. */
|
2000-09-29 20:48:04 +00:00
|
|
|
{
|
|
|
|
struct tms tms;
|
|
|
|
|
|
|
|
times(&tms);
|
|
|
|
TIME_ClockTimeToFileTime(tms.tms_utime,lpUserTime);
|
|
|
|
TIME_ClockTimeToFileTime(tms.tms_stime,lpKernelTime);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-02-26 22:33:29 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-19 03:36:23 +00:00
|
|
|
* GetCalendarInfoA (KERNEL32.@)
|
2001-02-26 22:33:29 +00:00
|
|
|
*
|
|
|
|
*/
|
2003-12-01 22:47:28 +00:00
|
|
|
int WINAPI GetCalendarInfoA(LCID lcid, CALID Calendar, CALTYPE CalType,
|
2001-02-26 22:33:29 +00:00
|
|
|
LPSTR lpCalData, int cchData, LPDWORD lpValue)
|
|
|
|
{
|
2002-05-14 21:44:07 +00:00
|
|
|
int ret;
|
|
|
|
LPWSTR lpCalDataW = NULL;
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
FIXME("(%08lx,%08lx,%08lx,%p,%d,%p): quarter-stub\n",
|
2003-12-01 22:47:28 +00:00
|
|
|
lcid, Calendar, CalType, lpCalData, cchData, lpValue);
|
2001-09-10 23:08:39 +00:00
|
|
|
|
2003-12-01 22:47:28 +00:00
|
|
|
lcid = ConvertDefaultLocale(lcid);
|
2002-05-14 21:44:07 +00:00
|
|
|
|
2003-12-01 22:47:28 +00:00
|
|
|
if (NLS_IsUnicodeOnlyLcid(lcid))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cchData &&
|
|
|
|
!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchData*sizeof(WCHAR))))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ret = GetCalendarInfoW(lcid, Calendar, CalType, lpCalDataW, cchData, lpValue);
|
2002-05-14 21:44:07 +00:00
|
|
|
if(ret && lpCalDataW && lpCalData)
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, lpCalDataW, cchData, lpCalData, cchData, NULL, NULL);
|
2004-12-23 17:06:43 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpCalDataW);
|
2002-05-14 21:44:07 +00:00
|
|
|
|
|
|
|
return ret;
|
2001-02-26 22:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-19 03:36:23 +00:00
|
|
|
* GetCalendarInfoW (KERNEL32.@)
|
2001-02-26 22:33:29 +00:00
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* See GetCalendarInfoA.
|
2001-02-26 22:33:29 +00:00
|
|
|
*/
|
|
|
|
int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType,
|
|
|
|
LPWSTR lpCalData, int cchData, LPDWORD lpValue)
|
2002-05-31 23:06:46 +00:00
|
|
|
{
|
|
|
|
FIXME("(%08lx,%08lx,%08lx,%p,%d,%p): quarter-stub\n",
|
2001-02-26 22:33:29 +00:00
|
|
|
Locale, Calendar, CalType, lpCalData, cchData, lpValue);
|
2002-05-14 21:44:07 +00: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 21:44:15 +00:00
|
|
|
if (lpValue) *lpValue = CALINFO_MAX_YEAR;
|
|
|
|
break;
|
2002-05-14 21:44:07 +00:00
|
|
|
default: MESSAGE("Unknown caltype %ld\n",CalType & 0xffff);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2001-02-26 22:33:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-19 03:36:23 +00:00
|
|
|
* SetCalendarInfoA (KERNEL32.@)
|
2001-02-26 22:33:29 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
int WINAPI SetCalendarInfoA(LCID Locale, CALID Calendar, CALTYPE CalType, LPCSTR lpCalData)
|
|
|
|
{
|
2002-05-31 23:06:46 +00:00
|
|
|
FIXME("(%08lx,%08lx,%08lx,%s): stub\n",
|
2001-02-26 22:33:29 +00:00
|
|
|
Locale, Calendar, CalType, debugstr_a(lpCalData));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2001-06-19 03:36:23 +00:00
|
|
|
* SetCalendarInfoW (KERNEL32.@)
|
2001-02-26 22:33:29 +00:00
|
|
|
*
|
2003-03-18 18:35:48 +00:00
|
|
|
* See SetCalendarInfoA.
|
2001-02-26 22:33:29 +00:00
|
|
|
*/
|
|
|
|
int WINAPI SetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPCWSTR lpCalData)
|
|
|
|
{
|
2002-05-31 23:06:46 +00:00
|
|
|
FIXME("(%08lx,%08lx,%08lx,%s): stub\n",
|
2001-02-26 22:33:29 +00:00
|
|
|
Locale, Calendar, CalType, debugstr_w(lpCalData));
|
|
|
|
return 0;
|
|
|
|
}
|
2002-12-11 00:19:56 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* LocalFileTimeToFileTime (KERNEL32.@)
|
|
|
|
*/
|
2002-12-13 20:53:04 +00:00
|
|
|
BOOL WINAPI LocalFileTimeToFileTime( const FILETIME *localft, LPFILETIME utcft )
|
2002-12-11 00:19:56 +00:00
|
|
|
{
|
|
|
|
NTSTATUS status;
|
2002-12-13 20:53:04 +00:00
|
|
|
LARGE_INTEGER local, utc;
|
|
|
|
|
2004-01-23 01:51:33 +00:00
|
|
|
local.u.LowPart = localft->dwLowDateTime;
|
|
|
|
local.u.HighPart = localft->dwHighDateTime;
|
2002-12-13 20:53:04 +00:00
|
|
|
if (!(status = RtlLocalTimeToSystemTime( &local, &utc )))
|
|
|
|
{
|
2004-01-23 01:51:33 +00:00
|
|
|
utcft->dwLowDateTime = utc.u.LowPart;
|
|
|
|
utcft->dwHighDateTime = utc.u.HighPart;
|
2002-12-13 20:53:04 +00:00
|
|
|
}
|
|
|
|
else SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
|
2002-12-11 00:19:56 +00:00
|
|
|
return !status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* FileTimeToLocalFileTime (KERNEL32.@)
|
|
|
|
*/
|
2002-12-13 20:53:04 +00:00
|
|
|
BOOL WINAPI FileTimeToLocalFileTime( const FILETIME *utcft, LPFILETIME localft )
|
2002-12-11 00:19:56 +00:00
|
|
|
{
|
|
|
|
NTSTATUS status;
|
2002-12-13 20:53:04 +00:00
|
|
|
LARGE_INTEGER local, utc;
|
|
|
|
|
2004-01-23 01:51:33 +00:00
|
|
|
utc.u.LowPart = utcft->dwLowDateTime;
|
|
|
|
utc.u.HighPart = utcft->dwHighDateTime;
|
2002-12-13 20:53:04 +00:00
|
|
|
if (!(status = RtlSystemTimeToLocalTime( &utc, &local )))
|
|
|
|
{
|
2004-01-23 01:51:33 +00:00
|
|
|
localft->dwLowDateTime = local.u.LowPart;
|
|
|
|
localft->dwHighDateTime = local.u.HighPart;
|
2002-12-13 20:53:04 +00:00
|
|
|
}
|
|
|
|
else SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
|
2002-12-11 00:19:56 +00:00
|
|
|
return !status;
|
|
|
|
}
|
2002-12-13 20:30:06 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* FileTimeToSystemTime (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileTimeToSystemTime( const FILETIME *ft, LPSYSTEMTIME syst )
|
|
|
|
{
|
|
|
|
TIME_FIELDS tf;
|
2002-12-13 20:53:04 +00:00
|
|
|
LARGE_INTEGER t;
|
2002-12-13 20:30:06 +00:00
|
|
|
|
2004-01-23 01:51:33 +00:00
|
|
|
t.u.LowPart = ft->dwLowDateTime;
|
|
|
|
t.u.HighPart = ft->dwHighDateTime;
|
2002-12-13 20:53:04 +00:00
|
|
|
RtlTimeToTimeFields(&t, &tf);
|
2002-12-13 20:30:06 +00: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 20:53:04 +00:00
|
|
|
LARGE_INTEGER t;
|
2002-12-13 20:30:06 +00: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;
|
|
|
|
|
2004-11-06 03:53:53 +00:00
|
|
|
if( !RtlTimeFieldsToTime(&tf, &t)) {
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-01-23 01:51:33 +00:00
|
|
|
ft->dwLowDateTime = t.u.LowPart;
|
|
|
|
ft->dwHighDateTime = t.u.HighPart;
|
2002-12-13 20:30:06 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* CompareFileTime (KERNEL32.@)
|
2003-03-18 18:35:48 +00: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 20:30:06 +00:00
|
|
|
*/
|
2002-12-13 20:53:04 +00:00
|
|
|
INT WINAPI CompareFileTime( const FILETIME *x, const FILETIME *y )
|
2002-12-13 20:30:06 +00: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 18:35:48 +00:00
|
|
|
*
|
|
|
|
* Get the current local time.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
2002-12-13 20:30:06 +00:00
|
|
|
*/
|
2003-03-18 18:35:48 +00:00
|
|
|
VOID WINAPI GetLocalTime(LPSYSTEMTIME systime) /* [O] Destination for current time */
|
2002-12-13 20:30:06 +00:00
|
|
|
{
|
|
|
|
FILETIME lft;
|
2002-12-13 20:53:04 +00:00
|
|
|
LARGE_INTEGER ft, ft2;
|
2002-12-13 20:30:06 +00:00
|
|
|
|
|
|
|
NtQuerySystemTime(&ft);
|
2002-12-13 20:53:04 +00:00
|
|
|
RtlSystemTimeToLocalTime(&ft, &ft2);
|
2004-01-23 01:51:33 +00:00
|
|
|
lft.dwLowDateTime = ft2.u.LowPart;
|
|
|
|
lft.dwHighDateTime = ft2.u.HighPart;
|
2002-12-13 20:30:06 +00:00
|
|
|
FileTimeToSystemTime(&lft, systime);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* GetSystemTime (KERNEL32.@)
|
2003-03-18 18:35:48 +00:00
|
|
|
*
|
|
|
|
* Get the current system time.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
2002-12-13 20:30:06 +00:00
|
|
|
*/
|
2003-03-18 18:35:48 +00:00
|
|
|
VOID WINAPI GetSystemTime(LPSYSTEMTIME systime) /* [O] Destination for current time */
|
2002-12-13 20:30:06 +00:00
|
|
|
{
|
|
|
|
FILETIME ft;
|
2002-12-13 20:53:04 +00:00
|
|
|
LARGE_INTEGER t;
|
2002-12-13 20:30:06 +00:00
|
|
|
|
2002-12-13 20:53:04 +00:00
|
|
|
NtQuerySystemTime(&t);
|
2004-01-23 01:51:33 +00:00
|
|
|
ft.dwLowDateTime = t.u.LowPart;
|
|
|
|
ft.dwHighDateTime = t.u.HighPart;
|
2002-12-13 20:30:06 +00:00
|
|
|
FileTimeToSystemTime(&ft, systime);
|
|
|
|
}
|
2004-03-03 02:17:58 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* GetDaylightFlag (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* returns TRUE if daylight saving time is in operation
|
|
|
|
*
|
|
|
|
* Note: this function is called from the Win98's control applet
|
|
|
|
* timedate.cpl
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetDaylightFlag(void)
|
|
|
|
{
|
2004-10-27 21:19:22 +00:00
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
return GetTimeZoneInformation( &tzinfo) == TIME_ZONE_ID_DAYLIGHT;
|
2004-03-03 02:17:58 +00:00
|
|
|
}
|
2004-04-28 03:53:19 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DosDateTimeToFileTime (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DosDateTimeToFileTime( WORD fatdate, WORD fattime, LPFILETIME ft)
|
|
|
|
{
|
|
|
|
struct tm newtm;
|
|
|
|
#ifndef HAVE_TIMEGM
|
|
|
|
struct tm *gtm;
|
|
|
|
time_t time1, time2;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
newtm.tm_sec = (fattime & 0x1f) * 2;
|
|
|
|
newtm.tm_min = (fattime >> 5) & 0x3f;
|
|
|
|
newtm.tm_hour = (fattime >> 11);
|
|
|
|
newtm.tm_mday = (fatdate & 0x1f);
|
|
|
|
newtm.tm_mon = ((fatdate >> 5) & 0x0f) - 1;
|
|
|
|
newtm.tm_year = (fatdate >> 9) + 80;
|
|
|
|
#ifdef HAVE_TIMEGM
|
|
|
|
RtlSecondsSince1970ToTime( timegm(&newtm), (LARGE_INTEGER *)ft );
|
|
|
|
#else
|
|
|
|
time1 = mktime(&newtm);
|
|
|
|
gtm = gmtime(&time1);
|
|
|
|
time2 = mktime(gtm);
|
|
|
|
RtlSecondsSince1970ToTime( 2*time1-time2, (LARGE_INTEGER *)ft );
|
|
|
|
#endif
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* FileTimeToDosDateTime (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FileTimeToDosDateTime( const FILETIME *ft, LPWORD fatdate,
|
|
|
|
LPWORD fattime )
|
|
|
|
{
|
|
|
|
LARGE_INTEGER li;
|
|
|
|
ULONG t;
|
|
|
|
time_t unixtime;
|
|
|
|
struct tm* tm;
|
|
|
|
|
|
|
|
li.u.LowPart = ft->dwLowDateTime;
|
|
|
|
li.u.HighPart = ft->dwHighDateTime;
|
|
|
|
RtlTimeToSecondsSince1970( &li, &t );
|
|
|
|
unixtime = t;
|
|
|
|
tm = gmtime( &unixtime );
|
|
|
|
if (fattime)
|
|
|
|
*fattime = (tm->tm_hour << 11) + (tm->tm_min << 5) + (tm->tm_sec / 2);
|
|
|
|
if (fatdate)
|
|
|
|
*fatdate = ((tm->tm_year - 80) << 9) + ((tm->tm_mon + 1) << 5)
|
|
|
|
+ tm->tm_mday;
|
|
|
|
return TRUE;
|
|
|
|
}
|