2 * Unit test suite for time functions
4 * Copyright 2004 Uwe Bonnes
5 * Copyright 2007 Dmitry Timoshkov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
25 static BOOL (WINAPI
*pTzSpecificLocalTimeToSystemTime
)(LPTIME_ZONE_INFORMATION
, LPSYSTEMTIME
, LPSYSTEMTIME
);
26 static BOOL (WINAPI
*pSystemTimeToTzSpecificLocalTime
)(LPTIME_ZONE_INFORMATION
, LPSYSTEMTIME
, LPSYSTEMTIME
);
29 #define SECSPERDAY 86400
30 /* 1601 to 1970 is 369 years plus 89 leap days */
31 #define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
32 #define TICKSPERSEC 10000000
33 #define TICKSPERMSEC 10000
34 #define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
37 #define NEWYEAR_1980_HI 0x01a8e79f
38 #define NEWYEAR_1980_LO 0xe1d58000
40 #define MAYDAY_2002_HI 0x01c1f107
41 #define MAYDAY_2002_LO 0xb82b6000
43 #define ATIME_HI 0x1c2349b
44 #define ATIME_LOW 0x580716b0
46 #define LOCAL_ATIME_HI 0x01c23471
47 #define LOCAL_ATIME_LOW 0x6f310eb0
49 #define DOS_DATE(y,m,d) ( (((y)-1980)<<9) | ((m)<<5) | (d) )
50 #define DOS_TIME(h,m,s) ( ((h)<<11) | ((m)<<5) | ((s)>>1) )
53 #define SETUP_1980(st) \
60 (st).wMilliseconds = 0;
62 #define SETUP_2002(st) \
69 (st).wMilliseconds = 0;
71 #define SETUP_ATIME(st) \
78 (st).wMilliseconds = 123;
80 #define SETUP_ZEROTIME(st) \
87 (st).wMilliseconds = 0;
89 #define SETUP_EARLY(st) \
96 (st).wMilliseconds = 999;
99 static void test_conversions(void)
104 memset(&ft
,0,sizeof ft
);
107 ok (!SystemTimeToFileTime(&st
, &ft
), "Conversion succeeded EARLY\n");
108 ok (GetLastError() == ERROR_INVALID_PARAMETER
, "EARLY should be INVALID\n");
111 ok (SystemTimeToFileTime(&st
, &ft
), "Conversion failed ZERO_TIME\n");
112 ok( (!((ft
.dwHighDateTime
!= 0) || (ft
.dwLowDateTime
!= 0))),
113 "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
114 ft
.dwLowDateTime
, ft
.dwHighDateTime
, 0, 0);
118 ok (SystemTimeToFileTime(&st
,&ft
), "Conversion Failed ATIME\n");
119 ok( (!((ft
.dwHighDateTime
!= ATIME_HI
) || (ft
.dwLowDateTime
!=ATIME_LOW
))),
120 "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
121 ft
.dwLowDateTime
, ft
.dwHighDateTime
, ATIME_LOW
, ATIME_HI
);
125 ok (SystemTimeToFileTime(&st
, &ft
), "Conversion failed 2002\n");
127 ok( (!((ft
.dwHighDateTime
!= MAYDAY_2002_HI
) ||
128 (ft
.dwLowDateTime
!=MAYDAY_2002_LO
))),
129 "Wrong time for 2002 %08x %08x (correct %08x %08x)\n", ft
.dwLowDateTime
,
130 ft
.dwHighDateTime
, MAYDAY_2002_LO
, MAYDAY_2002_HI
);
134 ok((SystemTimeToFileTime(&st
, &ft
)), "Conversion failed 1980\n");
136 ok( (!((ft
.dwHighDateTime
!=NEWYEAR_1980_HI
) ||
137 (ft
.dwLowDateTime
!=NEWYEAR_1980_LO
))) ,
138 "Wrong time for 1980 %08x %08x (correct %08x %08x)\n", ft
.dwLowDateTime
,
139 ft
.dwHighDateTime
, NEWYEAR_1980_LO
,NEWYEAR_1980_HI
);
141 ok(DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft
),
142 "DosDateTimeToFileTime() failed\n");
144 ok( (!((ft
.dwHighDateTime
!=NEWYEAR_1980_HI
) ||
145 (ft
.dwLowDateTime
!=NEWYEAR_1980_LO
))),
146 "Wrong time DosDateTimeToFileTime %08x %08x (correct %08x %08x)\n",
147 ft
.dwHighDateTime
, ft
.dwLowDateTime
, NEWYEAR_1980_HI
, NEWYEAR_1980_LO
);
151 static void test_invalid_arg(void)
157 /* Invalid argument checks */
159 memset(&ft
,0,sizeof ft
);
160 ok( DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft
), /* this is 1 Jan 1980 00:00:00 */
161 "DosDateTimeToFileTime() failed\n");
163 ok( (ft
.dwHighDateTime
==NEWYEAR_1980_HI
) && (ft
.dwLowDateTime
==NEWYEAR_1980_LO
),
164 "filetime for 1/1/80 00:00:00 was %08x %08x\n", ft
.dwHighDateTime
, ft
.dwLowDateTime
);
166 /* now check SystemTimeToFileTime */
167 memset(&ft
,0,sizeof ft
);
170 /* try with a bad month */
174 ok( !SystemTimeToFileTime(&st
, &ft
), "bad month\n");
176 /* with a bad hour */
180 ok( !SystemTimeToFileTime(&st
, &ft
), "bad hour\n");
182 /* with a bad minute */
186 ok( !SystemTimeToFileTime(&st
, &ft
), "bad minute\n");
189 static LONGLONG
system_time_to_minutes(const SYSTEMTIME
*st
)
195 SetLastError(0xdeadbeef);
196 ret
= SystemTimeToFileTime(st
, &ft
);
197 ok(ret
, "SystemTimeToFileTime error %u\n", GetLastError());
199 minutes
= ((LONGLONG
)ft
.dwHighDateTime
<< 32) + ft
.dwLowDateTime
;
200 minutes
/= (LONGLONG
)600000000; /* convert to minutes */
204 static LONG
get_tz_bias(const TIME_ZONE_INFORMATION
*tzinfo
, DWORD tz_id
)
208 case TIME_ZONE_ID_DAYLIGHT
:
209 return tzinfo
->DaylightBias
;
211 case TIME_ZONE_ID_STANDARD
:
212 return tzinfo
->StandardBias
;
215 trace("unknown time zone id %d\n", tz_id
);
217 case TIME_ZONE_ID_UNKNOWN
:
222 static void test_GetTimeZoneInformation(void)
224 TIME_ZONE_INFORMATION tzinfo
, tzinfo1
;
227 SYSTEMTIME st
, current
, utc
, local
;
229 LONGLONG l_time
, s_time
;
233 s_time
= system_time_to_minutes(&st
);
235 SetLastError(0xdeadbeef);
236 res
= SystemTimeToFileTime(&st
, &s_ft
);
237 ok(res
, "SystemTimeToFileTime error %u\n", GetLastError());
238 SetLastError(0xdeadbeef);
239 res
= FileTimeToLocalFileTime(&s_ft
, &l_ft
);
240 ok(res
, "FileTimeToLocalFileTime error %u\n", GetLastError());
241 SetLastError(0xdeadbeef);
242 res
= FileTimeToSystemTime(&l_ft
, &local
);
243 ok(res
, "FileTimeToSystemTime error %u\n", GetLastError());
244 l_time
= system_time_to_minutes(&local
);
246 tz_id
= GetTimeZoneInformation(&tzinfo
);
247 ok(tz_id
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
249 trace("tz_id %u (%s)\n", tz_id
,
250 tz_id
== TIME_ZONE_ID_DAYLIGHT
? "TIME_ZONE_ID_DAYLIGHT" :
251 (tz_id
== TIME_ZONE_ID_STANDARD
? "TIME_ZONE_ID_STANDARD" :
252 (tz_id
== TIME_ZONE_ID_UNKNOWN
? "TIME_ZONE_ID_UNKNOWN" :
253 "TIME_ZONE_ID_INVALID")));
255 trace("bias %d\n", tzinfo
.Bias
);
256 trace("standard (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
257 tzinfo
.StandardDate
.wDay
, tzinfo
.StandardDate
.wMonth
,
258 tzinfo
.StandardDate
.wYear
, tzinfo
.StandardDate
.wDayOfWeek
,
259 tzinfo
.StandardDate
.wHour
, tzinfo
.StandardDate
.wMinute
,
260 tzinfo
.StandardDate
.wSecond
, tzinfo
.StandardDate
.wMilliseconds
,
261 tzinfo
.StandardBias
);
262 trace("daylight (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
263 tzinfo
.DaylightDate
.wDay
, tzinfo
.DaylightDate
.wMonth
,
264 tzinfo
.DaylightDate
.wYear
, tzinfo
.DaylightDate
.wDayOfWeek
,
265 tzinfo
.DaylightDate
.wHour
, tzinfo
.DaylightDate
.wMinute
,
266 tzinfo
.DaylightDate
.wSecond
, tzinfo
.DaylightDate
.wMilliseconds
,
267 tzinfo
.DaylightBias
);
269 diff
= (LONG
)(s_time
- l_time
);
270 ok(diff
== tzinfo
.Bias
+ get_tz_bias(&tzinfo
, tz_id
),
271 "system/local diff %d != tz bias %d\n",
272 diff
, tzinfo
.Bias
+ get_tz_bias(&tzinfo
, tz_id
));
274 ok(SetEnvironmentVariableA("TZ","GMT0") != 0,
275 "SetEnvironmentVariableA failed\n");
276 res
= GetTimeZoneInformation(&tzinfo1
);
277 ok(res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
279 ok(((tzinfo
.Bias
== tzinfo1
.Bias
) &&
280 (tzinfo
.StandardBias
== tzinfo1
.StandardBias
) &&
281 (tzinfo
.DaylightBias
== tzinfo1
.DaylightBias
)),
282 "Bias influenced by TZ variable\n");
283 ok(SetEnvironmentVariableA("TZ",NULL
) != 0,
284 "SetEnvironmentVariableA failed\n");
286 if (!pSystemTimeToTzSpecificLocalTime
)
288 skip("SystemTimeToTzSpecificLocalTime not present\n");
292 diff
= get_tz_bias(&tzinfo
, tz_id
);
295 SetLastError(0xdeadbeef);
296 res
= pSystemTimeToTzSpecificLocalTime(&tzinfo
, &utc
, ¤t
);
297 ok(res
, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
298 s_time
= system_time_to_minutes(¤t
);
300 tzinfo
.StandardBias
-= 123;
301 tzinfo
.DaylightBias
+= 456;
303 res
= pSystemTimeToTzSpecificLocalTime(&tzinfo
, &utc
, &local
);
304 ok(res
, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
305 l_time
= system_time_to_minutes(&local
);
306 ok(l_time
- s_time
== diff
- get_tz_bias(&tzinfo
, tz_id
), "got %d, expected %d\n",
307 (LONG
)(l_time
- s_time
), diff
- get_tz_bias(&tzinfo
, tz_id
));
309 /* pretend that there is no transition dates */
310 tzinfo
.DaylightDate
.wDay
= 0;
311 tzinfo
.DaylightDate
.wMonth
= 0;
312 tzinfo
.DaylightDate
.wYear
= 0;
313 tzinfo
.StandardDate
.wDay
= 0;
314 tzinfo
.StandardDate
.wMonth
= 0;
315 tzinfo
.StandardDate
.wYear
= 0;
317 res
= pSystemTimeToTzSpecificLocalTime(&tzinfo
, &utc
, &local
);
318 ok(res
, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
319 l_time
= system_time_to_minutes(&local
);
320 ok(l_time
- s_time
== diff
, "got %d, expected %d\n",
321 (LONG
)(l_time
- s_time
), diff
);
324 static void test_FileTimeToSystemTime(void)
328 ULONGLONG time
= (ULONGLONG
)TICKSPERSEC
+ TICKS_1601_TO_1970
;
331 ft
.dwHighDateTime
= 0;
332 ft
.dwLowDateTime
= 0;
333 ret
= FileTimeToSystemTime(&ft
, &st
);
335 "FileTimeToSystemTime() failed with Error %d\n",GetLastError());
336 ok(((st
.wYear
== 1601) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
337 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 0) &&
338 (st
.wMilliseconds
== 0)),
339 "Got Year %4d Month %2d Day %2d\n", st
.wYear
, st
.wMonth
, st
.wDay
);
341 ft
.dwHighDateTime
= (UINT
)(time
>> 32);
342 ft
.dwLowDateTime
= (UINT
)time
;
343 ret
= FileTimeToSystemTime(&ft
, &st
);
345 "FileTimeToSystemTime() failed with Error %d\n",GetLastError());
346 ok(((st
.wYear
== 1970) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
347 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 1) &&
348 (st
.wMilliseconds
== 0)),
349 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
350 st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
,
354 static void test_FileTimeToLocalFileTime(void)
358 TIME_ZONE_INFORMATION tzinfo
;
359 DWORD res
= GetTimeZoneInformation(&tzinfo
);
360 ULONGLONG time
= (ULONGLONG
)TICKSPERSEC
+ TICKS_1601_TO_1970
+
361 (LONGLONG
)(tzinfo
.Bias
+
362 ( res
== TIME_ZONE_ID_STANDARD
? tzinfo
.StandardBias
:
363 ( res
== TIME_ZONE_ID_DAYLIGHT
? tzinfo
.DaylightBias
: 0 ))) *
364 SECSPERMIN
*TICKSPERSEC
;
367 ok( res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
368 ft
.dwHighDateTime
= (UINT
)(time
>> 32);
369 ft
.dwLowDateTime
= (UINT
)time
;
370 ret
= FileTimeToLocalFileTime(&ft
, &lft
);
372 "FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
373 FileTimeToSystemTime(&lft
, &st
);
374 ok(((st
.wYear
== 1970) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
375 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 1) &&
376 (st
.wMilliseconds
== 0)),
377 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
378 st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
,
381 ok(SetEnvironmentVariableA("TZ","GMT") != 0,
382 "SetEnvironmentVariableA failed\n");
383 ok(res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
384 ret
= FileTimeToLocalFileTime(&ft
, &lft
);
386 "FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
387 FileTimeToSystemTime(&lft
, &st
);
388 ok(((st
.wYear
== 1970) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
389 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 1) &&
390 (st
.wMilliseconds
== 0)),
391 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
392 st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
,
394 ok(SetEnvironmentVariableA("TZ",NULL
) != 0,
395 "SetEnvironmentVariableA failed\n");
399 int nr
; /* test case number for easier lookup */
400 TIME_ZONE_INFORMATION
*ptz
; /* ptr to timezone */
401 SYSTEMTIME slt
; /* system/local time to convert */
402 WORD ehour
; /* expected hour */
405 static void test_TzSpecificLocalTimeToSystemTime(void)
407 TIME_ZONE_INFORMATION tzE
, tzW
, tzS
;
411 if (!pTzSpecificLocalTimeToSystemTime
|| !pSystemTimeToTzSpecificLocalTime
)
413 skip("TzSpecificLocalTimeToSystemTime or SystemTimeToTzSpecificLocalTime not present\n");
417 ZeroMemory( &tzE
, sizeof(tzE
));
418 ZeroMemory( &tzW
, sizeof(tzW
));
419 ZeroMemory( &tzS
, sizeof(tzS
));
420 /* timezone Eastern hemisphere */
423 tzE
.DaylightBias
=-60;
424 tzE
.StandardDate
.wMonth
=10;
425 tzE
.StandardDate
.wDayOfWeek
=0; /*sunday */
426 tzE
.StandardDate
.wDay
=5; /* last (sunday) of the month */
427 tzE
.StandardDate
.wHour
=3;
428 tzE
.DaylightDate
.wMonth
=3;
429 tzE
.DaylightDate
.wDay
=5;
430 tzE
.DaylightDate
.wHour
=2;
431 /* timezone Western hemisphere */
434 tzW
.DaylightBias
=-60;
435 tzW
.StandardDate
.wMonth
=10;
436 tzW
.StandardDate
.wDayOfWeek
=0; /*sunday */
437 tzW
.StandardDate
.wDay
=4; /* 4th (sunday) of the month */
438 tzW
.StandardDate
.wHour
=2;
439 tzW
.DaylightDate
.wMonth
=4;
440 tzW
.DaylightDate
.wDay
=1;
441 tzW
.DaylightDate
.wHour
=2;
442 /* timezone Eastern hemisphere */
445 tzS
.DaylightBias
=-60;
446 tzS
.StandardDate
.wMonth
=4;
447 tzS
.StandardDate
.wDayOfWeek
=0; /*sunday */
448 tzS
.StandardDate
.wDay
=1; /* 1st (sunday) of the month */
449 tzS
.StandardDate
.wHour
=2;
450 tzS
.DaylightDate
.wMonth
=10;
451 tzS
.DaylightDate
.wDay
=4;
452 tzS
.DaylightDate
.wHour
=2;
454 /* TzSpecificLocalTimeToSystemTime */
455 { TZLT2ST_case cases
[] = {
456 /* standard->daylight transition */
457 { 1, &tzE
, {2004,3,-1,28,1,0,0,0}, 15 },
458 { 2, &tzE
, {2004,3,-1,28,1,59,59,999}, 15},
459 { 3, &tzE
, {2004,3,-1,28,2,0,0,0}, 15},
460 /* daylight->standard transition */
461 { 4, &tzE
, {2004,10,-1,31,2,0,0,0} , 15 },
462 { 5, &tzE
, {2004,10,-1,31,2,59,59,999}, 15 },
463 { 6, &tzE
, {2004,10,-1,31,3,0,0,0}, 17 },
464 /* West and with fixed weekday of the month */
465 { 7, &tzW
, {2004,4,-1,4,1,0,0,0}, 5},
466 { 8, &tzW
, {2004,4,-1,4,1,59,59,999}, 5},
467 { 9, &tzW
, {2004,4,-1,4,2,0,0,0}, 5},
468 { 10, &tzW
, {2004,10,-1,24,1,0,0,0}, 4},
469 { 11, &tzW
, {2004,10,-1,24,1,59,59,999}, 4},
470 { 12, &tzW
, {2004,10,-1,24,2,0,0,0 }, 6},
472 { 13, &tzS
, {2004,4,-1,4,1,0,0,0}, 4},
473 { 14, &tzS
, {2004,4,-1,4,1,59,59,999}, 4},
474 { 15, &tzS
, {2004,4,-1,4,2,0,0,0}, 6},
475 { 16, &tzS
, {2004,10,-1,24,1,0,0,0}, 5},
476 { 17, &tzS
, {2004,10,-1,24,1,59,59,999}, 5},
477 { 18, &tzS
, {2004,10,-1,24,2,0,0,0}, 5},
480 /* days of transitions to put into the cases array */
483 {28,31,4,24,4,24} /* 1999 */
484 , {26,29,2,22,2,22} /* 2000 */
485 , {25,28,1,28,1,28} /* 2001 */
486 , {31,27,7,27,7,27} /* 2002 */
487 , {30,26,6,26,6,26} /* 2003 */
488 , {28,31,4,24,4,24} /* 2004 */
489 , {27,30,3,23,3,23} /* 2005 */
490 , {26,29,2,22,2,22} /* 2006 */
491 , {25,28,1,28,1,28} /* 2007 */
492 , {30,26,6,26,6,26} /* 2008 */
493 , {29,25,5,25,5,25} /* 2009 */
494 , {28,31,4,24,4,24} /* 2010 */
495 , {27,30,3,23,3,23} /* 2011 */
496 , {25,28,1,28,1,28} /* 2012 */
497 , {31,27,7,27,7,27} /* 2013 */
498 , {30,26,6,26,6,26} /* 2014 */
499 , {29,25,5,25,5,25} /* 2015 */
500 , {27,30,3,23,3,23} /* 2016 */
501 , {26,29,2,22,2,22} /* 2017 */
502 , {25,28,1,28,1,28} /* 2018 */
503 , {31,27,7,27,7,27} /* 2019 */
506 for( j
=0 , year
= 1999; yeardays
[j
][0] ; j
++, year
++) {
507 for (i
=0; cases
[i
].nr
; i
++) {
508 if(i
) cases
[i
].nr
+= 18;
509 cases
[i
].slt
.wYear
= year
;
510 cases
[i
].slt
.wDay
= yeardays
[j
][i
/3];
511 pTzSpecificLocalTimeToSystemTime( cases
[i
].ptz
, &(cases
[i
].slt
), &result
);
512 ok( result
.wHour
== cases
[i
].ehour
,
513 "Test TzSpecificLocalTimeToSystemTime #%d. Got %4d-%02d-%02d %02d:%02d. Expect hour = %02d\n",
514 cases
[i
].nr
, result
.wYear
, result
.wMonth
, result
.wDay
,
515 result
.wHour
, result
.wMinute
, cases
[i
].ehour
);
519 /* SystemTimeToTzSpecificLocalTime */
520 { TZLT2ST_case cases
[] = {
521 /* standard->daylight transition */
522 { 1, &tzE
, {2004,3,-1,27,15,0,0,0}, 1 },
523 { 2, &tzE
, {2004,3,-1,27,15,59,59,999}, 1},
524 { 3, &tzE
, {2004,3,-1,27,16,0,0,0}, 3},
525 /* daylight->standard transition */
526 { 4, &tzE
, {2004,10,-1,30,15,0,0,0}, 2 },
527 { 5, &tzE
, {2004,10,-1,30,15,59,59,999}, 2 },
528 { 6, &tzE
, {2004,10,-1,30,16,0,0,0}, 2 },
529 /* West and with fixed weekday of the month */
530 { 7, &tzW
, {2004,4,-1,4,5,0,0,0}, 1},
531 { 8, &tzW
, {2004,4,-1,4,5,59,59,999}, 1},
532 { 9, &tzW
, {2004,4,-1,4,6,0,0,0}, 3},
533 { 10, &tzW
, {2004,10,-1,24,4,0,0,0}, 1},
534 { 11, &tzW
, {2004,10,-1,24,4,59,59,999}, 1},
535 { 12, &tzW
, {2004,10,-1,24,5,0,0,0 }, 1},
537 { 13, &tzS
, {2004,4,-1,4,4,0,0,0}, 1},
538 { 14, &tzS
, {2004,4,-1,4,4,59,59,999}, 1},
539 { 15, &tzS
, {2004,4,-1,4,5,0,0,0}, 1},
540 { 16, &tzS
, {2004,10,-1,24,5,0,0,0}, 1},
541 { 17, &tzS
, {2004,10,-1,24,5,59,59,999}, 1},
542 { 18, &tzS
, {2004,10,-1,24,6,0,0,0}, 3},
546 /* days of transitions to put into the cases array */
549 {27,30,4,24,4,24} /* 1999 */
550 , {25,28,2,22,2,22} /* 2000 */
551 , {24,27,1,28,1,28} /* 2001 */
552 , {30,26,7,27,7,27} /* 2002 */
553 , {29,25,6,26,6,26} /* 2003 */
554 , {27,30,4,24,4,24} /* 2004 */
555 , {26,29,3,23,3,23} /* 2005 */
556 , {25,28,2,22,2,22} /* 2006 */
557 , {24,27,1,28,1,28} /* 2007 */
558 , {29,25,6,26,6,26} /* 2008 */
559 , {28,24,5,25,5,25} /* 2009 */
560 , {27,30,4,24,4,24} /* 2010 */
561 , {26,29,3,23,3,23} /* 2011 */
562 , {24,27,1,28,1,28} /* 2012 */
563 , {30,26,7,27,7,27} /* 2013 */
564 , {29,25,6,26,6,26} /* 2014 */
565 , {28,24,5,25,5,25} /* 2015 */
566 , {26,29,3,23,3,23} /* 2016 */
567 , {25,28,2,22,2,22} /* 2017 */
568 , {24,27,1,28,1,28} /* 2018 */
569 , {30,26,7,27,7,27} /* 2019 */
571 for( j
=0 , year
= 1999; yeardays
[j
][0] ; j
++, year
++) {
572 for (i
=0; cases
[i
].nr
; i
++) {
573 if(i
) cases
[i
].nr
+= 18;
574 cases
[i
].slt
.wYear
= year
;
575 cases
[i
].slt
.wDay
= yeardays
[j
][i
/3];
576 pSystemTimeToTzSpecificLocalTime( cases
[i
].ptz
, &(cases
[i
].slt
), &result
);
577 ok( result
.wHour
== cases
[i
].ehour
,
578 "Test SystemTimeToTzSpecificLocalTime #%d. Got %4d-%02d-%02d %02d:%02d. Expect hour = %02d\n",
579 cases
[i
].nr
, result
.wYear
, result
.wMonth
, result
.wDay
,
580 result
.wHour
, result
.wMinute
, cases
[i
].ehour
);
589 HMODULE hKernel
= GetModuleHandle("kernel32");
590 pTzSpecificLocalTimeToSystemTime
= (void *)GetProcAddress(hKernel
, "TzSpecificLocalTimeToSystemTime");
591 pSystemTimeToTzSpecificLocalTime
= (void *)GetProcAddress( hKernel
, "SystemTimeToTzSpecificLocalTime");
595 test_GetTimeZoneInformation();
596 test_FileTimeToSystemTime();
597 test_FileTimeToLocalFileTime();
598 test_TzSpecificLocalTimeToSystemTime();