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"
26 static BOOL (WINAPI
*pTzSpecificLocalTimeToSystemTime
)(LPTIME_ZONE_INFORMATION
, LPSYSTEMTIME
, LPSYSTEMTIME
);
27 static BOOL (WINAPI
*pSystemTimeToTzSpecificLocalTime
)(LPTIME_ZONE_INFORMATION
, LPSYSTEMTIME
, LPSYSTEMTIME
);
30 #define SECSPERDAY 86400
31 /* 1601 to 1970 is 369 years plus 89 leap days */
32 #define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
33 #define TICKSPERSEC 10000000
34 #define TICKSPERMSEC 10000
35 #define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
38 #define NEWYEAR_1980_HI 0x01a8e79f
39 #define NEWYEAR_1980_LO 0xe1d58000
41 #define MAYDAY_2002_HI 0x01c1f107
42 #define MAYDAY_2002_LO 0xb82b6000
44 #define ATIME_HI 0x1c2349b
45 #define ATIME_LOW 0x580716b0
47 #define LOCAL_ATIME_HI 0x01c23471
48 #define LOCAL_ATIME_LOW 0x6f310eb0
50 #define DOS_DATE(y,m,d) ( (((y)-1980)<<9) | ((m)<<5) | (d) )
51 #define DOS_TIME(h,m,s) ( ((h)<<11) | ((m)<<5) | ((s)>>1) )
54 #define SETUP_1980(st) \
61 (st).wMilliseconds = 0;
63 #define SETUP_2002(st) \
70 (st).wMilliseconds = 0;
72 #define SETUP_ATIME(st) \
79 (st).wMilliseconds = 123;
81 #define SETUP_ZEROTIME(st) \
88 (st).wMilliseconds = 0;
90 #define SETUP_EARLY(st) \
97 (st).wMilliseconds = 999;
100 static void test_conversions(void)
105 memset(&ft
,0,sizeof ft
);
107 SetLastError(0xdeadbeef);
109 ok (!SystemTimeToFileTime(&st
, &ft
), "Conversion succeeded EARLY\n");
110 ok (GetLastError() == ERROR_INVALID_PARAMETER
||
111 GetLastError() == 0xdeadbeef, /* win9x */
112 "EARLY should be INVALID\n");
115 ok (SystemTimeToFileTime(&st
, &ft
), "Conversion failed ZERO_TIME\n");
116 ok( (!((ft
.dwHighDateTime
!= 0) || (ft
.dwLowDateTime
!= 0))),
117 "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
118 ft
.dwLowDateTime
, ft
.dwHighDateTime
, 0, 0);
122 ok (SystemTimeToFileTime(&st
,&ft
), "Conversion Failed ATIME\n");
123 ok( (!((ft
.dwHighDateTime
!= ATIME_HI
) || (ft
.dwLowDateTime
!=ATIME_LOW
))),
124 "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
125 ft
.dwLowDateTime
, ft
.dwHighDateTime
, ATIME_LOW
, ATIME_HI
);
129 ok (SystemTimeToFileTime(&st
, &ft
), "Conversion failed 2002\n");
131 ok( (!((ft
.dwHighDateTime
!= MAYDAY_2002_HI
) ||
132 (ft
.dwLowDateTime
!=MAYDAY_2002_LO
))),
133 "Wrong time for 2002 %08x %08x (correct %08x %08x)\n", ft
.dwLowDateTime
,
134 ft
.dwHighDateTime
, MAYDAY_2002_LO
, MAYDAY_2002_HI
);
138 ok((SystemTimeToFileTime(&st
, &ft
)), "Conversion failed 1980\n");
140 ok( (!((ft
.dwHighDateTime
!=NEWYEAR_1980_HI
) ||
141 (ft
.dwLowDateTime
!=NEWYEAR_1980_LO
))) ,
142 "Wrong time for 1980 %08x %08x (correct %08x %08x)\n", ft
.dwLowDateTime
,
143 ft
.dwHighDateTime
, NEWYEAR_1980_LO
,NEWYEAR_1980_HI
);
145 ok(DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft
),
146 "DosDateTimeToFileTime() failed\n");
148 ok( (!((ft
.dwHighDateTime
!=NEWYEAR_1980_HI
) ||
149 (ft
.dwLowDateTime
!=NEWYEAR_1980_LO
))),
150 "Wrong time DosDateTimeToFileTime %08x %08x (correct %08x %08x)\n",
151 ft
.dwHighDateTime
, ft
.dwLowDateTime
, NEWYEAR_1980_HI
, NEWYEAR_1980_LO
);
155 static void test_invalid_arg(void)
161 /* Invalid argument checks */
163 memset(&ft
,0,sizeof ft
);
164 ok( DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft
), /* this is 1 Jan 1980 00:00:00 */
165 "DosDateTimeToFileTime() failed\n");
167 ok( (ft
.dwHighDateTime
==NEWYEAR_1980_HI
) && (ft
.dwLowDateTime
==NEWYEAR_1980_LO
),
168 "filetime for 1/1/80 00:00:00 was %08x %08x\n", ft
.dwHighDateTime
, ft
.dwLowDateTime
);
170 /* now check SystemTimeToFileTime */
171 memset(&ft
,0,sizeof ft
);
174 /* try with a bad month */
178 ok( !SystemTimeToFileTime(&st
, &ft
), "bad month\n");
180 /* with a bad hour */
184 ok( !SystemTimeToFileTime(&st
, &ft
), "bad hour\n");
186 /* with a bad minute */
190 ok( !SystemTimeToFileTime(&st
, &ft
), "bad minute\n");
193 static LONGLONG
system_time_to_minutes(const SYSTEMTIME
*st
)
199 SetLastError(0xdeadbeef);
200 ret
= SystemTimeToFileTime(st
, &ft
);
201 ok(ret
, "SystemTimeToFileTime error %u\n", GetLastError());
203 minutes
= ((LONGLONG
)ft
.dwHighDateTime
<< 32) + ft
.dwLowDateTime
;
204 minutes
/= (LONGLONG
)600000000; /* convert to minutes */
208 static LONG
get_tz_bias(const TIME_ZONE_INFORMATION
*tzinfo
, DWORD tz_id
)
212 case TIME_ZONE_ID_DAYLIGHT
:
213 if (memcmp(&tzinfo
->StandardDate
, &tzinfo
->DaylightDate
, sizeof(tzinfo
->DaylightDate
)) != 0)
214 return tzinfo
->DaylightBias
;
217 case TIME_ZONE_ID_STANDARD
:
218 return tzinfo
->StandardBias
;
221 trace("unknown time zone id %d\n", tz_id
);
223 case TIME_ZONE_ID_UNKNOWN
:
228 static void test_GetTimeZoneInformation(void)
230 char std_name
[32], dlt_name
[32];
231 TIME_ZONE_INFORMATION tzinfo
, tzinfo1
;
234 SYSTEMTIME st
, current
, utc
, local
;
236 LONGLONG l_time
, s_time
;
240 s_time
= system_time_to_minutes(&st
);
242 SetLastError(0xdeadbeef);
243 res
= SystemTimeToFileTime(&st
, &s_ft
);
244 ok(res
, "SystemTimeToFileTime error %u\n", GetLastError());
245 SetLastError(0xdeadbeef);
246 res
= FileTimeToLocalFileTime(&s_ft
, &l_ft
);
247 ok(res
, "FileTimeToLocalFileTime error %u\n", GetLastError());
248 SetLastError(0xdeadbeef);
249 res
= FileTimeToSystemTime(&l_ft
, &local
);
250 ok(res
, "FileTimeToSystemTime error %u\n", GetLastError());
251 l_time
= system_time_to_minutes(&local
);
253 tz_id
= GetTimeZoneInformation(&tzinfo
);
254 ok(tz_id
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
256 trace("tz_id %u (%s)\n", tz_id
,
257 tz_id
== TIME_ZONE_ID_DAYLIGHT
? "TIME_ZONE_ID_DAYLIGHT" :
258 (tz_id
== TIME_ZONE_ID_STANDARD
? "TIME_ZONE_ID_STANDARD" :
259 (tz_id
== TIME_ZONE_ID_UNKNOWN
? "TIME_ZONE_ID_UNKNOWN" :
260 "TIME_ZONE_ID_INVALID")));
262 WideCharToMultiByte(CP_ACP
, 0, tzinfo
.StandardName
, -1, std_name
, sizeof(std_name
), NULL
, NULL
);
263 WideCharToMultiByte(CP_ACP
, 0, tzinfo
.DaylightName
, -1, dlt_name
, sizeof(dlt_name
), NULL
, NULL
);
264 trace("bias %d, %s - %s\n", tzinfo
.Bias
, std_name
, dlt_name
);
265 trace("standard (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
266 tzinfo
.StandardDate
.wDay
, tzinfo
.StandardDate
.wMonth
,
267 tzinfo
.StandardDate
.wYear
, tzinfo
.StandardDate
.wDayOfWeek
,
268 tzinfo
.StandardDate
.wHour
, tzinfo
.StandardDate
.wMinute
,
269 tzinfo
.StandardDate
.wSecond
, tzinfo
.StandardDate
.wMilliseconds
,
270 tzinfo
.StandardBias
);
271 trace("daylight (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
272 tzinfo
.DaylightDate
.wDay
, tzinfo
.DaylightDate
.wMonth
,
273 tzinfo
.DaylightDate
.wYear
, tzinfo
.DaylightDate
.wDayOfWeek
,
274 tzinfo
.DaylightDate
.wHour
, tzinfo
.DaylightDate
.wMinute
,
275 tzinfo
.DaylightDate
.wSecond
, tzinfo
.DaylightDate
.wMilliseconds
,
276 tzinfo
.DaylightBias
);
278 diff
= (LONG
)(s_time
- l_time
);
279 ok(diff
== tzinfo
.Bias
+ get_tz_bias(&tzinfo
, tz_id
),
280 "system/local diff %d != tz bias %d\n",
281 diff
, tzinfo
.Bias
+ get_tz_bias(&tzinfo
, tz_id
));
283 ok(SetEnvironmentVariableA("TZ","GMT0") != 0,
284 "SetEnvironmentVariableA failed\n");
285 res
= GetTimeZoneInformation(&tzinfo1
);
286 ok(res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
288 ok(((tzinfo
.Bias
== tzinfo1
.Bias
) &&
289 (tzinfo
.StandardBias
== tzinfo1
.StandardBias
) &&
290 (tzinfo
.DaylightBias
== tzinfo1
.DaylightBias
)),
291 "Bias influenced by TZ variable\n");
292 ok(SetEnvironmentVariableA("TZ",NULL
) != 0,
293 "SetEnvironmentVariableA failed\n");
295 if (!pSystemTimeToTzSpecificLocalTime
)
297 win_skip("SystemTimeToTzSpecificLocalTime not available\n");
301 diff
= get_tz_bias(&tzinfo
, tz_id
);
304 SetLastError(0xdeadbeef);
305 res
= pSystemTimeToTzSpecificLocalTime(&tzinfo
, &utc
, ¤t
);
306 if (!res
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
308 win_skip("SystemTimeToTzSpecificLocalTime is not implemented\n");
312 ok(res
, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
313 s_time
= system_time_to_minutes(¤t
);
315 tzinfo
.StandardBias
-= 123;
316 tzinfo
.DaylightBias
+= 456;
318 res
= pSystemTimeToTzSpecificLocalTime(&tzinfo
, &utc
, &local
);
319 ok(res
, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
320 l_time
= system_time_to_minutes(&local
);
321 ok(l_time
- s_time
== diff
- get_tz_bias(&tzinfo
, tz_id
), "got %d, expected %d\n",
322 (LONG
)(l_time
- s_time
), diff
- get_tz_bias(&tzinfo
, tz_id
));
324 /* pretend that there is no transition dates */
325 tzinfo
.DaylightDate
.wDay
= 0;
326 tzinfo
.DaylightDate
.wMonth
= 0;
327 tzinfo
.DaylightDate
.wYear
= 0;
328 tzinfo
.StandardDate
.wDay
= 0;
329 tzinfo
.StandardDate
.wMonth
= 0;
330 tzinfo
.StandardDate
.wYear
= 0;
332 res
= pSystemTimeToTzSpecificLocalTime(&tzinfo
, &utc
, &local
);
333 ok(res
, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
334 l_time
= system_time_to_minutes(&local
);
335 ok(l_time
- s_time
== diff
, "got %d, expected %d\n",
336 (LONG
)(l_time
- s_time
), diff
);
339 static void test_FileTimeToSystemTime(void)
343 ULONGLONG time
= (ULONGLONG
)TICKSPERSEC
+ TICKS_1601_TO_1970
;
346 ft
.dwHighDateTime
= 0;
347 ft
.dwLowDateTime
= 0;
348 ret
= FileTimeToSystemTime(&ft
, &st
);
350 "FileTimeToSystemTime() failed with Error %d\n",GetLastError());
351 ok(((st
.wYear
== 1601) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
352 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 0) &&
353 (st
.wMilliseconds
== 0)),
354 "Got Year %4d Month %2d Day %2d\n", st
.wYear
, st
.wMonth
, st
.wDay
);
356 ft
.dwHighDateTime
= (UINT
)(time
>> 32);
357 ft
.dwLowDateTime
= (UINT
)time
;
358 ret
= FileTimeToSystemTime(&ft
, &st
);
360 "FileTimeToSystemTime() failed with Error %d\n",GetLastError());
361 ok(((st
.wYear
== 1970) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
362 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 1) &&
363 (st
.wMilliseconds
== 0)),
364 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
365 st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
,
369 static void test_FileTimeToLocalFileTime(void)
373 TIME_ZONE_INFORMATION tzinfo
;
374 DWORD res
= GetTimeZoneInformation(&tzinfo
);
375 ULONGLONG time
= (ULONGLONG
)TICKSPERSEC
+ TICKS_1601_TO_1970
+
376 (LONGLONG
)(tzinfo
.Bias
+
377 ( res
== TIME_ZONE_ID_STANDARD
? tzinfo
.StandardBias
:
378 ( res
== TIME_ZONE_ID_DAYLIGHT
? tzinfo
.DaylightBias
: 0 ))) *
379 SECSPERMIN
*TICKSPERSEC
;
382 ok( res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
383 ft
.dwHighDateTime
= (UINT
)(time
>> 32);
384 ft
.dwLowDateTime
= (UINT
)time
;
385 ret
= FileTimeToLocalFileTime(&ft
, &lft
);
387 "FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
388 FileTimeToSystemTime(&lft
, &st
);
389 ok(((st
.wYear
== 1970) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
390 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 1) &&
391 (st
.wMilliseconds
== 0)),
392 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
393 st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
,
396 ok(SetEnvironmentVariableA("TZ","GMT") != 0,
397 "SetEnvironmentVariableA failed\n");
398 ok(res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
399 ret
= FileTimeToLocalFileTime(&ft
, &lft
);
401 "FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
402 FileTimeToSystemTime(&lft
, &st
);
403 ok(((st
.wYear
== 1970) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
404 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 1) &&
405 (st
.wMilliseconds
== 0)),
406 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
407 st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
,
409 ok(SetEnvironmentVariableA("TZ",NULL
) != 0,
410 "SetEnvironmentVariableA failed\n");
414 int nr
; /* test case number for easier lookup */
415 TIME_ZONE_INFORMATION
*ptz
; /* ptr to timezone */
416 SYSTEMTIME slt
; /* system/local time to convert */
417 WORD ehour
; /* expected hour */
420 static void test_TzSpecificLocalTimeToSystemTime(void)
422 TIME_ZONE_INFORMATION tzE
, tzW
, tzS
;
426 if (!pTzSpecificLocalTimeToSystemTime
|| !pSystemTimeToTzSpecificLocalTime
)
428 win_skip("TzSpecificLocalTimeToSystemTime or SystemTimeToTzSpecificLocalTime not available\n");
432 ZeroMemory( &tzE
, sizeof(tzE
));
433 ZeroMemory( &tzW
, sizeof(tzW
));
434 ZeroMemory( &tzS
, sizeof(tzS
));
435 /* timezone Eastern hemisphere */
438 tzE
.DaylightBias
=-60;
439 tzE
.StandardDate
.wMonth
=10;
440 tzE
.StandardDate
.wDayOfWeek
=0; /*sunday */
441 tzE
.StandardDate
.wDay
=5; /* last (sunday) of the month */
442 tzE
.StandardDate
.wHour
=3;
443 tzE
.DaylightDate
.wMonth
=3;
444 tzE
.DaylightDate
.wDay
=5;
445 tzE
.DaylightDate
.wHour
=2;
446 /* timezone Western hemisphere */
449 tzW
.DaylightBias
=-60;
450 tzW
.StandardDate
.wMonth
=10;
451 tzW
.StandardDate
.wDayOfWeek
=0; /*sunday */
452 tzW
.StandardDate
.wDay
=4; /* 4th (sunday) of the month */
453 tzW
.StandardDate
.wHour
=2;
454 tzW
.DaylightDate
.wMonth
=4;
455 tzW
.DaylightDate
.wDay
=1;
456 tzW
.DaylightDate
.wHour
=2;
457 /* timezone Eastern hemisphere */
460 tzS
.DaylightBias
=-60;
461 tzS
.StandardDate
.wMonth
=4;
462 tzS
.StandardDate
.wDayOfWeek
=0; /*sunday */
463 tzS
.StandardDate
.wDay
=1; /* 1st (sunday) of the month */
464 tzS
.StandardDate
.wHour
=2;
465 tzS
.DaylightDate
.wMonth
=10;
466 tzS
.DaylightDate
.wDay
=4;
467 tzS
.DaylightDate
.wHour
=2;
469 /* TzSpecificLocalTimeToSystemTime */
470 { TZLT2ST_case cases
[] = {
471 /* standard->daylight transition */
472 { 1, &tzE
, {2004,3,-1,28,1,0,0,0}, 15 },
473 { 2, &tzE
, {2004,3,-1,28,1,59,59,999}, 15},
474 { 3, &tzE
, {2004,3,-1,28,2,0,0,0}, 15},
475 /* daylight->standard transition */
476 { 4, &tzE
, {2004,10,-1,31,2,0,0,0} , 15 },
477 { 5, &tzE
, {2004,10,-1,31,2,59,59,999}, 15 },
478 { 6, &tzE
, {2004,10,-1,31,3,0,0,0}, 17 },
479 /* West and with fixed weekday of the month */
480 { 7, &tzW
, {2004,4,-1,4,1,0,0,0}, 5},
481 { 8, &tzW
, {2004,4,-1,4,1,59,59,999}, 5},
482 { 9, &tzW
, {2004,4,-1,4,2,0,0,0}, 5},
483 { 10, &tzW
, {2004,10,-1,24,1,0,0,0}, 4},
484 { 11, &tzW
, {2004,10,-1,24,1,59,59,999}, 4},
485 { 12, &tzW
, {2004,10,-1,24,2,0,0,0 }, 6},
487 { 13, &tzS
, {2004,4,-1,4,1,0,0,0}, 4},
488 { 14, &tzS
, {2004,4,-1,4,1,59,59,999}, 4},
489 { 15, &tzS
, {2004,4,-1,4,2,0,0,0}, 6},
490 { 16, &tzS
, {2004,10,-1,24,1,0,0,0}, 5},
491 { 17, &tzS
, {2004,10,-1,24,1,59,59,999}, 5},
492 { 18, &tzS
, {2004,10,-1,24,2,0,0,0}, 5},
495 /* days of transitions to put into the cases array */
498 {28,31,4,24,4,24} /* 1999 */
499 , {26,29,2,22,2,22} /* 2000 */
500 , {25,28,1,28,1,28} /* 2001 */
501 , {31,27,7,27,7,27} /* 2002 */
502 , {30,26,6,26,6,26} /* 2003 */
503 , {28,31,4,24,4,24} /* 2004 */
504 , {27,30,3,23,3,23} /* 2005 */
505 , {26,29,2,22,2,22} /* 2006 */
506 , {25,28,1,28,1,28} /* 2007 */
507 , {30,26,6,26,6,26} /* 2008 */
508 , {29,25,5,25,5,25} /* 2009 */
509 , {28,31,4,24,4,24} /* 2010 */
510 , {27,30,3,23,3,23} /* 2011 */
511 , {25,28,1,28,1,28} /* 2012 */
512 , {31,27,7,27,7,27} /* 2013 */
513 , {30,26,6,26,6,26} /* 2014 */
514 , {29,25,5,25,5,25} /* 2015 */
515 , {27,30,3,23,3,23} /* 2016 */
516 , {26,29,2,22,2,22} /* 2017 */
517 , {25,28,1,28,1,28} /* 2018 */
518 , {31,27,7,27,7,27} /* 2019 */
521 for( j
=0 , year
= 1999; yeardays
[j
][0] ; j
++, year
++) {
522 for (i
=0; cases
[i
].nr
; i
++) {
523 if(i
) cases
[i
].nr
+= 18;
524 cases
[i
].slt
.wYear
= year
;
525 cases
[i
].slt
.wDay
= yeardays
[j
][i
/3];
526 pTzSpecificLocalTimeToSystemTime( cases
[i
].ptz
, &(cases
[i
].slt
), &result
);
527 ok( result
.wHour
== cases
[i
].ehour
,
528 "Test TzSpecificLocalTimeToSystemTime #%d. Got %4d-%02d-%02d %02d:%02d. Expect hour = %02d\n",
529 cases
[i
].nr
, result
.wYear
, result
.wMonth
, result
.wDay
,
530 result
.wHour
, result
.wMinute
, cases
[i
].ehour
);
534 /* SystemTimeToTzSpecificLocalTime */
535 { TZLT2ST_case cases
[] = {
536 /* standard->daylight transition */
537 { 1, &tzE
, {2004,3,-1,27,15,0,0,0}, 1 },
538 { 2, &tzE
, {2004,3,-1,27,15,59,59,999}, 1},
539 { 3, &tzE
, {2004,3,-1,27,16,0,0,0}, 3},
540 /* daylight->standard transition */
541 { 4, &tzE
, {2004,10,-1,30,15,0,0,0}, 2 },
542 { 5, &tzE
, {2004,10,-1,30,15,59,59,999}, 2 },
543 { 6, &tzE
, {2004,10,-1,30,16,0,0,0}, 2 },
544 /* West and with fixed weekday of the month */
545 { 7, &tzW
, {2004,4,-1,4,5,0,0,0}, 1},
546 { 8, &tzW
, {2004,4,-1,4,5,59,59,999}, 1},
547 { 9, &tzW
, {2004,4,-1,4,6,0,0,0}, 3},
548 { 10, &tzW
, {2004,10,-1,24,4,0,0,0}, 1},
549 { 11, &tzW
, {2004,10,-1,24,4,59,59,999}, 1},
550 { 12, &tzW
, {2004,10,-1,24,5,0,0,0 }, 1},
552 { 13, &tzS
, {2004,4,-1,4,4,0,0,0}, 1},
553 { 14, &tzS
, {2004,4,-1,4,4,59,59,999}, 1},
554 { 15, &tzS
, {2004,4,-1,4,5,0,0,0}, 1},
555 { 16, &tzS
, {2004,10,-1,24,5,0,0,0}, 1},
556 { 17, &tzS
, {2004,10,-1,24,5,59,59,999}, 1},
557 { 18, &tzS
, {2004,10,-1,24,6,0,0,0}, 3},
561 /* days of transitions to put into the cases array */
564 {27,30,4,24,4,24} /* 1999 */
565 , {25,28,2,22,2,22} /* 2000 */
566 , {24,27,1,28,1,28} /* 2001 */
567 , {30,26,7,27,7,27} /* 2002 */
568 , {29,25,6,26,6,26} /* 2003 */
569 , {27,30,4,24,4,24} /* 2004 */
570 , {26,29,3,23,3,23} /* 2005 */
571 , {25,28,2,22,2,22} /* 2006 */
572 , {24,27,1,28,1,28} /* 2007 */
573 , {29,25,6,26,6,26} /* 2008 */
574 , {28,24,5,25,5,25} /* 2009 */
575 , {27,30,4,24,4,24} /* 2010 */
576 , {26,29,3,23,3,23} /* 2011 */
577 , {24,27,1,28,1,28} /* 2012 */
578 , {30,26,7,27,7,27} /* 2013 */
579 , {29,25,6,26,6,26} /* 2014 */
580 , {28,24,5,25,5,25} /* 2015 */
581 , {26,29,3,23,3,23} /* 2016 */
582 , {25,28,2,22,2,22} /* 2017 */
583 , {24,27,1,28,1,28} /* 2018 */
584 , {30,26,7,27,7,27} /* 2019 */
586 for( j
=0 , year
= 1999; yeardays
[j
][0] ; j
++, year
++) {
587 for (i
=0; cases
[i
].nr
; i
++) {
588 if(i
) cases
[i
].nr
+= 18;
589 cases
[i
].slt
.wYear
= year
;
590 cases
[i
].slt
.wDay
= yeardays
[j
][i
/3];
591 pSystemTimeToTzSpecificLocalTime( cases
[i
].ptz
, &(cases
[i
].slt
), &result
);
592 ok( result
.wHour
== cases
[i
].ehour
,
593 "Test SystemTimeToTzSpecificLocalTime #%d. Got %4d-%02d-%02d %02d:%02d. Expect hour = %02d\n",
594 cases
[i
].nr
, result
.wYear
, result
.wMonth
, result
.wDay
,
595 result
.wHour
, result
.wMinute
, cases
[i
].ehour
);
604 HMODULE hKernel
= GetModuleHandle("kernel32");
605 pTzSpecificLocalTimeToSystemTime
= (void *)GetProcAddress(hKernel
, "TzSpecificLocalTimeToSystemTime");
606 pSystemTimeToTzSpecificLocalTime
= (void *)GetProcAddress( hKernel
, "SystemTimeToTzSpecificLocalTime");
610 test_GetTimeZoneInformation();
611 test_FileTimeToSystemTime();
612 test_FileTimeToLocalFileTime();
613 test_TzSpecificLocalTimeToSystemTime();