ReactOS 0.4.16-dev-297-gc569aee
time.c File Reference
#include "wine/test.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
Include dependency graph for time.c:

Go to the source code of this file.

Classes

struct  TZLT2ST_case
 

Macros

#define SECSPERMIN   60
 
#define SECSPERDAY   86400
 
#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)
 
#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)
 
#define SETUP_2002(st)
 
#define SETUP_ATIME(st)
 
#define SETUP_ZEROTIME(st)
 
#define SETUP_EARLY(st)
 

Functions

static BOOL (WINAPI *pTzSpecificLocalTimeToSystemTime)(LPTIME_ZONE_INFORMATION
 
static int (WINAPI *pGetCalendarInfoA)(LCID
 
static DWORD (WINAPI *pGetDynamicTimeZoneInformation)(DYNAMIC_TIME_ZONE_INFORMATION *)
 
static void (WINAPI *pGetSystemTimePreciseAsFileTime)(LPFILETIME)
 
static void test_conversions (void)
 
static void test_invalid_arg (void)
 
static LONGLONG system_time_to_minutes (const SYSTEMTIME *st)
 
static LONG get_tz_bias (const TIME_ZONE_INFORMATION *tzinfo, DWORD tz_id)
 
static void test_GetTimeZoneInformation (void)
 
static void test_FileTimeToSystemTime (void)
 
static void test_FileTimeToLocalFileTime (void)
 
static void test_TzSpecificLocalTimeToSystemTime (void)
 
static void test_FileTimeToDosDateTime (void)
 
static void test_GetCalendarInfo (void)
 
static void test_GetDynamicTimeZoneInformation (void)
 
static ULONGLONG get_longlong_time (FILETIME *time)
 
static void test_GetSystemTimePreciseAsFileTime (void)
 
static void test_GetSystemTimes (void)
 
static WORD day_of_month (const SYSTEMTIME *systemtime, WORD year)
 
static void test_GetTimeZoneInformationForYear (void)
 
 START_TEST (time)
 

Variables

static LPSYSTEMTIME
 
static LPFILETIME
 
static CALID
 
static CALTYPE
 
static LPSTR
 
static int
 
static LPDWORD
 
static LPWSTR
 
static PDYNAMIC_TIME_ZONE_INFORMATION
 
static LPTIME_ZONE_INFORMATION
 

Macro Definition Documentation

◆ ATIME_HI

#define ATIME_HI   0x1c2349b

Definition at line 51 of file time.c.

◆ ATIME_LOW

#define ATIME_LOW   0x580716b0

Definition at line 52 of file time.c.

◆ DOS_DATE

#define DOS_DATE (   y,
  m,
  d 
)    ( (((y)-1980)<<9) | ((m)<<5) | (d) )

Definition at line 57 of file time.c.

◆ DOS_TIME

#define DOS_TIME (   h,
  m,
  s 
)    ( ((h)<<11) | ((m)<<5) | ((s)>>1) )

Definition at line 58 of file time.c.

◆ LOCAL_ATIME_HI

#define LOCAL_ATIME_HI   0x01c23471

Definition at line 54 of file time.c.

◆ LOCAL_ATIME_LOW

#define LOCAL_ATIME_LOW   0x6f310eb0

Definition at line 55 of file time.c.

◆ MAYDAY_2002_HI

#define MAYDAY_2002_HI   0x01c1f107

Definition at line 48 of file time.c.

◆ MAYDAY_2002_LO

#define MAYDAY_2002_LO   0xb82b6000

Definition at line 49 of file time.c.

◆ NEWYEAR_1980_HI

#define NEWYEAR_1980_HI   0x01a8e79f

Definition at line 45 of file time.c.

◆ NEWYEAR_1980_LO

#define NEWYEAR_1980_LO   0xe1d58000

Definition at line 46 of file time.c.

◆ SECS_1601_TO_1970

#define SECS_1601_TO_1970   ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)

Definition at line 39 of file time.c.

◆ SECSPERDAY

#define SECSPERDAY   86400

Definition at line 37 of file time.c.

◆ SECSPERMIN

#define SECSPERMIN   60

Definition at line 36 of file time.c.

◆ SETUP_1980

#define SETUP_1980 (   st)
Value:
(st).wYear = 1980; \
(st).wMonth = 1; \
(st).wDay = 1; \
(st).wHour = 0; \
(st).wMinute = 0; \
(st).wSecond = 0; \
(st).wMilliseconds = 0;

Definition at line 61 of file time.c.

◆ SETUP_2002

#define SETUP_2002 (   st)
Value:
(st).wYear = 2002; \
(st).wMonth = 5; \
(st).wDay = 1; \
(st).wHour = 12; \
(st).wMinute = 0; \
(st).wSecond = 0; \
(st).wMilliseconds = 0;

Definition at line 70 of file time.c.

◆ SETUP_ATIME

#define SETUP_ATIME (   st)
Value:
(st).wYear = 2002; \
(st).wMonth = 7; \
(st).wDay = 26; \
(st).wHour = 11; \
(st).wMinute = 55; \
(st).wSecond = 32; \
(st).wMilliseconds = 123;

Definition at line 79 of file time.c.

◆ SETUP_EARLY

#define SETUP_EARLY (   st)
Value:
(st).wYear = 1600; \
(st).wMonth = 12; \
(st).wDay = 31; \
(st).wHour = 23; \
(st).wMinute = 59; \
(st).wSecond = 59; \
(st).wMilliseconds = 999;

Definition at line 97 of file time.c.

◆ SETUP_ZEROTIME

#define SETUP_ZEROTIME (   st)
Value:
(st).wYear = 1601; \
(st).wMonth = 1; \
(st).wDay = 1; \
(st).wHour = 0; \
(st).wMinute = 0; \
(st).wSecond = 0; \
(st).wMilliseconds = 0;

Definition at line 88 of file time.c.

◆ TICKS_1601_TO_1970

#define TICKS_1601_TO_1970   (SECS_1601_TO_1970 * TICKSPERSEC)

Definition at line 42 of file time.c.

◆ TICKSPERMSEC

#define TICKSPERMSEC   10000

Definition at line 41 of file time.c.

◆ TICKSPERSEC

#define TICKSPERSEC   10000000

Definition at line 40 of file time.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pTzSpecificLocalTimeToSystemTime)
static

◆ day_of_month()

static WORD day_of_month ( const SYSTEMTIME systemtime,
WORD  year 
)
static

Definition at line 873 of file time.c.

