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
);
108 ok (!SystemTimeToFileTime(&st
, &ft
), "Conversion succeeded EARLY\n");
109 ok (GetLastError() == ERROR_INVALID_PARAMETER
, "EARLY should be INVALID\n");
112 ok (SystemTimeToFileTime(&st
, &ft
), "Conversion failed ZERO_TIME\n");
113 ok( (!((ft
.dwHighDateTime
!= 0) || (ft
.dwLowDateTime
!= 0))),
114 "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
115 ft
.dwLowDateTime
, ft
.dwHighDateTime
, 0, 0);
119 ok (SystemTimeToFileTime(&st
,&ft
), "Conversion Failed ATIME\n");
120 ok( (!((ft
.dwHighDateTime
!= ATIME_HI
) || (ft
.dwLowDateTime
!=ATIME_LOW
))),
121 "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
122 ft
.dwLowDateTime
, ft
.dwHighDateTime
, ATIME_LOW
, ATIME_HI
);
126 ok (SystemTimeToFileTime(&st
, &ft
), "Conversion failed 2002\n");
128 ok( (!((ft
.dwHighDateTime
!= MAYDAY_2002_HI
) ||
129 (ft
.dwLowDateTime
!=MAYDAY_2002_LO
))),
130 "Wrong time for 2002 %08x %08x (correct %08x %08x)\n", ft
.dwLowDateTime
,
131 ft
.dwHighDateTime
, MAYDAY_2002_LO
, MAYDAY_2002_HI
);
135 ok((SystemTimeToFileTime(&st
, &ft
)), "Conversion failed 1980\n");
137 ok( (!((ft
.dwHighDateTime
!=NEWYEAR_1980_HI
) ||
138 (ft
.dwLowDateTime
!=NEWYEAR_1980_LO
))) ,
139 "Wrong time for 1980 %08x %08x (correct %08x %08x)\n", ft
.dwLowDateTime
,
140 ft
.dwHighDateTime
, NEWYEAR_1980_LO
,NEWYEAR_1980_HI
);
142 ok(DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft
),
143 "DosDateTimeToFileTime() failed\n");
145 ok( (!((ft
.dwHighDateTime
!=NEWYEAR_1980_HI
) ||
146 (ft
.dwLowDateTime
!=NEWYEAR_1980_LO
))),
147 "Wrong time DosDateTimeToFileTime %08x %08x (correct %08x %08x)\n",
148 ft
.dwHighDateTime
, ft
.dwLowDateTime
, NEWYEAR_1980_HI
, NEWYEAR_1980_LO
);
152 static void test_invalid_arg(void)
158 /* Invalid argument checks */
160 memset(&ft
,0,sizeof ft
);
161 ok( DosDateTimeToFileTime(DOS_DATE(1980,1,1),DOS_TIME(0,0,0),&ft
), /* this is 1 Jan 1980 00:00:00 */
162 "DosDateTimeToFileTime() failed\n");
164 ok( (ft
.dwHighDateTime
==NEWYEAR_1980_HI
) && (ft
.dwLowDateTime
==NEWYEAR_1980_LO
),
165 "filetime for 1/1/80 00:00:00 was %08x %08x\n", ft
.dwHighDateTime
, ft
.dwLowDateTime
);
167 /* now check SystemTimeToFileTime */
168 memset(&ft
,0,sizeof ft
);
171 /* try with a bad month */
175 ok( !SystemTimeToFileTime(&st
, &ft
), "bad month\n");
177 /* with a bad hour */
181 ok( !SystemTimeToFileTime(&st
, &ft
), "bad hour\n");
183 /* with a bad minute */
187 ok( !SystemTimeToFileTime(&st
, &ft
), "bad minute\n");
190 static LONGLONG
system_time_to_minutes(const SYSTEMTIME
*st
)
196 SetLastError(0xdeadbeef);
197 ret
= SystemTimeToFileTime(st
, &ft
);
198 ok(ret
, "SystemTimeToFileTime error %u\n", GetLastError());
200 minutes
= ((LONGLONG
)ft
.dwHighDateTime
<< 32) + ft
.dwLowDateTime
;
201 minutes
/= (LONGLONG
)600000000; /* convert to minutes */
205 static LONG
get_tz_bias(const TIME_ZONE_INFORMATION
*tzinfo
, DWORD tz_id
)
209 case TIME_ZONE_ID_DAYLIGHT
:
210 if (memcmp(&tzinfo
->StandardDate
, &tzinfo
->DaylightDate
, sizeof(tzinfo
->DaylightDate
)) != 0)
211 return tzinfo
->DaylightBias
;
214 case TIME_ZONE_ID_STANDARD
:
215 return tzinfo
->StandardBias
;
218 trace("unknown time zone id %d\n", tz_id
);
220 case TIME_ZONE_ID_UNKNOWN
:
225 static void test_GetTimeZoneInformation(void)
227 char std_name
[32], dlt_name
[32];
228 TIME_ZONE_INFORMATION tzinfo
, tzinfo1
;
231 SYSTEMTIME st
, current
, utc
, local
;
233 LONGLONG l_time
, s_time
;
237 s_time
= system_time_to_minutes(&st
);
239 SetLastError(0xdeadbeef);
240 res
= SystemTimeToFileTime(&st
, &s_ft
);
241 ok(res
, "SystemTimeToFileTime error %u\n", GetLastError());
242 SetLastError(0xdeadbeef);
243 res
= FileTimeToLocalFileTime(&s_ft
, &l_ft
);
244 ok(res
, "FileTimeToLocalFileTime error %u\n", GetLastError());
245 SetLastError(0xdeadbeef);
246 res
= FileTimeToSystemTime(&l_ft
, &local
);
247 ok(res
, "FileTimeToSystemTime error %u\n", GetLastError());
248 l_time
= system_time_to_minutes(&local
);
250 tz_id
= GetTimeZoneInformation(&tzinfo
);
251 ok(tz_id
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
253 trace("tz_id %u (%s)\n", tz_id
,
254 tz_id
== TIME_ZONE_ID_DAYLIGHT
? "TIME_ZONE_ID_DAYLIGHT" :
255 (tz_id
== TIME_ZONE_ID_STANDARD
? "TIME_ZONE_ID_STANDARD" :
256 (tz_id
== TIME_ZONE_ID_UNKNOWN
? "TIME_ZONE_ID_UNKNOWN" :
257 "TIME_ZONE_ID_INVALID")));
259 WideCharToMultiByte(CP_ACP
, 0, tzinfo
.StandardName
, -1, std_name
, sizeof(std_name
), NULL
, NULL
);
260 WideCharToMultiByte(CP_ACP
, 0, tzinfo
.DaylightName
, -1, dlt_name
, sizeof(dlt_name
), NULL
, NULL
);
261 trace("bias %d, %s - %s\n", tzinfo
.Bias
, std_name
, dlt_name
);
262 trace("standard (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
263 tzinfo
.StandardDate
.wDay
, tzinfo
.StandardDate
.wMonth
,
264 tzinfo
.StandardDate
.wYear
, tzinfo
.StandardDate
.wDayOfWeek
,
265 tzinfo
.StandardDate
.wHour
, tzinfo
.StandardDate
.wMinute
,
266 tzinfo
.StandardDate
.wSecond
, tzinfo
.StandardDate
.wMilliseconds
,
267 tzinfo
.StandardBias
);
268 trace("daylight (d/m/y): %u/%02u/%04u day of week %u %u:%02u:%02u.%03u bias %d\n",
269 tzinfo
.DaylightDate
.wDay
, tzinfo
.DaylightDate
.wMonth
,
270 tzinfo
.DaylightDate
.wYear
, tzinfo
.DaylightDate
.wDayOfWeek
,
271 tzinfo
.DaylightDate
.wHour
, tzinfo
.DaylightDate
.wMinute
,
272 tzinfo
.DaylightDate
.wSecond
, tzinfo
.DaylightDate
.wMilliseconds
,
273 tzinfo
.DaylightBias
);
275 diff
= (LONG
)(s_time
- l_time
);
276 ok(diff
== tzinfo
.Bias
+ get_tz_bias(&tzinfo
, tz_id
),
277 "system/local diff %d != tz bias %d\n",
278 diff
, tzinfo
.Bias
+ get_tz_bias(&tzinfo
, tz_id
));
280 ok(SetEnvironmentVariableA("TZ","GMT0") != 0,
281 "SetEnvironmentVariableA failed\n");
282 res
= GetTimeZoneInformation(&tzinfo1
);
283 ok(res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
285 ok(((tzinfo
.Bias
== tzinfo1
.Bias
) &&
286 (tzinfo
.StandardBias
== tzinfo1
.StandardBias
) &&
287 (tzinfo
.DaylightBias
== tzinfo1
.DaylightBias
)),
288 "Bias influenced by TZ variable\n");
289 ok(SetEnvironmentVariableA("TZ",NULL
) != 0,
290 "SetEnvironmentVariableA failed\n");
292 if (!pSystemTimeToTzSpecificLocalTime
)
294 skip("SystemTimeToTzSpecificLocalTime not present\n");
298 diff
= get_tz_bias(&tzinfo
, tz_id
);
301 SetLastError(0xdeadbeef);
302 res
= pSystemTimeToTzSpecificLocalTime(&tzinfo
, &utc
, ¤t
);
303 if (!res
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
305 skip("SystemTimeToTzSpecificLocalTime is not implemented\n");
309 ok(res
, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
310 s_time
= system_time_to_minutes(¤t
);
312 tzinfo
.StandardBias
-= 123;
313 tzinfo
.DaylightBias
+= 456;
315 res
= pSystemTimeToTzSpecificLocalTime(&tzinfo
, &utc
, &local
);
316 ok(res
, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
317 l_time
= system_time_to_minutes(&local
);
318 ok(l_time
- s_time
== diff
- get_tz_bias(&tzinfo
, tz_id
), "got %d, expected %d\n",
319 (LONG
)(l_time
- s_time
), diff
- get_tz_bias(&tzinfo
, tz_id
));
321 /* pretend that there is no transition dates */
322 tzinfo
.DaylightDate
.wDay
= 0;
323 tzinfo
.DaylightDate
.wMonth
= 0;
324 tzinfo
.DaylightDate
.wYear
= 0;
325 tzinfo
.StandardDate
.wDay
= 0;
326 tzinfo
.StandardDate
.wMonth
= 0;
327 tzinfo
.StandardDate
.wYear
= 0;
329 res
= pSystemTimeToTzSpecificLocalTime(&tzinfo
, &utc
, &local
);
330 ok(res
, "SystemTimeToTzSpecificLocalTime error %u\n", GetLastError());
331 l_time
= system_time_to_minutes(&local
);
332 ok(l_time
- s_time
== diff
, "got %d, expected %d\n",
333 (LONG
)(l_time
- s_time
), diff
);
336 static void test_FileTimeToSystemTime(void)
340 ULONGLONG time
= (ULONGLONG
)TICKSPERSEC
+ TICKS_1601_TO_1970
;
343 ft
.dwHighDateTime
= 0;
344 ft
.dwLowDateTime
= 0;
345 ret
= FileTimeToSystemTime(&ft
, &st
);
347 "FileTimeToSystemTime() failed with Error %d\n",GetLastError());
348 ok(((st
.wYear
== 1601) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
349 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 0) &&
350 (st
.wMilliseconds
== 0)),
351 "Got Year %4d Month %2d Day %2d\n", st
.wYear
, st
.wMonth
, st
.wDay
);
353 ft
.dwHighDateTime
= (UINT
)(time
>> 32);
354 ft
.dwLowDateTime
= (UINT
)time
;
355 ret
= FileTimeToSystemTime(&ft
, &st
);
357 "FileTimeToSystemTime() failed with Error %d\n",GetLastError());
358 ok(((st
.wYear
== 1970) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
359 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 1) &&
360 (st
.wMilliseconds
== 0)),
361 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
362 st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
,
366 static void test_FileTimeToLocalFileTime(void)
370 TIME_ZONE_INFORMATION tzinfo
;
371 DWORD res
= GetTimeZoneInformation(&tzinfo
);
372 ULONGLONG time
= (ULONGLONG
)TICKSPERSEC
+ TICKS_1601_TO_1970
+
373 (LONGLONG
)(tzinfo
.Bias
+
374 ( res
== TIME_ZONE_ID_STANDARD
? tzinfo
.StandardBias
:
375 ( res
== TIME_ZONE_ID_DAYLIGHT
? tzinfo
.DaylightBias
: 0 ))) *
376 SECSPERMIN
*TICKSPERSEC
;
379 ok( res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
380 ft
.dwHighDateTime
= (UINT
)(time
>> 32);
381 ft
.dwLowDateTime
= (UINT
)time
;
382 ret
= FileTimeToLocalFileTime(&ft
, &lft
);
384 "FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
385 FileTimeToSystemTime(&lft
, &st
);
386 ok(((st
.wYear
== 1970) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
387 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 1) &&
388 (st
.wMilliseconds
== 0)),
389 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
390 st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
,
393 ok(SetEnvironmentVariableA("TZ","GMT") != 0,
394 "SetEnvironmentVariableA failed\n");
395 ok(res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
396 ret
= FileTimeToLocalFileTime(&ft
, &lft
);
398 "FileTimeToLocalFileTime() failed with Error %d\n",GetLastError());
399 FileTimeToSystemTime(&lft
, &st
);
400 ok(((st
.wYear
== 1970) && (st
.wMonth
== 1) && (st
.wDay
== 1) &&
401 (st
.wHour
== 0) && (st
.wMinute
== 0) && (st
.wSecond
== 1) &&
402 (st
.wMilliseconds
== 0)),
403 "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
404 st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
,
406 ok(SetEnvironmentVariableA("TZ",NULL
) != 0,
407 "SetEnvironmentVariableA failed\n");
411 int nr
; /* test case number for easier lookup */
412 TIME_ZONE_INFORMATION
*ptz
; /* ptr to timezone */
413 SYSTEMTIME slt
; /* system/local time to convert */
414 WORD ehour
; /* expected hour */
417 static void test_TzSpecificLocalTimeToSystemTime(void)
419 TIME_ZONE_INFORMATION tzE
, tzW
, tzS
;
423 if (!pTzSpecificLocalTimeToSystemTime
|| !pSystemTimeToTzSpecificLocalTime
)
425 skip("TzSpecificLocalTimeToSystemTime or SystemTimeToTzSpecificLocalTime not present\n");
429 ZeroMemory( &tzE
, sizeof(tzE
));
430 ZeroMemory( &tzW
, sizeof(tzW
));
431 ZeroMemory( &tzS
, sizeof(tzS
));
432 /* timezone Eastern hemisphere */
435 tzE
.DaylightBias
=-60;
436 tzE
.StandardDate
.wMonth
=10;
437 tzE
.StandardDate
.wDayOfWeek
=0; /*sunday */
438 tzE
.StandardDate
.wDay
=5; /* last (sunday) of the month */
439 tzE
.StandardDate
.wHour
=3;
440 tzE
.DaylightDate
.wMonth
=3;
441 tzE
.DaylightDate
.wDay
=5;
442 tzE
.DaylightDate
.wHour
=2;
443 /* timezone Western hemisphere */
446 tzW
.DaylightBias
=-60;
447 tzW
.StandardDate
.wMonth
=10;
448 tzW
.StandardDate
.wDayOfWeek
=0; /*sunday */
449 tzW
.StandardDate
.wDay
=4; /* 4th (sunday) of the month */
450 tzW
.StandardDate
.wHour
=2;
451 tzW
.DaylightDate
.wMonth
=4;
452 tzW
.DaylightDate
.wDay
=1;
453 tzW
.DaylightDate
.wHour
=2;
454 /* timezone Eastern hemisphere */
457 tzS
.DaylightBias
=-60;
458 tzS
.StandardDate
.wMonth
=4;
459 tzS
.StandardDate
.wDayOfWeek
=0; /*sunday */
460 tzS
.StandardDate
.wDay
=1; /* 1st (sunday) of the month */
461 tzS
.StandardDate
.wHour
=2;
462 tzS
.DaylightDate
.wMonth
=10;
463 tzS
.DaylightDate
.wDay
=4;
464 tzS
.DaylightDate
.wHour
=2;
466 /* TzSpecificLocalTimeToSystemTime */
467 { TZLT2ST_case cases
[] = {
468 /* standard->daylight transition */
469 { 1, &tzE
, {2004,3,-1,28,1,0,0,0}, 15 },
470 { 2, &tzE
, {2004,3,-1,28,1,59,59,999}, 15},
471 { 3, &tzE
, {2004,3,-1,28,2,0,0,0}, 15},
472 /* daylight->standard transition */
473 { 4, &tzE
, {2004,10,-1,31,2,0,0,0} , 15 },
474 { 5, &tzE
, {2004,10,-1,31,2,59,59,999}, 15 },
475 { 6, &tzE
, {2004,10,-1,31,3,0,0,0}, 17 },
476 /* West and with fixed weekday of the month */
477 { 7, &tzW
, {2004,4,-1,4,1,0,0,0}, 5},
478 { 8, &tzW
, {2004,4,-1,4,1,59,59,999}, 5},
479 { 9, &tzW
, {2004,4,-1,4,2,0,0,0}, 5},
480 { 10, &tzW
, {2004,10,-1,24,1,0,0,0}, 4},
481 { 11, &tzW
, {2004,10,-1,24,1,59,59,999}, 4},
482 { 12, &tzW
, {2004,10,-1,24,2,0,0,0 }, 6},
484 { 13, &tzS
, {2004,4,-1,4,1,0,0,0}, 4},
485 { 14, &tzS
, {2004,4,-1,4,1,59,59,999}, 4},
486 { 15, &tzS
, {2004,4,-1,4,2,0,0,0}, 6},
487 { 16, &tzS
, {2004,10,-1,24,1,0,0,0}, 5},
488 { 17, &tzS
, {2004,10,-1,24,1,59,59,999}, 5},
489 { 18, &tzS
, {2004,10,-1,24,2,0,0,0}, 5},
492 /* days of transitions to put into the cases array */
495 {28,31,4,24,4,24} /* 1999 */
496 , {26,29,2,22,2,22} /* 2000 */
497 , {25,28,1,28,1,28} /* 2001 */
498 , {31,27,7,27,7,27} /* 2002 */
499 , {30,26,6,26,6,26} /* 2003 */
500 , {28,31,4,24,4,24} /* 2004 */
501 , {27,30,3,23,3,23} /* 2005 */
502 , {26,29,2,22,2,22} /* 2006 */
503 , {25,28,1,28,1,28} /* 2007 */
504 , {30,26,6,26,6,26} /* 2008 */
505 , {29,25,5,25,5,25} /* 2009 */
506 , {28,31,4,24,4,24} /* 2010 */
507 , {27,30,3,23,3,23} /* 2011 */
508 , {25,28,1,28,1,28} /* 2012 */
509 , {31,27,7,27,7,27} /* 2013 */
510 , {30,26,6,26,6,26} /* 2014 */
511 , {29,25,5,25,5,25} /* 2015 */
512 , {27,30,3,23,3,23} /* 2016 */
513 , {26,29,2,22,2,22} /* 2017 */
514 , {25,28,1,28,1,28} /* 2018 */
515 , {31,27,7,27,7,27} /* 2019 */
518 for( j
=0 , year
= 1999; yeardays
[j
][0] ; j
++, year
++) {
519 for (i
=0; cases
[i
].nr
; i
++) {
520 if(i
) cases
[i
].nr
+= 18;
521 cases
[i
].slt
.wYear
= year
;
522 cases
[i
].slt
.wDay
= yeardays
[j
][i
/3];
523 pTzSpecificLocalTimeToSystemTime( cases
[i
].ptz
, &(cases
[i
].slt
), &result
);
524 ok( result
.wHour
== cases
[i
].ehour
,
525 "Test TzSpecificLocalTimeToSystemTime #%d. Got %4d-%02d-%02d %02d:%02d. Expect hour = %02d\n",
526 cases
[i
].nr
, result
.wYear
, result
.wMonth
, result
.wDay
,
527 result
.wHour
, result
.wMinute
, cases
[i
].ehour
);
531 /* SystemTimeToTzSpecificLocalTime */
532 { TZLT2ST_case cases
[] = {
533 /* standard->daylight transition */
534 { 1, &tzE
, {2004,3,-1,27,15,0,0,0}, 1 },
535 { 2, &tzE
, {2004,3,-1,27,15,59,59,999}, 1},
536 { 3, &tzE
, {2004,3,-1,27,16,0,0,0}, 3},
537 /* daylight->standard transition */
538 { 4, &tzE
, {2004,10,-1,30,15,0,0,0}, 2 },
539 { 5, &tzE
, {2004,10,-1,30,15,59,59,999}, 2 },
540 { 6, &tzE
, {2004,10,-1,30,16,0,0,0}, 2 },
541 /* West and with fixed weekday of the month */
542 { 7, &tzW
, {2004,4,-1,4,5,0,0,0}, 1},
543 { 8, &tzW
, {2004,4,-1,4,5,59,59,999}, 1},
544 { 9, &tzW
, {2004,4,-1,4,6,0,0,0}, 3},
545 { 10, &tzW
, {2004,10,-1,24,4,0,0,0}, 1},
546 { 11, &tzW
, {2004,10,-1,24,4,59,59,999}, 1},
547 { 12, &tzW
, {2004,10,-1,24,5,0,0,0 }, 1},
549 { 13, &tzS
, {2004,4,-1,4,4,0,0,0}, 1},
550 { 14, &tzS
, {2004,4,-1,4,4,59,59,999}, 1},
551 { 15, &tzS
, {2004,4,-1,4,5,0,0,0}, 1},
552 { 16, &tzS
, {2004,10,-1,24,5,0,0,0}, 1},
553 { 17, &tzS
, {2004,10,-1,24,5,59,59,999}, 1},
554 { 18, &tzS
, {2004,10,-1,24,6,0,0,0}, 3},
558 /* days of transitions to put into the cases array */
561 {27,30,4,24,4,24} /* 1999 */
562 , {25,28,2,22,2,22} /* 2000 */
563 , {24,27,1,28,1,28} /* 2001 */
564 , {30,26,7,27,7,27} /* 2002 */
565 , {29,25,6,26,6,26} /* 2003 */
566 , {27,30,4,24,4,24} /* 2004 */
567 , {26,29,3,23,3,23} /* 2005 */
568 , {25,28,2,22,2,22} /* 2006 */
569 , {24,27,1,28,1,28} /* 2007 */
570 , {29,25,6,26,6,26} /* 2008 */
571 , {28,24,5,25,5,25} /* 2009 */
572 , {27,30,4,24,4,24} /* 2010 */
573 , {26,29,3,23,3,23} /* 2011 */
574 , {24,27,1,28,1,28} /* 2012 */
575 , {30,26,7,27,7,27} /* 2013 */
576 , {29,25,6,26,6,26} /* 2014 */
577 , {28,24,5,25,5,25} /* 2015 */
578 , {26,29,3,23,3,23} /* 2016 */
579 , {25,28,2,22,2,22} /* 2017 */
580 , {24,27,1,28,1,28} /* 2018 */
581 , {30,26,7,27,7,27} /* 2019 */
583 for( j
=0 , year
= 1999; yeardays
[j
][0] ; j
++, year
++) {
584 for (i
=0; cases
[i
].nr
; i
++) {
585 if(i
) cases
[i
].nr
+= 18;
586 cases
[i
].slt
.wYear
= year
;
587 cases
[i
].slt
.wDay
= yeardays
[j
][i
/3];
588 pSystemTimeToTzSpecificLocalTime( cases
[i
].ptz
, &(cases
[i
].slt
), &result
);
589 ok( result
.wHour
== cases
[i
].ehour
,
590 "Test SystemTimeToTzSpecificLocalTime #%d. Got %4d-%02d-%02d %02d:%02d. Expect hour = %02d\n",
591 cases
[i
].nr
, result
.wYear
, result
.wMonth
, result
.wDay
,
592 result
.wHour
, result
.wMinute
, cases
[i
].ehour
);
601 HMODULE hKernel
= GetModuleHandle("kernel32");
602 pTzSpecificLocalTimeToSystemTime
= (void *)GetProcAddress(hKernel
, "TzSpecificLocalTimeToSystemTime");
603 pSystemTimeToTzSpecificLocalTime
= (void *)GetProcAddress( hKernel
, "SystemTimeToTzSpecificLocalTime");
607 test_GetTimeZoneInformation();
608 test_FileTimeToSystemTime();
609 test_FileTimeToLocalFileTime();
610 test_TzSpecificLocalTimeToSystemTime();