2004-03-22 22:12:02 +01:00
|
|
|
/*
|
|
|
|
* Unit test suite for time functions
|
|
|
|
*
|
|
|
|
* Copyright 2004 Uwe Bonnes
|
2007-07-29 14:26:20 +02:00
|
|
|
* Copyright 2007 Dmitry Timoshkov
|
2004-03-22 22:12:02 +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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-03-22 22:12:02 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "winbase.h"
|
2007-08-29 11:56:52 +02:00
|
|
|
#include "winnls.h"
|
2014-07-27 19:42:28 +02:00
|
|
|
#include "winternl.h"
|
2004-03-22 22:12:02 +01:00
|
|
|
|
2007-07-29 14:26:20 +02:00
|
|
|
static BOOL (WINAPI *pTzSpecificLocalTimeToSystemTime)(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME);
|
|
|
|
static BOOL (WINAPI *pSystemTimeToTzSpecificLocalTime)(LPTIME_ZONE_INFORMATION, LPSYSTEMTIME, LPSYSTEMTIME);
|
2014-07-27 19:42:28 +02:00
|
|
|
static BOOL (WINAPI *pGetSystemTimes)(LPFILETIME, LPFILETIME, LPFILETIME);
|
2011-06-08 16:18:26 +02:00
|
|
|
static int (WINAPI *pGetCalendarInfoA)(LCID,CALID,CALTYPE,LPSTR,int,LPDWORD);
|
|
|
|
static int (WINAPI *pGetCalendarInfoW)(LCID,CALID,CALTYPE,LPWSTR,int,LPDWORD);
|
2015-05-08 16:34:10 +02:00
|
|
|
static DWORD (WINAPI *pGetDynamicTimeZoneInformation)(DYNAMIC_TIME_ZONE_INFORMATION*);
|
2015-05-19 21:20:46 +02:00
|
|
|
static void (WINAPI *pGetSystemTimePreciseAsFileTime)(LPFILETIME);
|
2007-07-29 14:26:20 +02:00
|
|
|
|
2004-03-22 22:12:02 +01:00
|
|
|
#define SECSPERMIN 60
|
|
|
|
#define SECSPERDAY 86400
|
|
|
|
/* 1601 to 1970 is 369 years plus 89 leap days */
|
|
|
|
#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
|
|
|
|
#define TICKSPERSEC 10000000
|
|
|
|
#define TICKSPERMSEC 10000
|
|
|
|
#define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
|
|
|
|
|
|
|
|
|
2004-10-27 00:03:11 +02:00
|
|
|
#define NEWYEAR_1980_HI 0x01a8e79f
|
|
|
|
#define NEWYEAR_1980_LO 0xe1d58000
|
|
|
|
|
|
|
|
#define MAYDAY_2002_HI 0x01c1f107
|
|
|
|
#define MAYDAY_2002_LO 0xb82b6000
|
|
|
|
|
|
|
|
#define ATIME_HI 0x1c2349b
|
|
|
|
#define ATIME_LOW 0x580716b0
|
|
|
|
|
|
|
|
#define LOCAL_ATIME_HI 0x01c23471
|
|
|
|
#define LOCAL_ATIME_LOW 0x6f310eb0
|
|
|
|
|
|
|
|
#define DOS_DATE(y,m,d) ( (((y)-1980)<<9) | ((m)<<5) | (d) )
|
|
|
|
#define DOS_TIME(h,m,s) ( ((h)<<11) | ((m)<<5) | ((s)>>1) )
|
|
|
|
|
|
|
|
|
|
|
|
#define SETUP_1980(st) \
|
|
|
|
(st).wYear = 1980; \
|
|
|
|
(st).wMonth = 1; \
|
|
|
|
(st).wDay = 1; \
|
|
|
|
(st).wHour = 0; \
|
|
|
|
(st).wMinute = 0; \
|
|
|
|
(st).wSecond = 0; \
|
|
|
|
(st).wMilliseconds = 0;
|
|
|
|
|
|
|
|
#define SETUP_2002(st) \
|
|
|
|
(st).wYear = 2002; \
|
|
|
|
(st).wMonth = 5; \
|
|
|
|
(st).wDay = 1; \
|
|
|
|
(st).wHour = 12; \
|
|
|
|
(st).wMinute = 0; \
|
|
|
|
(st).wSecond = 0; \
|
|
|
|
(st).wMilliseconds = 0;
|
|
|
|
|
|
|
|
#define SETUP_ATIME(st) \
|
|
|
|
(st).wYear = 2002; \
|
|
|
|
(st).wMonth = 7; \
|
|
|
|
(st).wDay = 26; \
|
|
|
|
(st).wHour = 11; \
|
|
|
|
(st).wMinute = 55; \
|
|
|
|
(st).wSecond = 32; \
|
|
|
|
(st).wMilliseconds = 123;
|
|
|
|
|
2007-05-04 01:11:08 +02:00
|
|
|
#define SETUP_ZEROTIME(st) \
|
|
|
|
(st).wYear = 1601; \
|
|
|
|
(st).wMonth = 1; \
|
|
|
|
(st).wDay = 1; \
|
|
|
|
(st).wHour = 0; \
|
|
|
|
(st).wMinute = 0; \
|
|
|
|
(st).wSecond = 0; \
|
|
|
|
(st).wMilliseconds = 0;
|
|
|
|
|
|
|
|
#define SETUP_EARLY(st) \
|
|
|
|
(st).wYear = 1600; \
|
|
|
|
(st).wMonth = 12; \
|
|
|
|
(st).wDay = 31; \
|
|
|
|
(st).wHour = 23; \
|
|
|
|
(st).wMinute = 59; \
|
|
|
|
(st).wSecond = 59; \
|
|
|
|
(st).wMilliseconds = 999;
|
2004-10-27 00:03:11 +02:00
|
|
|
|
|
|
|
|
2005-06-14 13:40:04 +02:00
|
|
|
static void test_conversions(void)
|
2004-10-27 00:03:11 +02:00
|
|
|
{
|
|
|
|
FILETIME ft;
|
|
|
|
SYSTEMTIME st;
|
|
|
|
|
|
|
|
memset(&ft,0,sizeof ft);
|
|
|
|
|
2008-04-22 06:42:19 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2007-05-04 01:11:08 +02:00
|
|
|
SETUP_EARLY(st)
|
|
|
|
ok (!SystemTimeToFileTime(&st, &ft), "Conversion succeeded EARLY\n");
|
2008-04-22 06:42:19 +02:00
|
|
|
ok (GetLastError() == ERROR_INVALID_PARAMETER ||
|
|
|
|
GetLastError() == 0xdeadbeef, /* win9x */
|
|
|
|
"EARLY should be INVALID\n");
|
2007-05-04 01:11:08 +02:00
|
|
|
|
|
|
|
SETUP_ZEROTIME(st)
|
|
|
|
ok (SystemTimeToFileTime(&st, &ft), "Conversion failed ZERO_TIME\n");
|
|
|
|
ok( (!((ft.dwHighDateTime != 0) || (ft.dwLowDateTime != 0))),
|
|
|
|
"Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
|
|
|
|
ft.dwLowDateTime, ft.dwHighDateTime, 0, 0);
|
|
|
|
|
|
|
|
|
2004-10-27 00:03:11 +02:00
|
|
|
SETUP_ATIME(st)
|
|
|
|
ok (SystemTimeToFileTime(&st,&ft), "Conversion Failed ATIME\n");
|
|
|
|
ok( (!((ft.dwHighDateTime != ATIME_HI) || (ft.dwLowDateTime!=ATIME_LOW))),
|
2006-10-10 01:06:48 +02:00
|
|
|
"Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
|
2004-10-27 00:03:11 +02:00
|
|
|
ft.dwLowDateTime, ft.dwHighDateTime, ATIME_LOW, ATIME_HI);
|
|
|
|
|
|
|
|
|
|
|
|
SETUP_2002(st)
|
|
|
|
ok (SystemTimeToFileTime(&st, &ft), "Conversion failed 2002\n");
|
|
|
|
|
|
|
|
ok( (!((ft.dwHighDateTime != MAYDAY_2002_HI) ||
|
|
|
|
(ft.dwLowDateTime!=MAYDAY_2002_LO))),
|
2006-10-10 01:06:48 +02:00
|
|
|
"Wrong time for 2002 %08x %08x (correct %08x %08x)\n", ft.dwLowDateTime,
|
2004-10-27 00:03:11 +02:00
|
|
|
ft.dwHighDateTime, MAYDAY_2002_LO, MAYDAY_2002_HI);
|
|
|
|
|
|
|
|
|
|
|
|
SETUP_1980(st)
|
|
|
|
ok((SystemTimeToFileTime(&st, &ft)), "Conversion failed 1980\n");
|
|
|
|
|
|
|
|
ok( (!((ft.dwHighDateTime!=NEWYEAR_1980_HI) ||
|
|
|
|
(ft.dwLowDateTime!=NEWYEAR_1980_LO))) ,
|
2006-10-10 01:06:48 +02:00
|
|
|
"Wrong time for 1980 %08x %08x (correct %08x %08x)\n", ft.dwLowDateTime,
|
2004-10-27 00:03:11 +02:00
|
|
|
ft.dwHighDateTime, NEWYEAR_1980_LO,NEWYEAR_1980_HI );
|
|
|
|
|
|
|
|
ok(DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft),
|
|
|
|
"DosDateTimeToFileTime() failed\n");
|
|
|
|
|
|
|
|
ok( (!((ft.dwHighDateTime!=NEWYEAR_1980_HI) ||
|
|
|
|
(ft.dwLowDateTime!=NEWYEAR_1980_LO))),
|
2006-10-10 01:06:48 +02:00
|
|
|
"Wrong time DosDateTimeToFileTime %08x %08x (correct %08x %08x)\n",
|
2004-10-27 00:03:11 +02:00
|
|
|
ft.dwHighDateTime, ft.dwLowDateTime, NEWYEAR_1980_HI, NEWYEAR_1980_LO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-06-14 13:40:04 +02:00
|
|
|
static void test_invalid_arg(void)
|
2004-10-27 00:03:11 +02:00
|
|
|
{
|
|
|
|
FILETIME ft;
|
|
|
|
SYSTEMTIME st;
|
|
|
|
|
|
|
|
|
|
|
|
/* Invalid argument checks */
|
|
|
|
|
2005-03-17 19:54:31 +01:00
|
|
|
memset(&ft,0,sizeof ft);
|
2004-10-27 00:03:11 +02:00
|
|
|
ok( DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft), /* this is 1 Jan 1980 00:00:00 */
|
|
|
|
"DosDateTimeToFileTime() failed\n");
|
|
|
|
|
|
|
|
ok( (ft.dwHighDateTime==NEWYEAR_1980_HI) && (ft.dwLowDateTime==NEWYEAR_1980_LO),
|
2006-10-10 01:06:48 +02:00
|
|
|
"filetime for 1/1/80 00:00:00 was %08x %08x\n", ft.dwHighDateTime, ft.dwLowDateTime);
|
2004-10-27 00:03:11 +02:00
|
|
|
|
|
|
|
/* now check SystemTimeToFileTime */
|
|
|
|
memset(&ft,0,sizeof ft);
|
|
|
|
|
|
|
|
|
|
|
|
/* try with a bad month */
|
|
|
|
SETUP_1980(st)
|
|
|
|
st.wMonth = 0;
|
|
|
|
|
|
|
|
ok( !SystemTimeToFileTime(&st, &ft), "bad month\n");
|
|
|
|
|
|
|
|
/* with a bad hour */
|
|
|
|
SETUP_1980(st)
|
2004-11-06 04:53:53 +01:00
|
|
|
st.wHour = 24;
|
2004-10-27 00:03:11 +02:00
|
|
|
|
|
|
|
ok( !SystemTimeToFileTime(&st, &ft), "bad hour\n");
|
|
|
|
|
|
|
|
/* with a bad minute */
|
|
|
|
SETUP_1980(st)
|
2004-11-06 04:53:53 +01:00
|
|
|
st.wMinute = 60;
|
2004-10-27 00:03:11 +02:00
|
|
|
|
|
|
|
ok( !SystemTimeToFileTime(&st, &ft), "bad minute\n");
|
|
|
|
}
|
2007-07-29 14:26:20 +02:00
|
|
|
|
|
|
|
static LONGLONG system_time_to_minutes(const SYSTEMTIME *st)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
FILETIME ft;
|
|
|
|
LONGLONG minutes;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = SystemTimeToFileTime(st, &ft);
|
|
|
|
ok(ret, "SystemTimeToFileTime error %u\n", GetLastError());
|
|
|
|
|
|
|
|
minutes = ((LONGLONG)ft.dwHighDateTime << 32) + ft.dwLowDateTime;
|
|
|
|
minutes /= (LONGLONG)600000000; /* convert to minutes */
|
|
|
|
return minutes;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG get_tz_bias(const TIME_ZONE_INFORMATION *tzinfo, DWORD tz_id)
|
|
|
|
{
|
|
|
|
switch (tz_id)
|
|
|
|
{
|
|
|
|
case TIME_ZONE_ID_DAYLIGHT:
|
2008-02-13 21:48:05 +01:00
|
|
|
if (memcmp(&tzinfo->StandardDate, &tzinfo->DaylightDate, sizeof(tzinfo->DaylightDate)) != 0)
|
|
|
|
return tzinfo->DaylightBias;
|
|
|
|
/* fall through */
|
2007-07-29 14:26:20 +02:00
|
|
|
|
|
|
|
case TIME_ZONE_ID_STANDARD:
|
|
|
|
return tzinfo->StandardBias;
|
|
|
|
|
|
|
|
default:
|
|
|
|
trace("unknown time zone id %d\n", tz_id);
|
|
|
|
/* fall through */
|
|
|
|
case TIME_ZONE_ID_UNKNOWN:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2004-10-27 00:03:11 +02:00
|
|
|
|
2005-06-14 13:40:04 +02:00
|
|
|
static void test_GetTimeZoneInformation(void)
|
2004-03-22 22:12:02 +01:00
|
|
|
{
|
2007-08-29 11:56:52 +02:00
|
|
|
char std_name[32], dlt_name[32];
|
2004-03-22 22:12:02 +01:00
|
|
|
TIME_ZONE_INFORMATION tzinfo, tzinfo1;
|
2007-07-29 14:26:20 +02:00
|
|
|
BOOL res;
|
|
|
|
DWORD tz_id;
|
|
|
|
SYSTEMTIME st, current, utc, local;
|
|
|
|
FILETIME l_ft, s_ft;
|
|
|
|
LONGLONG l_time, s_time;
|
|
|
|
LONG diff;
|
|
|
|
|
|
|
|
GetSystemTime(&st);
|
|
|
|
s_time = system_time_to_minutes(&st);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = SystemTimeToFileTime(&st, &s_ft);
|
|
|
|
ok(res, "SystemTimeToFileTime error %u\n", GetLastError());
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = FileTimeToLocalFileTime(&s_ft, &l_ft);
|
|
|
|
ok(res, "FileTimeToLocalFileTime error %u\n", GetLastError());
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = FileTimeToSystemTime(&l_ft, &local);
|
|
|
|
ok(res, "FileTimeToSystemTime error %u\n", GetLastError());
|
|
|
|
l_time = system_time_to_minutes(&local);
|
|
|
|
|
|
|
|
tz_id = GetTimeZoneInformation(&tzinfo);
|
|
|
|
ok(tz_id != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
|
|
|
|
|
2007-08-07 13:01:16 +02:00
|
|
|
trace("tz_id %u (%s)\n", tz_id,
|
|
|
|
tz_id == TIME_ZONE_ID_DAYLIGHT ? "TIME_ZONE_ID_DAYLIGHT" :
|
|
|
|
(tz_id == TIME_ZONE_ID_STANDARD ? "TIME_ZONE_ID_STANDARD" :
|
|
|
|
(tz_id == TIME_ZONE_ID_UNKNOWN ? "TIME_ZONE_ID_UNKNOWN" :
|
|
|
|
"TIME_ZONE_ID_INVALID")));
|
|
|
|
|
2007-08-29 11:56:52 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, tzinfo.StandardName, -1, std_name, sizeof(std_name), NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, tzinfo.DaylightName, -1, dlt_name, sizeof(dlt_name), NULL, NULL);
|
|
|
|
trace("bias %d, %s - %s\n", tzinfo.Bias, std_name, dlt_name);
|
2007-07-29 14:26:20 +02:00
|
|
|
trace("standard (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
|
|
|
|
tzinfo.StandardDate.wDay, tzinfo.StandardDate.wMonth,
|
|
|
|
tzinfo.StandardDate.wYear, tzinfo.StandardDate.wDayOfWeek,
|
|
|
|
tzinfo.StandardDate.wHour, tzinfo.StandardDate.wMinute,
|
|
|
|
tzinfo.StandardDate.wSecond, tzinfo.StandardDate.wMilliseconds,
|
|
|
|
tzinfo.StandardBias);
|
|
|
|
trace("daylight (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
|
|
|
|
tzinfo.DaylightDate.wDay, tzinfo.DaylightDate.wMonth,
|
|
|
|
tzinfo.DaylightDate.wYear, tzinfo.DaylightDate.wDayOfWeek,
|
|
|
|
tzinfo.DaylightDate.wHour, tzinfo.DaylightDate.wMinute,
|
|
|
|
tzinfo.DaylightDate.wSecond, tzinfo.DaylightDate.wMilliseconds,
|
|
|
|
tzinfo.DaylightBias);
|
|
|
|
|
|
|
|
diff = (LONG)(s_time - l_time);
|
|
|
|
ok(diff == tzinfo.Bias + get_tz_bias(&tzinfo, tz_id),
|
|
|
|
"system/local diff %d != tz bias %d\n",
|
|
|
|
diff, tzinfo.Bias + get_tz_bias(&tzinfo, tz_id));
|
|
|
|
|
2004-03-22 22:12:02 +01:00
|
|
|
ok(SetEnvironmentVariableA("TZ","GMT0") != 0,
|
|
|
|
"SetEnvironmentVariableA failed\n");
|
|
|
|
res = GetTimeZoneInformation(&tzinfo1);
|
2004-10-26 02:11:43 +02:00
|
|
|
ok(res != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
|
2004-03-22 22:12:02 +01:00
|
|
|
|
|
|
|
ok(((tzinfo.Bias == tzinfo1.Bias) &&
|
|
|
|
(tzinfo.StandardBias == tzinfo1.StandardBias) &&
|
|
|
|
(tzinfo.DaylightBias == tzinfo1.DaylightBias)),
|
|
|
|
"Bias influenced by TZ variable\n");
|
|
|
|
ok(SetEnvironmentVariableA("TZ",NULL) != 0,
|
|
|
|
"SetEnvironmentVariableA failed\n");
|
2007-07-29 14:26:20 +02:00
|
|
|
|
2007-07-31 10:48:26 +02:00
|
|
|
if (!pSystemTimeToTzSpecificLocalTime)
|
|
|
|
{
|
2009-02-24 00:03:07 +01:00
|
|
|
win_skip("SystemTimeToTzSpecificLocalTime not available\n");
|
2007-07-31 10:48:26 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-29 14:26:20 +02:00
|
|
|
diff = get_tz_bias(&tzinfo, tz_id);
|
|
|
|
|
|
|
|
utc = st;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, ¤t);
|
2008-01-10 11:05:43 +01:00
|
|
|
if (!res && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
2009-02-24 00:03:07 +01:00
|
|
|
win_skip("SystemTimeToTzSpecificLocalTime is not implemented\n");
|
2008-01-10 11:05:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-29 14:26:20 +02:00
|
|
|
ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
|
|
|
|
s_time = system_time_to_minutes(¤t);
|
|
|
|
|
|
|
|
tzinfo.StandardBias -= 123;
|
|
|
|
tzinfo.DaylightBias += 456;
|
|
|
|
|
|
|
|
res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &local);
|
|
|
|
ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
|
|
|
|
l_time = system_time_to_minutes(&local);
|
|
|
|
ok(l_time - s_time == diff - get_tz_bias(&tzinfo, tz_id), "got %d, expected %d\n",
|
|
|
|
(LONG)(l_time - s_time), diff - get_tz_bias(&tzinfo, tz_id));
|
|
|
|
|
|
|
|
/* pretend that there is no transition dates */
|
|
|
|
tzinfo.DaylightDate.wDay = 0;
|
|
|
|
tzinfo.DaylightDate.wMonth = 0;
|
|
|
|
tzinfo.DaylightDate.wYear = 0;
|
|
|
|
tzinfo.StandardDate.wDay = 0;
|
|
|
|
tzinfo.StandardDate.wMonth = 0;
|
|
|
|
tzinfo.StandardDate.wYear = 0;
|
|
|
|
|
|
|
|
res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &local);
|
|
|
|
ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
|
|
|
|
l_time = system_time_to_minutes(&local);
|
|
|
|
ok(l_time - s_time == diff, "got %d, expected %d\n",
|
|
|
|
(LONG)(l_time - s_time), diff);
|
2012-12-10 11:54:23 +01:00
|
|
|
|
|
|
|
/* test 23:01, 31st of December date */
|
|
|
|
memset(&tzinfo, 0, sizeof(tzinfo));
|
|
|
|
tzinfo.StandardDate.wMonth = 10;
|
|
|
|
tzinfo.StandardDate.wDay = 5;
|
|
|
|
tzinfo.StandardDate.wHour = 2;
|
|
|
|
tzinfo.StandardDate.wMinute = 0;
|
|
|
|
tzinfo.DaylightDate.wMonth = 4;
|
|
|
|
tzinfo.DaylightDate.wDay = 1;
|
|
|
|
tzinfo.DaylightDate.wHour = 2;
|
|
|
|
tzinfo.Bias = 0;
|
|
|
|
tzinfo.StandardBias = 0;
|
|
|
|
tzinfo.DaylightBias = -60;
|
|
|
|
utc.wYear = 2012;
|
|
|
|
utc.wMonth = 12;
|
|
|
|
utc.wDay = 31;
|
|
|
|
utc.wHour = 23;
|
|
|
|
utc.wMinute = 1;
|
|
|
|
res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &local);
|
|
|
|
ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
|
|
|
|
ok(local.wYear==2012 && local.wMonth==12 && local.wDay==31 && local.wHour==23 && local.wMinute==1,
|
|
|
|
"got (%d-%d-%d %02d:%02d), expected (2012-12-31 23:01)\n",
|
|
|
|
local.wYear, local.wMonth, local.wDay, local.wHour, local.wMinute);
|
2004-03-22 22:12:02 +01:00
|
|
|
}
|
|
|
|
|
2005-06-14 13:40:04 +02:00
|
|
|
static void test_FileTimeToSystemTime(void)
|
2004-03-22 22:12:02 +01:00
|
|
|
{
|
|
|
|
FILETIME ft;
|
|
|
|
SYSTEMTIME st;
|
|
|
|
ULONGLONG time = (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
|
2004-12-27 18:26:37 +01:00
|
|
|
BOOL ret;
|
2004-03-22 22:12:02 +01:00
|
|
|
|
|
|
|
ft.dwHighDateTime = 0;
|
|
|
|
ft.dwLowDateTime = 0;
|
2004-12-27 18:26:37 +01:00
|
|
|
ret = FileTimeToSystemTime(&ft, &st);
|
|
|
|
ok( ret,
|
2007-01-04 10:54:10 +01:00
|
|
|
"FileTimeToSystemTime() failed with Error %d\n",GetLastError());
|
2004-03-22 22:12:02 +01:00
|
|
|
ok(((st.wYear == 1601) && (st.wMonth == 1) && (st.wDay == 1) &&
|
|
|
|
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 0) &&
|
|
|
|
(st.wMilliseconds == 0)),
|
|
|
|
"Got Year %4d Month %2d Day %2d\n", st.wYear, st.wMonth, st.wDay);
|
|
|
|
|
|
|
|
ft.dwHighDateTime = (UINT)(time >> 32);
|
|
|
|
ft.dwLowDateTime = (UINT)time;
|
2004-12-27 18:26:37 +01:00
|
|
|
ret = FileTimeToSystemTime(&ft, &st);
|
|
|
|
ok( ret,
|
2007-01-04 10:54:10 +01:00
|
|
|
"FileTimeToSystemTime() failed with Error %d\n",GetLastError());
|
2004-03-22 22:12:02 +01:00
|
|
|
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
|
|
|
|
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
|
|
|
|
(st.wMilliseconds == 0)),
|
|
|
|
"Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
|
|
|
|
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
|
|
|
|
st.wMilliseconds);
|
|
|
|
}
|
|
|
|
|
2005-06-14 13:40:04 +02:00
|
|
|
static void test_FileTimeToLocalFileTime(void)
|
2004-03-22 22:12:02 +01:00
|
|
|
{
|
|
|
|
FILETIME ft, lft;
|
|
|
|
SYSTEMTIME st;
|
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
DWORD res = GetTimeZoneInformation(&tzinfo);
|
2004-10-26 02:11:43 +02:00
|
|
|
ULONGLONG time = (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970 +
|
|
|
|
(LONGLONG)(tzinfo.Bias +
|
|
|
|
( res == TIME_ZONE_ID_STANDARD ? tzinfo.StandardBias :
|
|
|
|
( res == TIME_ZONE_ID_DAYLIGHT ? tzinfo.DaylightBias : 0 ))) *
|
|
|
|
SECSPERMIN *TICKSPERSEC;
|
2004-12-27 18:26:37 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
2004-10-26 02:11:43 +02:00
|
|
|
ok( res != TIME_ZONE_ID_INVALID , "GetTimeZoneInformation failed\n");
|
2004-03-22 22:12:02 +01:00
|
|
|
ft.dwHighDateTime = (UINT)(time >> 32);
|
|
|
|
ft.dwLowDateTime = (UINT)time;
|
2004-12-27 18:26:37 +01:00
|
|
|
ret = FileTimeToLocalFileTime(&ft, &lft);
|
|
|
|
ok( ret,
|
2007-01-04 10:54:10 +01:00
|
|
|
"FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
|
2004-03-22 22:12:02 +01:00
|
|
|
FileTimeToSystemTime(&lft, &st);
|
|
|
|
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
|
|
|
|
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
|
|
|
|
(st.wMilliseconds == 0)),
|
|
|
|
"Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
|
|
|
|
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
|
|
|
|
st.wMilliseconds);
|
|
|
|
|
|
|
|
ok(SetEnvironmentVariableA("TZ","GMT") != 0,
|
|
|
|
"SetEnvironmentVariableA failed\n");
|
2004-10-26 02:11:43 +02:00
|
|
|
ok(res != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
|
2004-12-27 18:26:37 +01:00
|
|
|
ret = FileTimeToLocalFileTime(&ft, &lft);
|
|
|
|
ok( ret,
|
2007-01-04 10:54:10 +01:00
|
|
|
"FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
|
2004-03-22 22:12:02 +01:00
|
|
|
FileTimeToSystemTime(&lft, &st);
|
|
|
|
ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
|
|
|
|
(st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
|
|
|
|
(st.wMilliseconds == 0)),
|
|
|
|
"Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
|
|
|
|
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
|
|
|
|
st.wMilliseconds);
|
|
|
|
ok(SetEnvironmentVariableA("TZ",NULL) != 0,
|
|
|
|
"SetEnvironmentVariableA failed\n");
|
|
|
|
}
|
|
|
|
|
2004-09-10 21:35:16 +02:00
|
|
|
typedef struct {
|
|
|
|
int nr; /* test case number for easier lookup */
|
|
|
|
TIME_ZONE_INFORMATION *ptz; /* ptr to timezone */
|
|
|
|
SYSTEMTIME slt; /* system/local time to convert */
|
|
|
|
WORD ehour; /* expected hour */
|
|
|
|
} TZLT2ST_case;
|
|
|
|
|
2005-06-14 13:40:04 +02:00
|
|
|
static void test_TzSpecificLocalTimeToSystemTime(void)
|
2004-09-10 21:35:16 +02:00
|
|
|
{
|
|
|
|
TIME_ZONE_INFORMATION tzE, tzW, tzS;
|
|
|
|
SYSTEMTIME result;
|
2004-10-29 23:27:18 +02:00
|
|
|
int i, j, year;
|
2007-07-29 14:26:20 +02:00
|
|
|
|
|
|
|
if (!pTzSpecificLocalTimeToSystemTime || !pSystemTimeToTzSpecificLocalTime)
|
|
|
|
{
|
2009-02-24 00:03:07 +01:00
|
|
|
win_skip("TzSpecificLocalTimeToSystemTime or SystemTimeToTzSpecificLocalTime not available\n");
|
2004-09-10 21:35:16 +02:00
|
|
|
return;
|
2007-07-29 14:26:20 +02:00
|
|
|
}
|
|
|
|
|
2004-09-10 21:35:16 +02:00
|
|
|
ZeroMemory( &tzE, sizeof(tzE));
|
|
|
|
ZeroMemory( &tzW, sizeof(tzW));
|
|
|
|
ZeroMemory( &tzS, sizeof(tzS));
|
|
|
|
/* timezone Eastern hemisphere */
|
|
|
|
tzE.Bias=-600;
|
|
|
|
tzE.StandardBias=0;
|
|
|
|
tzE.DaylightBias=-60;
|
|
|
|
tzE.StandardDate.wMonth=10;
|
2010-09-09 18:21:30 +02:00
|
|
|
tzE.StandardDate.wDayOfWeek=0; /* Sunday */
|
|
|
|
tzE.StandardDate.wDay=5; /* last (Sunday) of the month */
|
2004-09-10 21:35:16 +02:00
|
|
|
tzE.StandardDate.wHour=3;
|
|
|
|
tzE.DaylightDate.wMonth=3;
|
|
|
|
tzE.DaylightDate.wDay=5;
|
|
|
|
tzE.DaylightDate.wHour=2;
|
|
|
|
/* timezone Western hemisphere */
|
|
|
|
tzW.Bias=240;
|
|
|
|
tzW.StandardBias=0;
|
|
|
|
tzW.DaylightBias=-60;
|
|
|
|
tzW.StandardDate.wMonth=10;
|
2010-09-09 18:21:30 +02:00
|
|
|
tzW.StandardDate.wDayOfWeek=0; /* Sunday */
|
|
|
|
tzW.StandardDate.wDay=4; /* 4th (Sunday) of the month */
|
2004-09-10 21:35:16 +02:00
|
|
|
tzW.StandardDate.wHour=2;
|
|
|
|
tzW.DaylightDate.wMonth=4;
|
|
|
|
tzW.DaylightDate.wDay=1;
|
|
|
|
tzW.DaylightDate.wHour=2;
|
2010-09-09 18:21:30 +02:00
|
|
|
/* timezone Southern hemisphere */
|
2004-09-10 21:35:16 +02:00
|
|
|
tzS.Bias=240;
|
|
|
|
tzS.StandardBias=0;
|
|
|
|
tzS.DaylightBias=-60;
|
|
|
|
tzS.StandardDate.wMonth=4;
|
2010-09-09 18:21:30 +02:00
|
|
|
tzS.StandardDate.wDayOfWeek=0; /*Sunday */
|
|
|
|
tzS.StandardDate.wDay=1; /* 1st (Sunday) of the month */
|
2004-09-10 21:35:16 +02:00
|
|
|
tzS.StandardDate.wHour=2;
|
|
|
|
tzS.DaylightDate.wMonth=10;
|
|
|
|
tzS.DaylightDate.wDay=4;
|
|
|
|
tzS.DaylightDate.wHour=2;
|
|
|
|
/*tests*/
|
|
|
|
/* TzSpecificLocalTimeToSystemTime */
|
|
|
|
{ TZLT2ST_case cases[] = {
|
|
|
|
/* standard->daylight transition */
|
|
|
|
{ 1, &tzE, {2004,3,-1,28,1,0,0,0}, 15 },
|
|
|
|
{ 2, &tzE, {2004,3,-1,28,1,59,59,999}, 15},
|
|
|
|
{ 3, &tzE, {2004,3,-1,28,2,0,0,0}, 15},
|
|
|
|
/* daylight->standard transition */
|
|
|
|
{ 4, &tzE, {2004,10,-1,31,2,0,0,0} , 15 },
|
|
|
|
{ 5, &tzE, {2004,10,-1,31,2,59,59,999}, 15 },
|
|
|
|
{ 6, &tzE, {2004,10,-1,31,3,0,0,0}, 17 },
|
|
|
|
/* West and with fixed weekday of the month */
|
|
|
|
{ 7, &tzW, {2004,4,-1,4,1,0,0,0}, 5},
|
|
|
|
{ 8, &tzW, {2004,4,-1,4,1,59,59,999}, 5},
|
|
|
|
{ 9, &tzW, {2004,4,-1,4,2,0,0,0}, 5},
|
|
|
|
{ 10, &tzW, {2004,10,-1,24,1,0,0,0}, 4},
|
|
|
|
{ 11, &tzW, {2004,10,-1,24,1,59,59,999}, 4},
|
|
|
|
{ 12, &tzW, {2004,10,-1,24,2,0,0,0 }, 6},
|
2010-09-09 18:21:30 +02:00
|
|
|
/* and now South */
|
2004-09-10 21:35:16 +02:00
|
|
|
{ 13, &tzS, {2004,4,-1,4,1,0,0,0}, 4},
|
|
|
|
{ 14, &tzS, {2004,4,-1,4,1,59,59,999}, 4},
|
|
|
|
{ 15, &tzS, {2004,4,-1,4,2,0,0,0}, 6},
|
|
|
|
{ 16, &tzS, {2004,10,-1,24,1,0,0,0}, 5},
|
|
|
|
{ 17, &tzS, {2004,10,-1,24,1,59,59,999}, 5},
|
|
|
|
{ 18, &tzS, {2004,10,-1,24,2,0,0,0}, 5},
|
|
|
|
{0}
|
2004-10-29 23:27:18 +02:00
|
|
|
};
|
|
|
|
/* days of transitions to put into the cases array */
|
|
|
|
int yeardays[][6]=
|
|
|
|
{
|
|
|
|
{28,31,4,24,4,24} /* 1999 */
|
|
|
|
, {26,29,2,22,2,22} /* 2000 */
|
|
|
|
, {25,28,1,28,1,28} /* 2001 */
|
|
|
|
, {31,27,7,27,7,27} /* 2002 */
|
|
|
|
, {30,26,6,26,6,26} /* 2003 */
|
|
|
|
, {28,31,4,24,4,24} /* 2004 */
|
|
|
|
, {27,30,3,23,3,23} /* 2005 */
|
|
|
|
, {26,29,2,22,2,22} /* 2006 */
|
|
|
|
, {25,28,1,28,1,28} /* 2007 */
|
|
|
|
, {30,26,6,26,6,26} /* 2008 */
|
|
|
|
, {29,25,5,25,5,25} /* 2009 */
|
|
|
|
, {28,31,4,24,4,24} /* 2010 */
|
|
|
|
, {27,30,3,23,3,23} /* 2011 */
|
|
|
|
, {25,28,1,28,1,28} /* 2012 */
|
|
|
|
, {31,27,7,27,7,27} /* 2013 */
|
|
|
|
, {30,26,6,26,6,26} /* 2014 */
|
|
|
|
, {29,25,5,25,5,25} /* 2015 */
|
|
|
|
, {27,30,3,23,3,23} /* 2016 */
|
|
|
|
, {26,29,2,22,2,22} /* 2017 */
|
|
|
|
, {25,28,1,28,1,28} /* 2018 */
|
|
|
|
, {31,27,7,27,7,27} /* 2019 */
|
|
|
|
,{0}
|
|
|
|
};
|
|
|
|
for( j=0 , year = 1999; yeardays[j][0] ; j++, year++) {
|
|
|
|
for (i=0; cases[i].nr; i++) {
|
|
|
|
if(i) cases[i].nr += 18;
|
|
|
|
cases[i].slt.wYear = year;
|
|
|
|
cases[i].slt.wDay = yeardays[j][i/3];
|
|
|
|
pTzSpecificLocalTimeToSystemTime( cases[i].ptz, &(cases[i].slt), &result);
|
|
|
|
ok( result.wHour == cases[i].ehour,
|
|
|
|
"Test TzSpecificLocalTimeToSystemTime #%d. Got %4d-%02d-%02d %02d:%02d. Expect hour = %02d\n",
|
|
|
|
cases[i].nr, result.wYear, result.wMonth, result.wDay,
|
|
|
|
result.wHour, result.wMinute, cases[i].ehour);
|
|
|
|
}
|
2004-09-10 21:35:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* SystemTimeToTzSpecificLocalTime */
|
|
|
|
{ TZLT2ST_case cases[] = {
|
|
|
|
/* standard->daylight transition */
|
|
|
|
{ 1, &tzE, {2004,3,-1,27,15,0,0,0}, 1 },
|
|
|
|
{ 2, &tzE, {2004,3,-1,27,15,59,59,999}, 1},
|
|
|
|
{ 3, &tzE, {2004,3,-1,27,16,0,0,0}, 3},
|
|
|
|
/* daylight->standard transition */
|
|
|
|
{ 4, &tzE, {2004,10,-1,30,15,0,0,0}, 2 },
|
|
|
|
{ 5, &tzE, {2004,10,-1,30,15,59,59,999}, 2 },
|
|
|
|
{ 6, &tzE, {2004,10,-1,30,16,0,0,0}, 2 },
|
|
|
|
/* West and with fixed weekday of the month */
|
|
|
|
{ 7, &tzW, {2004,4,-1,4,5,0,0,0}, 1},
|
|
|
|
{ 8, &tzW, {2004,4,-1,4,5,59,59,999}, 1},
|
|
|
|
{ 9, &tzW, {2004,4,-1,4,6,0,0,0}, 3},
|
|
|
|
{ 10, &tzW, {2004,10,-1,24,4,0,0,0}, 1},
|
|
|
|
{ 11, &tzW, {2004,10,-1,24,4,59,59,999}, 1},
|
|
|
|
{ 12, &tzW, {2004,10,-1,24,5,0,0,0 }, 1},
|
2010-09-09 18:21:30 +02:00
|
|
|
/* and now South */
|
2004-09-10 21:35:16 +02:00
|
|
|
{ 13, &tzS, {2004,4,-1,4,4,0,0,0}, 1},
|
|
|
|
{ 14, &tzS, {2004,4,-1,4,4,59,59,999}, 1},
|
|
|
|
{ 15, &tzS, {2004,4,-1,4,5,0,0,0}, 1},
|
|
|
|
{ 16, &tzS, {2004,10,-1,24,5,0,0,0}, 1},
|
|
|
|
{ 17, &tzS, {2004,10,-1,24,5,59,59,999}, 1},
|
|
|
|
{ 18, &tzS, {2004,10,-1,24,6,0,0,0}, 3},
|
|
|
|
|
|
|
|
{0}
|
2004-10-29 23:27:18 +02:00
|
|
|
};
|
|
|
|
/* days of transitions to put into the cases array */
|
|
|
|
int yeardays[][6]=
|
|
|
|
{
|
|
|
|
{27,30,4,24,4,24} /* 1999 */
|
|
|
|
, {25,28,2,22,2,22} /* 2000 */
|
|
|
|
, {24,27,1,28,1,28} /* 2001 */
|
|
|
|
, {30,26,7,27,7,27} /* 2002 */
|
|
|
|
, {29,25,6,26,6,26} /* 2003 */
|
|
|
|
, {27,30,4,24,4,24} /* 2004 */
|
|
|
|
, {26,29,3,23,3,23} /* 2005 */
|
|
|
|
, {25,28,2,22,2,22} /* 2006 */
|
|
|
|
, {24,27,1,28,1,28} /* 2007 */
|
|
|
|
, {29,25,6,26,6,26} /* 2008 */
|
|
|
|
, {28,24,5,25,5,25} /* 2009 */
|
|
|
|
, {27,30,4,24,4,24} /* 2010 */
|
|
|
|
, {26,29,3,23,3,23} /* 2011 */
|
|
|
|
, {24,27,1,28,1,28} /* 2012 */
|
|
|
|
, {30,26,7,27,7,27} /* 2013 */
|
|
|
|
, {29,25,6,26,6,26} /* 2014 */
|
|
|
|
, {28,24,5,25,5,25} /* 2015 */
|
|
|
|
, {26,29,3,23,3,23} /* 2016 */
|
|
|
|
, {25,28,2,22,2,22} /* 2017 */
|
|
|
|
, {24,27,1,28,1,28} /* 2018 */
|
|
|
|
, {30,26,7,27,7,27} /* 2019 */
|
2010-09-06 19:58:35 +02:00
|
|
|
, {0}
|
2004-10-29 23:27:18 +02:00
|
|
|
};
|
|
|
|
for( j=0 , year = 1999; yeardays[j][0] ; j++, year++) {
|
|
|
|
for (i=0; cases[i].nr; i++) {
|
|
|
|
if(i) cases[i].nr += 18;
|
|
|
|
cases[i].slt.wYear = year;
|
|
|
|
cases[i].slt.wDay = yeardays[j][i/3];
|
|
|
|
pSystemTimeToTzSpecificLocalTime( cases[i].ptz, &(cases[i].slt), &result);
|
|
|
|
ok( result.wHour == cases[i].ehour,
|
|
|
|
"Test SystemTimeToTzSpecificLocalTime #%d. Got %4d-%02d-%02d %02d:%02d. Expect hour = %02d\n",
|
|
|
|
cases[i].nr, result.wYear, result.wMonth, result.wDay,
|
|
|
|
result.wHour, result.wMinute, cases[i].ehour);
|
|
|
|
}
|
2004-09-10 21:35:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-08 00:55:35 +01:00
|
|
|
static void test_FileTimeToDosDateTime(void)
|
|
|
|
{
|
|
|
|
FILETIME ft = { 0 };
|
|
|
|
WORD fatdate, fattime;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* Crashes */
|
|
|
|
FileTimeToDosDateTime(NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
/* Parameter checking */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = FileTimeToDosDateTime(&ft, NULL, NULL);
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = FileTimeToDosDateTime(&ft, &fatdate, NULL);
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = FileTimeToDosDateTime(&ft, NULL, &fattime);
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = FileTimeToDosDateTime(&ft, &fatdate, &fattime);
|
|
|
|
ok(!ret, "expected failure\n");
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
|
|
|
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
2011-06-08 16:18:26 +02:00
|
|
|
static void test_GetCalendarInfo(void)
|
|
|
|
{
|
|
|
|
char bufferA[20];
|
|
|
|
WCHAR bufferW[20];
|
|
|
|
DWORD val1, val2;
|
2014-06-12 15:51:24 +02:00
|
|
|
int ret, ret2;
|
2011-06-08 16:18:26 +02:00
|
|
|
|
|
|
|
if (!pGetCalendarInfoA || !pGetCalendarInfoW)
|
|
|
|
{
|
|
|
|
trace( "GetCalendarInfo missing\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
|
|
|
|
NULL, 0, &val1 );
|
|
|
|
ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
|
|
|
|
ok( ret == sizeof(val1), "wrong size %u\n", ret );
|
|
|
|
ok( val1 >= 2000 && val1 < 2100, "wrong value %u\n", val1 );
|
|
|
|
|
|
|
|
ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
|
|
|
|
NULL, 0, &val2 );
|
|
|
|
ok( ret, "GetCalendarInfoW failed err %u\n", GetLastError() );
|
|
|
|
ok( ret == sizeof(val2)/sizeof(WCHAR), "wrong size %u\n", ret );
|
|
|
|
ok( val1 == val2, "A/W mismatch %u/%u\n", val1, val2 );
|
|
|
|
|
|
|
|
ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, bufferA, sizeof(bufferA), NULL );
|
|
|
|
ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
|
|
|
|
ok( ret == 5, "wrong size %u\n", ret );
|
|
|
|
ok( atoi( bufferA ) == val1, "wrong value %s/%u\n", bufferA, val1 );
|
|
|
|
|
|
|
|
ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, bufferW, sizeof(bufferW), NULL );
|
|
|
|
ok( ret, "GetCalendarInfoW failed err %u\n", GetLastError() );
|
|
|
|
ok( ret == 5, "wrong size %u\n", ret );
|
|
|
|
memset( bufferA, 0x55, sizeof(bufferA) );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, bufferW, -1, bufferA, sizeof(bufferA), NULL, NULL );
|
|
|
|
ok( atoi( bufferA ) == val1, "wrong value %s/%u\n", bufferA, val1 );
|
|
|
|
|
|
|
|
ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
|
|
|
|
NULL, 0, NULL );
|
|
|
|
ok( !ret, "GetCalendarInfoA succeeded\n" );
|
|
|
|
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, NULL, 0, NULL );
|
|
|
|
ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
|
|
|
|
ok( ret == 5, "wrong size %u\n", ret );
|
|
|
|
|
|
|
|
ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
|
|
|
|
NULL, 0, NULL );
|
|
|
|
ok( !ret, "GetCalendarInfoW succeeded\n" );
|
|
|
|
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
|
|
|
|
|
|
|
|
ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, NULL, 0, NULL );
|
|
|
|
ok( ret, "GetCalendarInfoW failed err %u\n", GetLastError() );
|
|
|
|
ok( ret == 5, "wrong size %u\n", ret );
|
2014-06-12 15:51:24 +02:00
|
|
|
|
|
|
|
ret = pGetCalendarInfoA( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
|
|
|
|
bufferA, sizeof(bufferA), NULL);
|
|
|
|
ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
|
|
|
|
ret2 = pGetCalendarInfoA( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
|
|
|
|
bufferA, 0, NULL);
|
|
|
|
ok( ret2, "GetCalendarInfoA failed err %u\n", GetLastError() );
|
|
|
|
ok( ret == ret2, "got %d, expected %d\n", ret2, ret );
|
|
|
|
|
|
|
|
ret2 = pGetCalendarInfoW( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
|
|
|
|
bufferW, sizeof(bufferW), NULL);
|
|
|
|
ok( ret2, "GetCalendarInfoW failed err %u\n", GetLastError() );
|
|
|
|
ret2 = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
|
|
|
|
ok( ret == ret2, "got %d, expected %d\n", ret, ret2 );
|
2015-05-08 16:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetDynamicTimeZoneInformation(void)
|
|
|
|
{
|
|
|
|
DYNAMIC_TIME_ZONE_INFORMATION dyninfo;
|
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
DWORD ret, ret2;
|
|
|
|
|
|
|
|
if (!pGetDynamicTimeZoneInformation)
|
|
|
|
{
|
|
|
|
win_skip("GetDynamicTimeZoneInformation() is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
2014-06-12 15:51:24 +02:00
|
|
|
|
2015-05-08 16:34:10 +02:00
|
|
|
ret = pGetDynamicTimeZoneInformation(&dyninfo);
|
|
|
|
ret2 = GetTimeZoneInformation(&tzinfo);
|
|
|
|
ok(ret == ret2, "got %d, %d\n", ret, ret2);
|
|
|
|
|
|
|
|
ok(dyninfo.Bias == tzinfo.Bias, "got %d, %d\n", dyninfo.Bias, tzinfo.Bias);
|
|
|
|
ok(!lstrcmpW(dyninfo.StandardName, tzinfo.StandardName), "got std name %s, %s\n",
|
|
|
|
wine_dbgstr_w(dyninfo.StandardName), wine_dbgstr_w(tzinfo.StandardName));
|
|
|
|
ok(!memcmp(&dyninfo.StandardDate, &tzinfo.StandardDate, sizeof(dyninfo.StandardDate)), "got different StandardDate\n");
|
|
|
|
ok(dyninfo.StandardBias == tzinfo.StandardBias, "got %d, %d\n", dyninfo.StandardBias, tzinfo.StandardBias);
|
|
|
|
ok(!lstrcmpW(dyninfo.DaylightName, tzinfo.DaylightName), "got daylight name %s, %s\n",
|
|
|
|
wine_dbgstr_w(dyninfo.DaylightName), wine_dbgstr_w(tzinfo.DaylightName));
|
|
|
|
ok(!memcmp(&dyninfo.DaylightDate, &tzinfo.DaylightDate, sizeof(dyninfo.DaylightDate)), "got different DaylightDate\n");
|
|
|
|
ok(dyninfo.TimeZoneKeyName[0] != 0, "got empty tz keyname\n");
|
|
|
|
trace("Dyn TimeZoneKeyName %s\n", wine_dbgstr_w(dyninfo.TimeZoneKeyName));
|
2011-06-08 16:18:26 +02:00
|
|
|
}
|
|
|
|
|
2015-05-19 21:20:46 +02:00
|
|
|
static ULONGLONG get_longlong_time(FILETIME *time)
|
|
|
|
{
|
|
|
|
ULARGE_INTEGER uli;
|
2015-05-23 13:53:06 +02:00
|
|
|
uli.u.LowPart = time->dwLowDateTime;
|
|
|
|
uli.u.HighPart = time->dwHighDateTime;
|
2015-05-19 21:20:46 +02:00
|
|
|
return uli.QuadPart;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_GetSystemTimePreciseAsFileTime(void)
|
|
|
|
{
|
|
|
|
FILETIME ft;
|
|
|
|
ULONGLONG time1, time2;
|
|
|
|
LONGLONG diff;
|
|
|
|
|
|
|
|
if (!pGetSystemTimePreciseAsFileTime)
|
|
|
|
{
|
|
|
|
win_skip("GetSystemTimePreciseAsFileTime() is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetSystemTimeAsFileTime(&ft);
|
|
|
|
time1 = get_longlong_time(&ft);
|
|
|
|
pGetSystemTimePreciseAsFileTime(&ft);
|
|
|
|
time2 = get_longlong_time(&ft);
|
|
|
|
diff = time2 - time1;
|
|
|
|
if (diff < 0)
|
|
|
|
diff = -diff;
|
|
|
|
ok(diff < 1000000, "Difference between GetSystemTimeAsFileTime and GetSystemTimePreciseAsFileTime more than 100 ms\n");
|
|
|
|
|
|
|
|
pGetSystemTimePreciseAsFileTime(&ft);
|
|
|
|
time1 = get_longlong_time(&ft);
|
|
|
|
do {
|
|
|
|
pGetSystemTimePreciseAsFileTime(&ft);
|
|
|
|
time2 = get_longlong_time(&ft);
|
|
|
|
} while (time2 == time1);
|
|
|
|
diff = time2 - time1;
|
|
|
|
ok(diff < 10000 && diff > 0, "GetSystemTimePreciseAsFileTime incremented by more than 1 ms\n");
|
|
|
|
}
|
|
|
|
|
2014-07-27 19:42:28 +02:00
|
|
|
static void test_GetSystemTimes(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
FILETIME idletime, kerneltime, usertime;
|
|
|
|
int i;
|
|
|
|
ULARGE_INTEGER ul1, ul2, ul3;
|
|
|
|
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION *sppi;
|
|
|
|
SYSTEM_BASIC_INFORMATION sbi;
|
|
|
|
ULONG ReturnLength;
|
|
|
|
ULARGE_INTEGER total_usertime, total_kerneltime, total_idletime;
|
|
|
|
|
|
|
|
if (!pGetSystemTimes)
|
|
|
|
{
|
|
|
|
win_skip("GetSystemTimes not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-10 05:38:08 +02:00
|
|
|
ok( pGetSystemTimes(NULL, NULL, NULL), "GetSystemTimes failed unexpectedly\n" );
|
2014-07-27 19:42:28 +02:00
|
|
|
|
|
|
|
total_usertime.QuadPart = 0;
|
|
|
|
total_kerneltime.QuadPart = 0;
|
|
|
|
total_idletime.QuadPart = 0;
|
|
|
|
memset( &idletime, 0x11, sizeof(idletime) );
|
|
|
|
memset( &kerneltime, 0x11, sizeof(kerneltime) );
|
|
|
|
memset( &usertime, 0x11, sizeof(usertime) );
|
2015-06-10 05:38:08 +02:00
|
|
|
ok( pGetSystemTimes(&idletime, &kerneltime , &usertime),
|
|
|
|
"GetSystemTimes failed unexpectedly\n" );
|
2014-07-27 19:42:28 +02:00
|
|
|
|
|
|
|
ul1.LowPart = idletime.dwLowDateTime;
|
|
|
|
ul1.HighPart = idletime.dwHighDateTime;
|
|
|
|
ul2.LowPart = kerneltime.dwLowDateTime;
|
|
|
|
ul2.HighPart = kerneltime.dwHighDateTime;
|
|
|
|
ul3.LowPart = usertime.dwLowDateTime;
|
|
|
|
ul3.HighPart = usertime.dwHighDateTime;
|
|
|
|
|
|
|
|
ok( !NtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), &ReturnLength),
|
|
|
|
"NtQuerySystemInformation failed\n" );
|
|
|
|
ok( sizeof(sbi) == ReturnLength, "Inconsistent length %d\n", ReturnLength );
|
|
|
|
|
|
|
|
/* Check if we have some return values */
|
|
|
|
trace( "Number of Processors : %d\n", sbi.NumberOfProcessors );
|
|
|
|
ok( sbi.NumberOfProcessors > 0, "Expected more than 0 processors, got %d\n",
|
|
|
|
sbi.NumberOfProcessors );
|
|
|
|
|
|
|
|
sppi = HeapAlloc( GetProcessHeap(), 0,
|
|
|
|
sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * sbi.NumberOfProcessors);
|
|
|
|
|
|
|
|
ok( !NtQuerySystemInformation( SystemProcessorPerformanceInformation, sppi,
|
2015-09-07 15:09:35 +02:00
|
|
|
sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * sbi.NumberOfProcessors,
|
|
|
|
&ReturnLength),
|
2014-07-27 19:42:28 +02:00
|
|
|
"NtQuerySystemInformation failed\n" );
|
|
|
|
|
|
|
|
for (i = 0; i < sbi.NumberOfProcessors; i++)
|
|
|
|
{
|
|
|
|
total_usertime.QuadPart += sppi[i].UserTime.QuadPart;
|
|
|
|
total_kerneltime.QuadPart += sppi[i].KernelTime.QuadPart;
|
|
|
|
total_idletime.QuadPart += sppi[i].IdleTime.QuadPart;
|
|
|
|
}
|
|
|
|
|
2015-06-10 05:38:08 +02:00
|
|
|
ok( total_idletime.QuadPart - ul1.QuadPart < 10000000, "test idletime failed\n" );
|
|
|
|
ok( total_kerneltime.QuadPart - ul2.QuadPart < 10000000, "test kerneltime failed\n" );
|
|
|
|
ok( total_usertime.QuadPart - ul3.QuadPart < 10000000, "test usertime failed\n" );
|
2014-07-27 19:42:28 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, sppi);
|
|
|
|
}
|
|
|
|
|
2004-03-22 22:12:02 +01:00
|
|
|
START_TEST(time)
|
|
|
|
{
|
2013-10-17 04:45:46 +02:00
|
|
|
HMODULE hKernel = GetModuleHandleA("kernel32");
|
2007-07-29 14:26:20 +02:00
|
|
|
pTzSpecificLocalTimeToSystemTime = (void *)GetProcAddress(hKernel, "TzSpecificLocalTimeToSystemTime");
|
|
|
|
pSystemTimeToTzSpecificLocalTime = (void *)GetProcAddress( hKernel, "SystemTimeToTzSpecificLocalTime");
|
2014-07-27 19:42:28 +02:00
|
|
|
pGetSystemTimes = (void *)GetProcAddress( hKernel, "GetSystemTimes");
|
2011-06-08 16:18:26 +02:00
|
|
|
pGetCalendarInfoA = (void *)GetProcAddress(hKernel, "GetCalendarInfoA");
|
|
|
|
pGetCalendarInfoW = (void *)GetProcAddress(hKernel, "GetCalendarInfoW");
|
2015-05-08 16:34:10 +02:00
|
|
|
pGetDynamicTimeZoneInformation = (void *)GetProcAddress(hKernel, "GetDynamicTimeZoneInformation");
|
2015-05-19 21:20:46 +02:00
|
|
|
pGetSystemTimePreciseAsFileTime = (void *)GetProcAddress(hKernel, "GetSystemTimePreciseAsFileTime");
|
2007-07-29 14:26:20 +02:00
|
|
|
|
2004-10-27 00:03:11 +02:00
|
|
|
test_conversions();
|
|
|
|
test_invalid_arg();
|
2004-03-22 22:12:02 +01:00
|
|
|
test_GetTimeZoneInformation();
|
|
|
|
test_FileTimeToSystemTime();
|
|
|
|
test_FileTimeToLocalFileTime();
|
2004-09-10 21:35:16 +02:00
|
|
|
test_TzSpecificLocalTimeToSystemTime();
|
2014-07-27 19:42:28 +02:00
|
|
|
test_GetSystemTimes();
|
2011-03-08 00:55:35 +01:00
|
|
|
test_FileTimeToDosDateTime();
|
2011-06-08 16:18:26 +02:00
|
|
|
test_GetCalendarInfo();
|
2015-05-08 16:34:10 +02:00
|
|
|
test_GetDynamicTimeZoneInformation();
|
2015-05-19 21:20:46 +02:00
|
|
|
test_GetSystemTimePreciseAsFileTime();
|
2004-03-22 22:12:02 +01:00
|
|
|
}
|