874{
875 SYSTEMTIME first_of_month = {0};
877 WORD result;
878
879 if (systemtime->wYear != 0)
880 return systemtime->wDay;
881
882 first_of_month.wYear = year;
883 first_of_month.wMonth = systemtime->wMonth;
884 first_of_month.wDay = 1;
885
886 /* round-trip conversion sets day of week field */
887 SystemTimeToFileTime(&first_of_month, &filetime);
888 FileTimeToSystemTime(&filetime, &first_of_month);
889
890 result = 1 + ((systemtime->wDayOfWeek - first_of_month.wDayOfWeek + 7) % 7) +
891 (7 * (systemtime->wDay - 1));
892
893 if (systemtime->wDay == 5)
894 {
895 /* make sure this isn't in the next month */
896 SYSTEMTIME result_date;
897
898 result_date = first_of_month;
899 result_date.wDay = result;
900
901 SystemTimeToFileTime(&result_date, &filetime);
902 FileTimeToSystemTime(&filetime, &result_date);
903
904 if (result_date.wDay != result)
905 result = 1 + ((systemtime->wDayOfWeek - first_of_month.wDayOfWeek + 7) % 7) +
906 (7 * (4 - 1));
907 }
908
909 return result;
910}
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint64EXT * result
Definition: glext.h:11304
static FILETIME systemtime
Definition: automation.c:46
WORD wYear
Definition: winbase.h:930
WORD wMonth
Definition: winbase.h:931
WORD wDay
Definition: winbase.h:933
WORD wDayOfWeek
Definition: winbase.h:932

Referenced by test_GetTimeZoneInformationForYear().

◆ DWORD()

static DWORD ( WINAPI pGetDynamicTimeZoneInformation)
static

◆ get_longlong_time()

static ULONGLONG get_longlong_time ( FILETIME time)
static

Definition at line 768 of file time.c.

769{
770 ULARGE_INTEGER uli;
771 uli.u.LowPart = time->dwLowDateTime;
772 uli.u.HighPart = time->dwHighDateTime;
773 return uli.QuadPart;
774}
__u16 time
Definition: mkdosfs.c:8
struct _ULARGE_INTEGER::@4140 u
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

Referenced by test_GetSystemTimePreciseAsFileTime().

◆ get_tz_bias()

static LONG get_tz_bias ( const TIME_ZONE_INFORMATION tzinfo,
DWORD  tz_id 
)
static

Definition at line 215 of file time.c.

216{
217 switch (tz_id)
218 {
220 if (memcmp(&tzinfo->StandardDate, &tzinfo->DaylightDate, sizeof(tzinfo->DaylightDate)) != 0)
221 return tzinfo->DaylightBias;
222 /* fall through */
223
225 return tzinfo->StandardBias;
226
227 default:
228 trace("unknown time zone id %d\n", tz_id);
229 /* fall through */
231 return 0;
232 }
233}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define trace
Definition: atltest.h:70
#define TIME_ZONE_ID_UNKNOWN
Definition: rtltypes.h:252
#define TIME_ZONE_ID_STANDARD
Definition: rtltypes.h:253
#define TIME_ZONE_ID_DAYLIGHT
Definition: rtltypes.h:254
SYSTEMTIME DaylightDate
Definition: winbase.h:1236
SYSTEMTIME StandardDate
Definition: winbase.h:1233

Referenced by test_GetTimeZoneInformation().

◆ int()

static int ( WINAPI pGetCalendarInfoA)
static

◆ START_TEST()

START_TEST ( time  )

Definition at line 993 of file time.c.

994{
995 HMODULE hKernel = GetModuleHandleA("kernel32");
996 pTzSpecificLocalTimeToSystemTime = (void *)GetProcAddress(hKernel, "TzSpecificLocalTimeToSystemTime");
997 pSystemTimeToTzSpecificLocalTime = (void *)GetProcAddress( hKernel, "SystemTimeToTzSpecificLocalTime");
998 pGetSystemTimes = (void *)GetProcAddress( hKernel, "GetSystemTimes");
999 pGetCalendarInfoA = (void *)GetProcAddress(hKernel, "GetCalendarInfoA");
1000 pGetCalendarInfoW = (void *)GetProcAddress(hKernel, "GetCalendarInfoW");
1001 pGetDynamicTimeZoneInformation = (void *)GetProcAddress(hKernel, "GetDynamicTimeZoneInformation");
1002 pGetSystemTimePreciseAsFileTime = (void *)GetProcAddress(hKernel, "GetSystemTimePreciseAsFileTime");
1003 pGetTimeZoneInformationForYear = (void *)GetProcAddress(hKernel, "GetTimeZoneInformationForYear");
1004
1017}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_GetSystemTimePreciseAsFileTime(void)
Definition: time.c:776
static void test_invalid_arg(void)
Definition: time.c:162
static void test_conversions(void)
Definition: time.c:107
static void test_GetTimeZoneInformationForYear(void)
Definition: time.c:912
static void test_GetCalendarInfo(void)
Definition: time.c:670
static void test_GetSystemTimes(void)
Definition: time.c:807
static void test_TzSpecificLocalTimeToSystemTime(void)
Definition: time.c:450
static void test_GetTimeZoneInformation(void)
Definition: time.c:235
static void test_FileTimeToLocalFileTime(void)
Definition: time.c:399
static void test_GetDynamicTimeZoneInformation(void)
Definition: time.c:740
static void test_FileTimeToDosDateTime(void)
Definition: time.c:633
static void test_FileTimeToSystemTime(void)
Definition: time.c:369

◆ system_time_to_minutes()

static LONGLONG system_time_to_minutes ( const SYSTEMTIME st)
static

Definition at line 200 of file time.c.

201{
202 BOOL ret;
203 FILETIME ft;
204 LONGLONG minutes;
205
206 SetLastError(0xdeadbeef);
207 ret = SystemTimeToFileTime(st, &ft);
208 ok(ret, "SystemTimeToFileTime error %u\n", GetLastError());
209
210 minutes = ((LONGLONG)ft.dwHighDateTime << 32) + ft.dwLowDateTime;
211 minutes /= (LONGLONG)600000000; /* convert to minutes */
212 return minutes;
213}
#define ok(value,...)
Definition: atltest.h:57
#define SetLastError(x)
Definition: compat.h:752
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
int64_t LONGLONG
Definition: typedefs.h:68
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by test_GetTimeZoneInformation().

◆ test_conversions()

static void test_conversions ( void  )
static

Definition at line 107 of file time.c.

108{
109 FILETIME ft;
110 SYSTEMTIME st;
111
112 memset(&ft,0,sizeof ft);
113
114 SetLastError(0xdeadbeef);
115 SETUP_EARLY(st)
116 ok (!SystemTimeToFileTime(&st, &ft), "Conversion succeeded EARLY\n");
118 GetLastError() == 0xdeadbeef, /* win9x */
119 "EARLY should be INVALID\n");
120
122 ok (SystemTimeToFileTime(&st, &ft), "Conversion failed ZERO_TIME\n");
123 ok( (!((ft.dwHighDateTime != 0) || (ft.dwLowDateTime != 0))),
124 "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
125 ft.dwLowDateTime, ft.dwHighDateTime, 0, 0);
126
127
128 SETUP_ATIME(st)
129 ok (SystemTimeToFileTime(&st,&ft), "Conversion Failed ATIME\n");
130 ok( (!((ft.dwHighDateTime != ATIME_HI) || (ft.dwLowDateTime!=ATIME_LOW))),
131 "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
133
134
135 SETUP_2002(st)
136 ok (SystemTimeToFileTime(&st, &ft), "Conversion failed 2002\n");
137
138 ok( (!((ft.dwHighDateTime != MAYDAY_2002_HI) ||
140 "Wrong time for 2002 %08x %08x (correct %08x %08x)\n", ft.dwLowDateTime,
142
143
144 SETUP_1980(st)
145 ok((SystemTimeToFileTime(&st, &ft)), "Conversion failed 1980\n");
146
149 "Wrong time for 1980 %08x %08x (correct %08x %08x)\n", ft.dwLowDateTime,
151
152 ok(DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft),
153 "DosDateTimeToFileTime() failed\n");
154
157 "Wrong time DosDateTimeToFileTime %08x %08x (correct %08x %08x)\n",
159
160}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
BOOL WINAPI DosDateTimeToFileTime(IN WORD wFatDate, IN WORD wFatTime, OUT LPFILETIME lpFileTime)
Definition: time.c:75
#define MAYDAY_2002_LO
Definition: time.c:49
#define NEWYEAR_1980_LO
Definition: time.c:46
#define ATIME_HI
Definition: time.c:51
#define NEWYEAR_1980_HI
Definition: time.c:45
#define DOS_TIME(h, m, s)
Definition: time.c:58
#define SETUP_1980(st)
Definition: time.c:61
#define DOS_DATE(y, m, d)
Definition: time.c:57
#define SETUP_ATIME(st)
Definition: time.c:79
#define SETUP_2002(st)
Definition: time.c:70
#define SETUP_ZEROTIME(st)
Definition: time.c:88
#define SETUP_EARLY(st)
Definition: time.c:97
#define ATIME_LOW
Definition: time.c:52
#define MAYDAY_2002_HI
Definition: time.c:48
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_FileTimeToDosDateTime()

static void test_FileTimeToDosDateTime ( void  )
static

Definition at line 633 of file time.c.

634{
635 FILETIME ft = { 0 };
636 WORD fatdate, fattime;
637 BOOL ret;
638
639 if (0)
640 {
641 /* Crashes */
643 }
644 /* Parameter checking */
645 SetLastError(0xdeadbeef);
647 ok(!ret, "expected failure\n");
649 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
650
651 SetLastError(0xdeadbeef);
652 ret = FileTimeToDosDateTime(&ft, &fatdate, NULL);
653 ok(!ret, "expected failure\n");
655 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
656
657 SetLastError(0xdeadbeef);
658 ret = FileTimeToDosDateTime(&ft, NULL, &fattime);
659 ok(!ret, "expected failure\n");
661 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
662
663 SetLastError(0xdeadbeef);
664 ret = FileTimeToDosDateTime(&ft, &fatdate, &fattime);
665 ok(!ret, "expected failure\n");
667 "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
668}
#define NULL
Definition: types.h:112
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
Definition: time.c:37

Referenced by START_TEST().

◆ test_FileTimeToLocalFileTime()

static void test_FileTimeToLocalFileTime ( void  )
static

Definition at line 399 of file time.c.

400{
401 FILETIME ft, lft;
402 SYSTEMTIME st;
406 (LONGLONG)(tzinfo.Bias +
408 ( res == TIME_ZONE_ID_DAYLIGHT ? tzinfo.DaylightBias : 0 ))) *
410 BOOL ret;
411
412 ok( res != TIME_ZONE_ID_INVALID , "GetTimeZoneInformation failed\n");
413 ft.dwHighDateTime = (UINT)(time >> 32);
414 ft.dwLowDateTime = (UINT)time;
415 ret = FileTimeToLocalFileTime(&ft, &lft);
416 ok( ret,
417 "FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
418 FileTimeToSystemTime(&lft, &st);
419 ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
420 (st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
421 (st.wMilliseconds == 0)),
422 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
423 st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
424 st.wMilliseconds);
425
426 ok(SetEnvironmentVariableA("TZ","GMT") != 0,
427 "SetEnvironmentVariableA failed\n");
428 ok(res != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
429 ret = FileTimeToLocalFileTime(&ft, &lft);
430 ok( ret,
431 "FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
432 FileTimeToSystemTime(&lft, &st);
433 ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
434 (st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
435 (st.wMilliseconds == 0)),
436 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
437 st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
438 st.wMilliseconds);
440 "SetEnvironmentVariableA failed\n");
441}
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:221
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
#define TICKSPERSEC
Definition: time.c:40
#define TICKS_1601_TO_1970
Definition: time.c:42
#define SECSPERMIN
Definition: time.c:36
unsigned int UINT
Definition: ndis.h:50
WORD wMilliseconds
Definition: winbase.h:937
WORD wHour
Definition: winbase.h:934
WORD wSecond
Definition: winbase.h:936
WORD wMinute
Definition: winbase.h:935
uint64_t ULONGLONG
Definition: typedefs.h:67
#define TIME_ZONE_ID_INVALID
Definition: winbase.h:312

Referenced by START_TEST().

◆ test_FileTimeToSystemTime()

static void test_FileTimeToSystemTime ( void  )
static

Definition at line 369 of file time.c.

370{
371 FILETIME ft;
372 SYSTEMTIME st;
374 BOOL ret;
375
376 ft.dwHighDateTime = 0;
377 ft.dwLowDateTime = 0;
378 ret = FileTimeToSystemTime(&ft, &st);
379 ok( ret,
380 "FileTimeToSystemTime() failed with Error %d\n",GetLastError());
381 ok(((st.wYear == 1601) && (st.wMonth == 1) && (st.wDay == 1) &&
382 (st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 0) &&
383 (st.wMilliseconds == 0)),
384 "Got Year %4d Month %2d Day %2d\n", st.wYear, st.wMonth, st.wDay);
385
386 ft.dwHighDateTime = (UINT)(time >> 32);
387 ft.dwLowDateTime = (UINT)time;
388 ret = FileTimeToSystemTime(&ft, &st);
389 ok( ret,
390 "FileTimeToSystemTime() failed with Error %d\n",GetLastError());
391 ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
392 (st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
393 (st.wMilliseconds == 0)),
394 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
395 st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
396 st.wMilliseconds);
397}

Referenced by START_TEST().

◆ test_GetCalendarInfo()

static void test_GetCalendarInfo ( void  )
static

Definition at line 670 of file time.c.

671{
672 char bufferA[20];
673 WCHAR bufferW[20];
674 DWORD val1, val2;
675 int ret, ret2;
676
677 if (!pGetCalendarInfoA || !pGetCalendarInfoW)
678 {
679 trace( "GetCalendarInfo missing\n" );
680 return;
681 }
682
683 ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
684 NULL, 0, &val1 );
685 ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
686 ok( ret == sizeof(val1), "wrong size %u\n", ret );
687 ok( val1 >= 2000 && val1 < 2100, "wrong value %u\n", val1 );
688
689 ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
690 NULL, 0, &val2 );
691 ok( ret, "GetCalendarInfoW failed err %u\n", GetLastError() );
692 ok( ret == sizeof(val2)/sizeof(WCHAR), "wrong size %u\n", ret );
693 ok( val1 == val2, "A/W mismatch %u/%u\n", val1, val2 );
694
695 ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, bufferA, sizeof(bufferA), NULL );
696 ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
697 ok( ret == 5, "wrong size %u\n", ret );
698 ok( atoi( bufferA ) == val1, "wrong value %s/%u\n", bufferA, val1 );
699
700 ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, bufferW, sizeof(bufferW), NULL );
701 ok( ret, "GetCalendarInfoW failed err %u\n", GetLastError() );
702 ok( ret == 5, "wrong size %u\n", ret );
703 memset( bufferA, 0x55, sizeof(bufferA) );
704 WideCharToMultiByte( CP_ACP, 0, bufferW, -1, bufferA, sizeof(bufferA), NULL, NULL );
705 ok( atoi( bufferA ) == val1, "wrong value %s/%u\n", bufferA, val1 );
706
707 ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
708 NULL, 0, NULL );
709 ok( !ret, "GetCalendarInfoA succeeded\n" );
710 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
711
712 ret = pGetCalendarInfoA( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, NULL, 0, NULL );
713 ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
714 ok( ret == 5, "wrong size %u\n", ret );
715
716 ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER,
717 NULL, 0, NULL );
718 ok( !ret, "GetCalendarInfoW succeeded\n" );
719 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
720
721 ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, NULL, 0, NULL );
722 ok( ret, "GetCalendarInfoW failed err %u\n", GetLastError() );
723 ok( ret == 5, "wrong size %u\n", ret );
724
725 ret = pGetCalendarInfoA( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
726 bufferA, sizeof(bufferA), NULL);
727 ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
728 ret2 = pGetCalendarInfoA( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
729 bufferA, 0, NULL);
730 ok( ret2, "GetCalendarInfoA failed err %u\n", GetLastError() );
731 ok( ret == ret2, "got %d, expected %d\n", ret2, ret );
732
733 ret2 = pGetCalendarInfoW( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
734 bufferW, sizeof(bufferW), NULL);
735 ok( ret2, "GetCalendarInfoW failed err %u\n", GetLastError() );
736 ret2 = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
737 ok( ret == ret2, "got %d, expected %d\n", ret, ret2 );
738}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define LANG_SYSTEM_DEFAULT
#define CAL_GREGORIAN
Definition: winnls.h:445
#define CAL_SDAYNAME1
Definition: winnls.h:405
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_GetDynamicTimeZoneInformation()

static void test_GetDynamicTimeZoneInformation ( void  )
static

Definition at line 740 of file time.c.

741{
744 DWORD ret, ret2;
745
746 if (!pGetDynamicTimeZoneInformation)
747 {
748 win_skip("GetDynamicTimeZoneInformation() is not supported.\n");
749 return;
750 }
751
752 ret = pGetDynamicTimeZoneInformation(&dyninfo);
753 ret2 = GetTimeZoneInformation(&tzinfo);
754 ok(ret == ret2, "got %d, %d\n", ret, ret2);
755
756 ok(dyninfo.Bias == tzinfo.Bias, "got %d, %d\n", dyninfo.Bias, tzinfo.Bias);
757 ok(!lstrcmpW(dyninfo.StandardName, tzinfo.StandardName), "got std name %s, %s\n",
759 ok(!memcmp(&dyninfo.StandardDate, &tzinfo.StandardDate, sizeof(dyninfo.StandardDate)), "got different StandardDate\n");
760 ok(dyninfo.StandardBias == tzinfo.StandardBias, "got %d, %d\n", dyninfo.StandardBias, tzinfo.StandardBias);
761 ok(!lstrcmpW(dyninfo.DaylightName, tzinfo.DaylightName), "got daylight name %s, %s\n",
763 ok(!memcmp(&dyninfo.DaylightDate, &tzinfo.DaylightDate, sizeof(dyninfo.DaylightDate)), "got different DaylightDate\n");
764 ok(dyninfo.TimeZoneKeyName[0] != 0, "got empty tz keyname\n");
765 trace("Dyn TimeZoneKeyName %s\n", wine_dbgstr_w(dyninfo.TimeZoneKeyName));
766}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
#define wine_dbgstr_w
Definition: kernel32.h:34
#define win_skip
Definition: test.h:163
WCHAR DaylightName[32]
Definition: winbase.h:1235
WCHAR StandardName[32]
Definition: winbase.h:1232

Referenced by START_TEST().

◆ test_GetSystemTimePreciseAsFileTime()

static void test_GetSystemTimePreciseAsFileTime ( void  )
static

Definition at line 776 of file time.c.

777{
778 FILETIME ft;
779 ULONGLONG time1, time2;
780 LONGLONG diff;
781
782 if (!pGetSystemTimePreciseAsFileTime)
783 {
784 win_skip("GetSystemTimePreciseAsFileTime() is not supported.\n");
785 return;
786 }
787
789 time1 = get_longlong_time(&ft);
790 pGetSystemTimePreciseAsFileTime(&ft);
791 time2 = get_longlong_time(&ft);
792 diff = time2 - time1;
793 if (diff < 0)
794 diff = -diff;
795 ok(diff < 1000000, "Difference between GetSystemTimeAsFileTime and GetSystemTimePreciseAsFileTime more than 100 ms\n");
796
797 pGetSystemTimePreciseAsFileTime(&ft);
798 time1 = get_longlong_time(&ft);
799 do {
800 pGetSystemTimePreciseAsFileTime(&ft);
801 time2 = get_longlong_time(&ft);
802 } while (time2 == time1);
803 diff = time2 - time1;
804 ok(diff < 10000 && diff > 0, "GetSystemTimePreciseAsFileTime incremented by more than 1 ms\n");
805}
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
static ULONGLONG get_longlong_time(FILETIME *time)
Definition: time.c:768

Referenced by START_TEST().

◆ test_GetSystemTimes()

static void test_GetSystemTimes ( void  )
static

Definition at line 807 of file time.c.

808{
809
810 FILETIME idletime, kerneltime, usertime;
811 int i;
812 ULARGE_INTEGER ul1, ul2, ul3;
816 ULARGE_INTEGER total_usertime, total_kerneltime, total_idletime;
817
818 if (!pGetSystemTimes)
819 {
820 win_skip("GetSystemTimes not available\n");
821 return;
822 }
823
824 ok( pGetSystemTimes(NULL, NULL, NULL), "GetSystemTimes failed unexpectedly\n" );
825
826 total_usertime.QuadPart = 0;
827 total_kerneltime.QuadPart = 0;
828 total_idletime.QuadPart = 0;
829 memset( &idletime, 0x11, sizeof(idletime) );
830 memset( &kerneltime, 0x11, sizeof(kerneltime) );
831 memset( &usertime, 0x11, sizeof(usertime) );
832 ok( pGetSystemTimes(&idletime, &kerneltime , &usertime),
833 "GetSystemTimes failed unexpectedly\n" );
834
835 ul1.LowPart = idletime.dwLowDateTime;
836 ul1.HighPart = idletime.dwHighDateTime;
837 ul2.LowPart = kerneltime.dwLowDateTime;
838 ul2.HighPart = kerneltime.dwHighDateTime;
839 ul3.LowPart = usertime.dwLowDateTime;
840 ul3.HighPart = usertime.dwHighDateTime;
841
843 "NtQuerySystemInformation failed\n" );
844 ok( sizeof(sbi) == ReturnLength, "Inconsistent length %d\n", ReturnLength );
845
846 /* Check if we have some return values */
847 trace( "Number of Processors : %d\n", sbi.NumberOfProcessors );
848 ok( sbi.NumberOfProcessors > 0, "Expected more than 0 processors, got %d\n",
849 sbi.NumberOfProcessors );
850
851 sppi = HeapAlloc( GetProcessHeap(), 0,
853
856 &ReturnLength),
857 "NtQuerySystemInformation failed\n" );
858
859 for (i = 0; i < sbi.NumberOfProcessors; i++)
860 {
861 total_usertime.QuadPart += sppi[i].UserTime.QuadPart;
862 total_kerneltime.QuadPart += sppi[i].KernelTime.QuadPart;
863 total_idletime.QuadPart += sppi[i].IdleTime.QuadPart;
864 }
865
866 ok( total_idletime.QuadPart - ul1.QuadPart < 10000000, "test idletime failed\n" );
867 ok( total_kerneltime.QuadPart - ul2.QuadPart < 10000000, "test kerneltime failed\n" );
868 ok( total_usertime.QuadPart - ul3.QuadPart < 10000000, "test usertime failed\n" );
869
870 HeapFree(GetProcessHeap(), 0, sppi);
871}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
@ SystemBasicInformation
Definition: ntddk_ex.h:11
@ SystemProcessorPerformanceInformation
Definition: ntddk_ex.h:19
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
$ULONG LowPart
Definition: ntbasedef.h:577
$ULONG HighPart
Definition: ntbasedef.h:578
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by START_TEST().

◆ test_GetTimeZoneInformation()

static void test_GetTimeZoneInformation ( void  )
static

Definition at line 235 of file time.c.

236{
237 char std_name[32], dlt_name[32];
238 TIME_ZONE_INFORMATION tzinfo, tzinfo1;
239 BOOL res;
240 DWORD tz_id;
242 FILETIME l_ft, s_ft;
243 LONGLONG l_time, s_time;
244 LONG diff;
245
246 GetSystemTime(&st);
247 s_time = system_time_to_minutes(&st);
248
249 SetLastError(0xdeadbeef);
250 res = SystemTimeToFileTime(&st, &s_ft);
251 ok(res, "SystemTimeToFileTime error %u\n", GetLastError());
252 SetLastError(0xdeadbeef);
253 res = FileTimeToLocalFileTime(&s_ft, &l_ft);
254 ok(res, "FileTimeToLocalFileTime error %u\n", GetLastError());
255 SetLastError(0xdeadbeef);
256 res = FileTimeToSystemTime(&l_ft, &local);
257 ok(res, "FileTimeToSystemTime error %u\n", GetLastError());
258 l_time = system_time_to_minutes(&local);
259
260 tz_id = GetTimeZoneInformation(&tzinfo);
261 ok(tz_id != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
262
263 trace("tz_id %u (%s)\n", tz_id,
264 tz_id == TIME_ZONE_ID_DAYLIGHT ? "TIME_ZONE_ID_DAYLIGHT" :
265 (tz_id == TIME_ZONE_ID_STANDARD ? "TIME_ZONE_ID_STANDARD" :
266 (tz_id == TIME_ZONE_ID_UNKNOWN ? "TIME_ZONE_ID_UNKNOWN" :
267 "TIME_ZONE_ID_INVALID")));
268
269 WideCharToMultiByte(CP_ACP, 0, tzinfo.StandardName, -1, std_name, sizeof(std_name), NULL, NULL);
270 WideCharToMultiByte(CP_ACP, 0, tzinfo.DaylightName, -1, dlt_name, sizeof(dlt_name), NULL, NULL);
271 trace("bias %d, %s - %s\n", tzinfo.Bias, std_name, dlt_name);
272 trace("standard (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
273 tzinfo.StandardDate.wDay, tzinfo.StandardDate.wMonth,
275 tzinfo.StandardDate.wHour, tzinfo.StandardDate.wMinute,
277 tzinfo.StandardBias);
278 trace("daylight (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
279 tzinfo.DaylightDate.wDay, tzinfo.DaylightDate.wMonth,
281 tzinfo.DaylightDate.wHour, tzinfo.DaylightDate.wMinute,
283 tzinfo.DaylightBias);
284
285 diff = (LONG)(s_time - l_time);
286 ok(diff == tzinfo.Bias + get_tz_bias(&tzinfo, tz_id),
287 "system/local diff %d != tz bias %d\n",
288 diff, tzinfo.Bias + get_tz_bias(&tzinfo, tz_id));
289
290 ok(SetEnvironmentVariableA("TZ","GMT0") != 0,
291 "SetEnvironmentVariableA failed\n");
292 res = GetTimeZoneInformation(&tzinfo1);
293 ok(res != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
294
295 ok(((tzinfo.Bias == tzinfo1.Bias) &&
296 (tzinfo.StandardBias == tzinfo1.StandardBias) &&
297 (tzinfo.DaylightBias == tzinfo1.DaylightBias)),
298 "Bias influenced by TZ variable\n");
300 "SetEnvironmentVariableA failed\n");
301
302 if (!pSystemTimeToTzSpecificLocalTime)
303 {
304 win_skip("SystemTimeToTzSpecificLocalTime not available\n");
305 return;
306 }
307
308 diff = get_tz_bias(&tzinfo, tz_id);
309
310 utc = st;
311 SetLastError(0xdeadbeef);
312 res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &current);
314 {
315 win_skip("SystemTimeToTzSpecificLocalTime is not implemented\n");
316 return;
317 }
318
319 ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
321
322 tzinfo.StandardBias -= 123;
323 tzinfo.DaylightBias += 456;
324
325 res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &local);
326 ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
327 l_time = system_time_to_minutes(&local);
328 ok(l_time - s_time == diff - get_tz_bias(&tzinfo, tz_id), "got %d, expected %d\n",
329 (LONG)(l_time - s_time), diff - get_tz_bias(&tzinfo, tz_id));
330
331 /* pretend that there is no transition dates */
332 tzinfo.DaylightDate.wDay = 0;
333 tzinfo.DaylightDate.wMonth = 0;
334 tzinfo.DaylightDate.wYear = 0;
335 tzinfo.StandardDate.wDay = 0;
336 tzinfo.StandardDate.wMonth = 0;
337 tzinfo.StandardDate.wYear = 0;
338
339 res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &local);
340 ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
341 l_time = system_time_to_minutes(&local);
342 ok(l_time - s_time == diff, "got %d, expected %d\n",
343 (LONG)(l_time - s_time), diff);
344
345 /* test 23:01, 31st of December date */
346 memset(&tzinfo, 0, sizeof(tzinfo));
347 tzinfo.StandardDate.wMonth = 10;
348 tzinfo.StandardDate.wDay = 5;
349 tzinfo.StandardDate.wHour = 2;
350 tzinfo.StandardDate.wMinute = 0;
351 tzinfo.DaylightDate.wMonth = 4;
352 tzinfo.DaylightDate.wDay = 1;
353 tzinfo.DaylightDate.wHour = 2;
354 tzinfo.Bias = 0;
355 tzinfo.StandardBias = 0;
356 tzinfo.DaylightBias = -60;
357 utc.wYear = 2012;
358 utc.wMonth = 12;
359 utc.wDay = 31;
360 utc.wHour = 23;
361 utc.wMinute = 1;
362 res = pSystemTimeToTzSpecificLocalTime(&tzinfo, &utc, &local);
363 ok(res, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
364 ok(local.wYear==2012 && local.wMonth==12 && local.wDay==31 && local.wHour==23 && local.wMinute==1,
365 "got (%d-%d-%d %02d:%02d), expected (2012-12-31 23:01)\n",
366 local.wYear, local.wMonth, local.wDay, local.wHour, local.wMinute);
367}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
static DOUBLE utc(DOUBLE time, DateInstance *date)
Definition: date.c:357
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
#define local
Definition: zutil.h:30
struct task_struct * current
Definition: linux.c:32
static LONG get_tz_bias(const TIME_ZONE_INFORMATION *tzinfo, DWORD tz_id)
Definition: time.c:215
static LONGLONG system_time_to_minutes(const SYSTEMTIME *st)
Definition: time.c:200
long LONG
Definition: pedump.c:60

Referenced by START_TEST().

◆ test_GetTimeZoneInformationForYear()

static void test_GetTimeZoneInformationForYear ( void  )
static

Definition at line 912 of file time.c.

913{
914 BOOL ret;
916 TIME_ZONE_INFORMATION local_tzinfo, tzinfo, tzinfo2;
918 static const WCHAR std_tzname[] = {'G','r','e','e','n','l','a','n','d',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e',0};
919 static const WCHAR dlt_tzname[] = {'G','r','e','e','n','l','a','n','d',' ','D','a','y','l','i','g','h','t',' ','T','i','m','e',0};
920 WORD std_day, dlt_day;
921
922 if (!pGetTimeZoneInformationForYear || !pGetDynamicTimeZoneInformation)
923 {
924 win_skip("GetTimeZoneInformationForYear not available\n");
925 return;
926 }
927
929
930 GetTimeZoneInformation(&local_tzinfo);
931
932 ret = pGetTimeZoneInformationForYear(systemtime.wYear, NULL, &tzinfo);
933 ok(ret == TRUE, "GetTimeZoneInformationForYear failed, err %u\n", GetLastError());
934 ok(tzinfo.Bias == local_tzinfo.Bias, "Expected Bias %d, got %d\n", local_tzinfo.Bias, tzinfo.Bias);
935 ok(!lstrcmpW(tzinfo.StandardName, local_tzinfo.StandardName),
936 "Expected StandardName %s, got %s\n", wine_dbgstr_w(local_tzinfo.StandardName), wine_dbgstr_w(tzinfo.StandardName));
937 ok(!memcmp(&tzinfo.StandardDate, &local_tzinfo.StandardDate, sizeof(SYSTEMTIME)), "StandardDate does not match\n");
938 ok(tzinfo.StandardBias == local_tzinfo.StandardBias, "Expected StandardBias %d, got %d\n", local_tzinfo.StandardBias, tzinfo.StandardBias);
939 ok(!lstrcmpW(tzinfo.DaylightName, local_tzinfo.DaylightName),
940 "Expected DaylightName %s, got %s\n", wine_dbgstr_w(local_tzinfo.DaylightName), wine_dbgstr_w(tzinfo.DaylightName));
941 ok(!memcmp(&tzinfo.DaylightDate, &local_tzinfo.DaylightDate, sizeof(SYSTEMTIME)), "DaylightDate does not match\n");
942 ok(tzinfo.DaylightBias == local_tzinfo.DaylightBias, "Expected DaylightBias %d, got %d\n", local_tzinfo.DaylightBias, tzinfo.DaylightBias);
943
944 pGetDynamicTimeZoneInformation(&dyn_tzinfo);
945
946 ret = pGetTimeZoneInformationForYear(systemtime.wYear, &dyn_tzinfo, &tzinfo);
947 ok(ret == TRUE, "GetTimeZoneInformationForYear failed, err %u\n", GetLastError());
948 ok(tzinfo.Bias == local_tzinfo.Bias, "Expected Bias %d, got %d\n", local_tzinfo.Bias, tzinfo.Bias);
949 ok(!lstrcmpW(tzinfo.StandardName, local_tzinfo.StandardName),
950 "Expected StandardName %s, got %s\n", wine_dbgstr_w(local_tzinfo.StandardName), wine_dbgstr_w(tzinfo.StandardName));
951 ok(!memcmp(&tzinfo.StandardDate, &local_tzinfo.StandardDate, sizeof(SYSTEMTIME)), "StandardDate does not match\n");
952 ok(tzinfo.StandardBias == local_tzinfo.StandardBias, "Expected StandardBias %d, got %d\n", local_tzinfo.StandardBias, tzinfo.StandardBias);
953 ok(!lstrcmpW(tzinfo.DaylightName, local_tzinfo.DaylightName),
954 "Expected DaylightName %s, got %s\n", wine_dbgstr_w(local_tzinfo.DaylightName), wine_dbgstr_w(tzinfo.DaylightName));
955 ok(!memcmp(&tzinfo.DaylightDate, &local_tzinfo.DaylightDate, sizeof(SYSTEMTIME)), "DaylightDate does not match\n");
956 ok(tzinfo.DaylightBias == local_tzinfo.DaylightBias, "Expected DaylightBias %d, got %d\n", local_tzinfo.DaylightBias, tzinfo.DaylightBias);
957
958 memset(&dyn_tzinfo, 0xaa, sizeof(dyn_tzinfo));
959 lstrcpyW(dyn_tzinfo.TimeZoneKeyName, std_tzname);
961
962 ret = pGetTimeZoneInformationForYear(2015, &dyn_tzinfo, &tzinfo);
963 ok(ret == TRUE, "GetTimeZoneInformationForYear failed, err %u\n", GetLastError());
964 ok(tzinfo.Bias == 180, "Expected Bias 180, got %d\n", tzinfo.Bias);
965 ok(tzinfo.StandardDate.wMonth == 10, "Expected standard month 10, got %d\n", tzinfo.StandardDate.wMonth);
966 std_day = day_of_month(&tzinfo.StandardDate, 2015);
967 ok(std_day == 24, "Expected standard day 24, got %d\n", std_day);
968 ok(tzinfo.StandardBias == 0, "Expected StandardBias 0, got %d\n", tzinfo.StandardBias);
969 ok(tzinfo.DaylightDate.wMonth == 3, "Expected daylight month 3, got %d\n", tzinfo.DaylightDate.wMonth);
970 dlt_day = day_of_month(&tzinfo.DaylightDate, 2015);
971 ok(dlt_day == 28, "Expected daylight day 28, got %d\n", dlt_day);
972 ok(tzinfo.DaylightBias == -60, "Expected DaylightBias -60, got %d\n", tzinfo.DaylightBias);
973
974 ret = pGetTimeZoneInformationForYear(2016, &dyn_tzinfo, &tzinfo2);
975 ok(ret == TRUE, "GetTimeZoneInformationForYear failed, err %u\n", GetLastError());
976 ok(!lstrcmpW(tzinfo.StandardName, tzinfo2.StandardName),
977 "Got differing StandardName values %s and %s\n",
979 ok(!lstrcmpW(tzinfo.DaylightName, tzinfo2.DaylightName),
980 "Got differing DaylightName values %s and %s\n",
982
983 memset(&dyn_tzinfo, 0xaa, sizeof(dyn_tzinfo));
984 lstrcpyW(dyn_tzinfo.TimeZoneKeyName, dlt_tzname);
985
986 SetLastError(0xdeadbeef);
987 ret = pGetTimeZoneInformationForYear(2015, &dyn_tzinfo, &tzinfo);
989 broken(ret == TRUE) /* vista,7 */,
990 "GetTimeZoneInformationForYear err %u\n", GetLastError());
991}
#define broken(x)
Definition: atltest.h:178
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define lstrcpyW
Definition: compat.h:749
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static WORD day_of_month(const SYSTEMTIME *systemtime, WORD year)
Definition: time.c:873

Referenced by START_TEST().

◆ test_invalid_arg()

static void test_invalid_arg ( void  )
static

Definition at line 162 of file time.c.

163{
164 FILETIME ft;
165 SYSTEMTIME st;
166
167
168 /* Invalid argument checks */
169
170 memset(&ft,0,sizeof ft);
171 ok( DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft), /* this is 1 Jan 1980 00:00:00 */
172 "DosDateTimeToFileTime() failed\n");
173
175 "filetime for 1/1/80 00:00:00 was %08x %08x\n", ft.dwHighDateTime, ft.dwLowDateTime);
176
177 /* now check SystemTimeToFileTime */
178 memset(&ft,0,sizeof ft);
179
180
181 /* try with a bad month */
182 SETUP_1980(st)
183 st.wMonth = 0;
184
185 ok( !SystemTimeToFileTime(&st, &ft), "bad month\n");
186
187 /* with a bad hour */
188 SETUP_1980(st)
189 st.wHour = 24;
190
191 ok( !SystemTimeToFileTime(&st, &ft), "bad hour\n");
192
193 /* with a bad minute */
194 SETUP_1980(st)
195 st.wMinute = 60;
196
197 ok( !SystemTimeToFileTime(&st, &ft), "bad minute\n");
198}

Referenced by START_TEST().

◆ test_TzSpecificLocalTimeToSystemTime()

static void test_TzSpecificLocalTimeToSystemTime ( void  )
static

Definition at line 450 of file time.c.

451{
452 TIME_ZONE_INFORMATION tzE, tzW, tzS;
454 int i, j, year;
455
456 if (!pTzSpecificLocalTimeToSystemTime || !pSystemTimeToTzSpecificLocalTime)
457 {
458 win_skip("TzSpecificLocalTimeToSystemTime or SystemTimeToTzSpecificLocalTime not available\n");
459 return;
460 }
461
462 ZeroMemory( &tzE, sizeof(tzE));
463 ZeroMemory( &tzW, sizeof(tzW));
464 ZeroMemory( &tzS, sizeof(tzS));
465 /* timezone Eastern hemisphere */
466 tzE.Bias=-600;
467 tzE.StandardBias=0;
468 tzE.DaylightBias=-60;
469 tzE.StandardDate.wMonth=10;
470 tzE.StandardDate.wDayOfWeek=0; /* Sunday */
471 tzE.StandardDate.wDay=5; /* last (Sunday) of the month */
472 tzE.StandardDate.wHour=3;
473 tzE.DaylightDate.wMonth=3;
474 tzE.DaylightDate.wDay=5;
475 tzE.DaylightDate.wHour=2;
476 /* timezone Western hemisphere */
477 tzW.Bias=240;
478 tzW.StandardBias=0;
479 tzW.DaylightBias=-60;
480 tzW.StandardDate.wMonth=10;
481 tzW.StandardDate.wDayOfWeek=0; /* Sunday */
482 tzW.StandardDate.wDay=4; /* 4th (Sunday) of the month */
483 tzW.StandardDate.wHour=2;
484 tzW.DaylightDate.wMonth=4;
485 tzW.DaylightDate.wDay=1;
486 tzW.DaylightDate.wHour=2;
487 /* timezone Southern hemisphere */
488 tzS.Bias=240;
489 tzS.StandardBias=0;
490 tzS.DaylightBias=-60;
491 tzS.StandardDate.wMonth=4;
492 tzS.StandardDate.wDayOfWeek=0; /*Sunday */
493 tzS.StandardDate.wDay=1; /* 1st (Sunday) of the month */
494 tzS.StandardDate.wHour=2;
495 tzS.DaylightDate.wMonth=10;
496 tzS.DaylightDate.wDay=4;
497 tzS.DaylightDate.wHour=2;
498 /*tests*/
499 /* TzSpecificLocalTimeToSystemTime */
500 { TZLT2ST_case cases[] = {
501 /* standard->daylight transition */
502 { 1, &tzE, {2004,3,-1,28,1,0,0,0}, 15 },
503 { 2, &tzE, {2004,3,-1,28,1,59,59,999}, 15},
504 { 3, &tzE, {2004,3,-1,28,2,0,0,0}, 15},
505 /* daylight->standard transition */
506 { 4, &tzE, {2004,10,-1,31,2,0,0,0} , 15 },
507 { 5, &tzE, {2004,10,-1,31,2,59,59,999}, 15 },
508 { 6, &tzE, {2004,10,-1,31,3,0,0,0}, 17 },
509 /* West and with fixed weekday of the month */
510 { 7, &tzW, {2004,4,-1,4,1,0,0,0}, 5},
511 { 8, &tzW, {2004,4,-1,4,1,59,59,999}, 5},
512 { 9, &tzW, {2004,4,-1,4,2,0,0,0}, 5},
513 { 10, &tzW, {2004,10,-1,24,1,0,0,0}, 4},
514 { 11, &tzW, {2004,10,-1,24,1,59,59,999}, 4},
515 { 12, &tzW, {2004,10,-1,24,2,0,0,0 }, 6},
516 /* and now South */
517 { 13, &tzS, {2004,4,-1,4,1,0,0,0}, 4},
518 { 14, &tzS, {2004,4,-1,4,1,59,59,999}, 4},
519 { 15, &tzS, {2004,4,-1,4,2,0,0,0}, 6},
520 { 16, &tzS, {2004,10,-1,24,1,0,0,0}, 5},
521 { 17, &tzS, {2004,10,-1,24,1,59,59,999}, 5},
522 { 18, &tzS, {2004,10,-1,24,2,0,0,0}, 5},
523 {0}
524 };
525 /* days of transitions to put into the cases array */
526 int yeardays[][6]=
527 {
528 {28,31,4,24,4,24} /* 1999 */
529 , {26,29,2,22,2,22} /* 2000 */
530 , {25,28,1,28,1,28} /* 2001 */
531 , {31,27,7,27,7,27} /* 2002 */
532 , {30,26,6,26,6,26} /* 2003 */
533 , {28,31,4,24,4,24} /* 2004 */
534 , {27,30,3,23,3,23} /* 2005 */
535 , {26,29,2,22,2,22} /* 2006 */
536 , {25,28,1,28,1,28} /* 2007 */
537 , {30,26,6,26,6,26} /* 2008 */
538 , {29,25,5,25,5,25} /* 2009 */
539 , {28,31,4,24,4,24} /* 2010 */
540 , {27,30,3,23,3,23} /* 2011 */
541 , {25,28,1,28,1,28} /* 2012 */
542 , {31,27,7,27,7,27} /* 2013 */
543 , {30,26,6,26,6,26} /* 2014 */
544 , {29,25,5,25,5,25} /* 2015 */
545 , {27,30,3,23,3,23} /* 2016 */
546 , {26,29,2,22,2,22} /* 2017 */
547 , {25,28,1,28,1,28} /* 2018 */
548 , {31,27,7,27,7,27} /* 2019 */
549 ,{0}
550 };
551 for( j=0 , year = 1999; yeardays[j][0] ; j++, year++) {
552 for (i=0; cases[i].nr; i++) {
553 if(i) cases[i].nr += 18;
554 cases[i].slt.wYear = year;
555 cases[i].slt.wDay = yeardays[j][i/3];
556 pTzSpecificLocalTimeToSystemTime( cases[i].ptz, &(cases[i].slt), &result);
557 ok( result.wHour == cases[i].ehour,
558 "Test TzSpecificLocalTimeToSystemTime #%d. Got %4d-%02d-%02d %02d:%02d. Expect hour = %02d\n",
559 cases[i].nr, result.wYear, result.wMonth, result.wDay,
560 result.wHour, result.wMinute, cases[i].ehour);
561 }
562 }
563 }
564 /* SystemTimeToTzSpecificLocalTime */
565 { TZLT2ST_case cases[] = {
566 /* standard->daylight transition */
567 { 1, &tzE, {2004,3,-1,27,15,0,0,0}, 1 },
568 { 2, &tzE, {2004,3,-1,27,15,59,59,999}, 1},
569 { 3, &tzE, {2004,3,-1,27,16,0,0,0}, 3},
570 /* daylight->standard transition */
571 { 4, &tzE, {2004,10,-1,30,15,0,0,0}, 2 },
572 { 5, &tzE, {2004,10,-1,30,15,59,59,999}, 2 },
573 { 6, &tzE, {2004,10,-1,30,16,0,0,0}, 2 },
574 /* West and with fixed weekday of the month */
575 { 7, &tzW, {2004,4,-1,4,5,0,0,0}, 1},
576 { 8, &tzW, {2004,4,-1,4,5,59,59,999}, 1},
577 { 9, &tzW, {2004,4,-1,4,6,0,0,0}, 3},
578 { 10, &tzW, {2004,10,-1,24,4,0,0,0}, 1},
579 { 11, &tzW, {2004,10,-1,24,4,59,59,999}, 1},
580 { 12, &tzW, {2004,10,-1,24,5,0,0,0 }, 1},
581 /* and now South */
582 { 13, &tzS, {2004,4,-1,4,4,0,0,0}, 1},
583 { 14, &tzS, {2004,4,-1,4,4,59,59,999}, 1},
584 { 15, &tzS, {2004,4,-1,4,5,0,0,0}, 1},
585 { 16, &tzS, {2004,10,-1,24,5,0,0,0}, 1},
586 { 17, &tzS, {2004,10,-1,24,5,59,59,999}, 1},
587 { 18, &tzS, {2004,10,-1,24,6,0,0,0}, 3},
588
589 {0}
590 };
591 /* days of transitions to put into the cases array */
592 int yeardays[][6]=
593 {
594 {27,30,4,24,4,24} /* 1999 */
595 , {25,28,2,22,2,22} /* 2000 */
596 , {24,27,1,28,1,28} /* 2001 */
597 , {30,26,7,27,7,27} /* 2002 */
598 , {29,25,6,26,6,26} /* 2003 */
599 , {27,30,4,24,4,24} /* 2004 */
600 , {26,29,3,23,3,23} /* 2005 */
601 , {25,28,2,22,2,22} /* 2006 */
602 , {24,27,1,28,1,28} /* 2007 */
603 , {29,25,6,26,6,26} /* 2008 */
604 , {28,24,5,25,5,25} /* 2009 */
605 , {27,30,4,24,4,24} /* 2010 */
606 , {26,29,3,23,3,23} /* 2011 */
607 , {24,27,1,28,1,28} /* 2012 */
608 , {30,26,7,27,7,27} /* 2013 */
609 , {29,25,6,26,6,26} /* 2014 */
610 , {28,24,5,25,5,25} /* 2015 */
611 , {26,29,3,23,3,23} /* 2016 */
612 , {25,28,2,22,2,22} /* 2017 */
613 , {24,27,1,28,1,28} /* 2018 */
614 , {30,26,7,27,7,27} /* 2019 */
615 , {0}
616 };
617 for( j=0 , year = 1999; yeardays[j][0] ; j++, year++) {
618 for (i=0; cases[i].nr; i++) {
619 if(i) cases[i].nr += 18;
620 cases[i].slt.wYear = year;
621 cases[i].slt.wDay = yeardays[j][i/3];
622 pSystemTimeToTzSpecificLocalTime( cases[i].ptz, &(cases[i].slt), &result);
623 ok( result.wHour == cases[i].ehour,
624 "Test SystemTimeToTzSpecificLocalTime #%d. Got %4d-%02d-%02d %02d:%02d. Expect hour = %02d\n",
625 cases[i].nr, result.wYear, result.wMonth, result.wDay,
626 result.wHour, result.wMinute, cases[i].ehour);
627 }
628 }
629
630 }
631}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
SYSTEMTIME slt
Definition: time.c:446
int nr
Definition: time.c:444
#define ZeroMemory
Definition: winbase.h:1737

Referenced by START_TEST().

◆ void()

static void ( WINAPI pGetSystemTimePreciseAsFileTime)
static

Variable Documentation

◆ CALID

Definition at line 30 of file time.c.

◆ CALTYPE

Definition at line 30 of file time.c.

◆ int

int

Definition at line 30 of file time.c.

◆ LPDWORD

Definition at line 30 of file time.c.

◆ LPFILETIME

Definition at line 29 of file time.c.

◆ LPSTR

Definition at line 30 of file time.c.

◆ LPSYSTEMTIME

Definition at line 27 of file time.c.

◆ LPTIME_ZONE_INFORMATION

Definition at line 34 of file time.c.

◆ LPWSTR

Definition at line 31 of file time.c.

◆ PDYNAMIC_TIME_ZONE_INFORMATION

Definition at line 34 of file time.c.