Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2698 lines
88 KiB

  1. /*++
  2. Copyright (c) 1991-1999, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. gdftest.c
  5. Abstract:
  6. Test module for NLS API GetDateFormat.
  7. NOTE: This code was simply hacked together quickly in order to
  8. test the different code modules of the NLS component.
  9. This is NOT meant to be a formal regression test.
  10. Revision History:
  11. 04-30-93 JulieB Created.
  12. --*/
  13. //
  14. // Include Files.
  15. //
  16. #include "nlstest.h"
  17. //
  18. // Constant Declarations.
  19. //
  20. #define BUFSIZE 50 // buffer size in wide chars
  21. #define GDF_INVALID_FLAGS ((DWORD)(~(LOCALE_NOUSEROVERRIDE | \
  22. DATE_SHORTDATE | \
  23. DATE_LONGDATE | \
  24. DATE_YEARMONTH | \
  25. DATE_USE_ALT_CALENDAR)))
  26. #define ENGLISH_US L"5/1/1993"
  27. #define L_ENGLISH_US L"Saturday, May 01, 1993"
  28. #define CZECH L"1.5.1993"
  29. #define YEAR L"1993"
  30. #define YEAR_2 L"93"
  31. #define US_DAYOFWEEK L"Saturday"
  32. #define US_MONTH L"May"
  33. #define US_ABBREVDAY L"Sat"
  34. #define US_ABBREVMONTH L"May"
  35. #define SPANISH_DAYOFWEEK L"s�bado"
  36. #define SPANISH_MONTH L"mayo"
  37. #define SPANISH_ABBREVDAY L"s�b"
  38. #define SPANISH_ABBREVMONTH L"may"
  39. #define L_RUSSIAN_2 L"\x041c\x0430\x0439"
  40. #define L_RUSSIAN_3 L"\x043c\x0430\x044f 1"
  41. #define L_RUSSIAN_4 L"1 93 \x041c\x0430\x0439"
  42. #define L_POLISH_2 L"maj"
  43. #define L_POLISH_3 L"maja 1"
  44. #define L_POLISH_4 L"1 93 maj"
  45. #define JAPAN_ALT L"\x5e73\x6210 5/5/1"
  46. #define CHINA_ALT L"82/5/1"
  47. #define KOREA_ALT L"\xb2e8\xae30 4326-05-01"
  48. #define L_JAPAN_ALT L"\x5e73\x6210 5\x5e74\x0035\x6708\x0031\x65e5"
  49. #define L_CHINA_ALT L"\x4e2d\x83ef\x6c11\x570b\x0038\x0032\x5e74\x0035\x6708\x0031\x65e5"
  50. #define L_KOREA_ALT L"\xb2e8\xae30 4326\xb144 5\xc6d4 1\xc77c \xd1a0\xc694\xc77c"
  51. #define L_JAPAN_ALT_2 L"\x5927\x6b63 2\x5e74\x0035\x6708\x0031\x65e5"
  52. #define L_CHINA_ALT_2 L"1832\x5e74\x0035\x6708\x0031\x65e5"
  53. #define L_KOREA_ALT_2 L"\xb2e8\xae30 4165\xb144 5\xc6d4 1\xc77c \xd654\xc694\xc77c"
  54. #define L_JAPAN_ALT_3 L" 32\x5e74\x0035\x6708\x0031\x65e5"
  55. //
  56. // Global Variables.
  57. //
  58. LCID Locale;
  59. SYSTEMTIME SysDate;
  60. WCHAR lpDateStr[BUFSIZE];
  61. WCHAR pSShortDate[BUFSIZE];
  62. //
  63. // Date format buffers must be in line with the pAllLocales global
  64. // buffer.
  65. //
  66. LPWSTR pShortDate[] =
  67. {
  68. L"01.5.1993 \x0433.", // 0x0402
  69. L"1993/5/1", // 0x0404
  70. L"1993-5-1", // 0x0804
  71. L"1/5/1993", // 0x0c04
  72. L"1/5/1993", // 0x1004
  73. L"1.5.1993", // 0x0405
  74. L"01-05-1993", // 0x0406
  75. L"01.05.1993", // 0x0407
  76. L"01.05.1993", // 0x0807
  77. L"01.05.1993", // 0x0c07
  78. L"1/5/1993", // 0x0408
  79. L"5/1/1993", // 0x0409
  80. L"01/05/1993", // 0x0809
  81. L"1/05/1993", // 0x0c09
  82. L"01/05/1993", // 0x1009
  83. L"1/05/1993", // 0x1409
  84. L"01/05/1993", // 0x1809
  85. L"01/05/1993", // 0x040a
  86. L"01/05/1993", // 0x080a
  87. L"01/05/1993", // 0x0c0a
  88. L"1.5.1993", // 0x040b
  89. L"01/05/1993", // 0x040c
  90. L"1/05/1993", // 0x080c
  91. L"1993-05-01", // 0x0c0c
  92. L"01.05.1993", // 0x100c
  93. L"1993. 05. 01.", // 0x040e
  94. L"1.5.1993", // 0x040f
  95. L"01/05/1993", // 0x0410
  96. L"01.05.1993", // 0x0810
  97. L"1993/05/01", // 0x0411
  98. L"1993-05-01", // 0x0412
  99. L"1-5-1993", // 0x0413
  100. L"1/05/1993", // 0x0813
  101. L"01.05.1993", // 0x0414
  102. L"01.05.1993", // 0x0814
  103. L"1993-05-01", // 0x0415
  104. L"1/5/1993", // 0x0416
  105. L"01-05-1993", // 0x0816
  106. L"01.05.1993", // 0x0418
  107. L"01.05.1993", // 0x0419
  108. L"1.5.1993", // 0x041a
  109. L"1. 5. 1993", // 0x041b
  110. L"1993-05-01", // 0x041d
  111. L"01.05.1993", // 0x041f
  112. L"1.5.1993" // 0x0424
  113. };
  114. LPWSTR pLongDate[] =
  115. {
  116. L"01 \x041c\x0430\x0439 1993 \x0433.", // 0x0402
  117. L"1993\x5e74\x0035\x6708\x0031\x65e5", // 0x0404
  118. L"1993\x5e74\x0035\x6708\x0031\x65e5", // 0x0804
  119. L"Saturday, 1 May, 1993", // 0x0c04
  120. L"\x661f\x671f\x516d, 1 \x4e94\x6708, 1993", // 0x1004
  121. L"1. kv\x011btna 1993", // 0x0405
  122. L"1. maj 1993", // 0x0406
  123. L"Samstag, 1. Mai 1993", // 0x0407
  124. L"Samstag, 1. Mai 1993", // 0x0807
  125. L"Samstag, 01. Mai 1993", // 0x0c07
  126. L"\x03a3\x03ac\x03b2\x03b2\x03b1\x03c4\x03bf, 1 \x039c\x03b1\x0390\x03bf\x03c5 1993", // 0x0408
  127. L"Saturday, May 01, 1993", // 0x0409
  128. L"01 May 1993", // 0x0809
  129. L"Saturday, 1 May 1993", // 0x0c09
  130. L"May 1, 1993", // 0x1009
  131. L"Saturday, 1 May 1993", // 0x1409
  132. L"01 May 1993", // 0x1809
  133. L"s�bado, 01 de mayo de 1993", // 0x040a
  134. L"S�bado, 01 de Mayo de 1993", // 0x080a
  135. L"s�bado, 01 de mayo de 1993", // 0x0c0a
  136. L"1. toukokuuta 1993", // 0x040b
  137. L"samedi 1 mai 1993", // 0x040c
  138. L"samedi 1 mai 1993", // 0x080c
  139. L"1 mai, 1993", // 0x0c0c
  140. L"samedi, 1. mai 1993", // 0x100c
  141. L"1993. m�jus 1.", // 0x040e
  142. L"1. ma� 1993", // 0x040f
  143. L"sabato 1 maggio 1993", // 0x0410
  144. L"sabato, 1. maggio 1993", // 0x0810
  145. L"1993\x5e74\x0035\x6708\x0031\x65e5", // 0x0411
  146. L"1993\xb144 5\xc6d4 1\xc77c \xd1a0\xc694\xc77c", // 0x0412
  147. L"zaterdag 1 mei 1993", // 0x0413
  148. L"zaterdag 1 mei 1993", // 0x0813
  149. L"1. mai 1993", // 0x0414
  150. L"1. mai 1993", // 0x0814
  151. L"1 maja 1993", // 0x0415
  152. L"s�bado, 1 de maio de 1993", // 0x0416
  153. L"s�bado, 1 de Maio de 1993", // 0x0816
  154. L"1 mai 1993", // 0x0418
  155. L"1 \x043c\x0430\x044f 1993 \x0433.", // 0x0419
  156. L"1. svibanj 1993", // 0x041a
  157. L"1. m\x00e1ja 1993", // 0x041b
  158. L"den 1 maj 1993", // 0x041d
  159. L"01 May\x0131s 1993 Cumartesi", // 0x041f
  160. L"1. maj 1993" // 0x0424
  161. };
  162. LPWSTR pYearMonth[] =
  163. {
  164. L"\x041c\x0430\x0439 1993 \x0433.", // 0x0402
  165. L"1993\x5e74\x0035\x6708", // 0x0404
  166. L"1993\x5e74\x0035\x6708", // 0x0804
  167. L"May, 1993", // 0x0c04
  168. L"\x4e94\x6708, 1993", // 0x1004
  169. L"kv\x011bten 1993", // 0x0405
  170. L"maj 1993", // 0x0406
  171. L"Mai 1993", // 0x0407
  172. L"Mai 1993", // 0x0807
  173. L"Mai 1993", // 0x0c07
  174. L"\x039c\x03ac\x03b9\x03bf\x03c2 1993", // 0x0408
  175. L"May, 1993", // 0x0409
  176. L"May 1993", // 0x0809
  177. L"May 1993", // 0x0c09
  178. L"May, 1993", // 0x1009
  179. L"May 1993", // 0x1409
  180. L"May 1993", // 0x1809
  181. L"mayo de 1993", // 0x040a
  182. L"Mayo de 1993", // 0x080a
  183. L"mayo de 1993", // 0x0c0a
  184. L"toukokuu 1993", // 0x040b
  185. L"mai 1993", // 0x040c
  186. L"mai 1993", // 0x080c
  187. L"mai, 1993", // 0x0c0c
  188. L"mai 1993", // 0x100c
  189. L"1993. m�jus", // 0x040e
  190. L"ma� 1993", // 0x040f
  191. L"maggio 1993", // 0x0410
  192. L"maggio 1993", // 0x0810
  193. L"1993\x5e74\x0035\x6708", // 0x0411
  194. L"1993\xb144 5\xc6d4", // 0x0412
  195. L"mei 1993", // 0x0413
  196. L"mei 1993", // 0x0813
  197. L"mai 1993", // 0x0414
  198. L"mai 1993", // 0x0814
  199. L"maj 1993", // 0x0415
  200. L"maio de 1993", // 0x0416
  201. L"Maio de 1993", // 0x0816
  202. L"mai 1993", // 0x0418
  203. L"\x041c\x0430\x0439 1993 \x0433.", // 0x0419
  204. L"svibanj, 1993", // 0x041a
  205. L"m�j 1993", // 0x041b
  206. L"maj 1993", // 0x041d
  207. L"May\x0131s 1993", // 0x041f
  208. L"maj 1993" // 0x0424
  209. };
  210. //
  211. // Forward Declarations.
  212. //
  213. BOOL
  214. InitGetDateFormat();
  215. int
  216. GDF_BadParamCheck();
  217. int
  218. GDF_NormalCase();
  219. int
  220. GDF_Ansi();
  221. ////////////////////////////////////////////////////////////////////////////
  222. //
  223. // TestGetDateFormat
  224. //
  225. // Test routine for GetDateFormatW API.
  226. //
  227. // 04-30-93 JulieB Created.
  228. ////////////////////////////////////////////////////////////////////////////
  229. int TestGetDateFormat()
  230. {
  231. int ErrCount = 0; // error count
  232. //
  233. // Print out what's being done.
  234. //
  235. printf("\n\nTESTING GetDateFormatW...\n\n");
  236. //
  237. // Initialize global variables.
  238. //
  239. if (!InitGetDateFormat())
  240. {
  241. printf("\nABORTED TestGetDateFormat: Could not Initialize.\n");
  242. return (1);
  243. }
  244. //
  245. // Test bad parameters.
  246. //
  247. ErrCount += GDF_BadParamCheck();
  248. //
  249. // Test normal cases.
  250. //
  251. ErrCount += GDF_NormalCase();
  252. //
  253. // Test Ansi version.
  254. //
  255. ErrCount += GDF_Ansi();
  256. //
  257. // Print out result.
  258. //
  259. printf("\nGetDateFormatW: ERRORS = %d\n", ErrCount);
  260. //
  261. // Return total number of errors found.
  262. //
  263. return (ErrCount);
  264. }
  265. ////////////////////////////////////////////////////////////////////////////
  266. //
  267. // InitGetDateFormat
  268. //
  269. // This routine initializes the global variables. If no errors were
  270. // encountered, then it returns TRUE. Otherwise, it returns FALSE.
  271. //
  272. // 04-30-93 JulieB Created.
  273. ////////////////////////////////////////////////////////////////////////////
  274. BOOL InitGetDateFormat()
  275. {
  276. //
  277. // Make a Locale.
  278. //
  279. Locale = MAKELCID(0x0409, 0);
  280. //
  281. // Initialize the system date.
  282. //
  283. SysDate.wYear = 1993;
  284. SysDate.wMonth = 5;
  285. SysDate.wDayOfWeek = 6;
  286. SysDate.wDay = 1;
  287. SysDate.wHour = 15;
  288. SysDate.wMinute = 45;
  289. SysDate.wSecond = 25;
  290. SysDate.wMilliseconds = 13;
  291. //
  292. // Return success.
  293. //
  294. return (TRUE);
  295. }
  296. ////////////////////////////////////////////////////////////////////////////
  297. //
  298. // GDF_BadParamCheck
  299. //
  300. // This routine passes in bad parameters to the API routines and checks to
  301. // be sure they are handled properly. The number of errors encountered
  302. // is returned to the caller.
  303. //
  304. // 04-30-93 JulieB Created.
  305. ////////////////////////////////////////////////////////////////////////////
  306. int GDF_BadParamCheck()
  307. {
  308. int NumErrors = 0; // error count - to be returned
  309. int rc; // return code
  310. SYSTEMTIME MyDate; // structure to hold custom date
  311. //
  312. // Bad Locale.
  313. //
  314. // Variation 1 - Bad Locale
  315. rc = GetDateFormatW( (LCID)333,
  316. 0,
  317. NULL,
  318. NULL,
  319. lpDateStr,
  320. BUFSIZE );
  321. CheckReturnBadParam( rc,
  322. 0,
  323. ERROR_INVALID_PARAMETER,
  324. "Bad Locale",
  325. &NumErrors );
  326. //
  327. // Null Pointers.
  328. //
  329. // Variation 1 - lpDateStr = NULL
  330. rc = GetDateFormatW( Locale,
  331. 0,
  332. NULL,
  333. NULL,
  334. NULL,
  335. BUFSIZE );
  336. CheckReturnBadParam( rc,
  337. 0,
  338. ERROR_INVALID_PARAMETER,
  339. "lpDateStr NULL",
  340. &NumErrors );
  341. //
  342. // Bad Count.
  343. //
  344. // Variation 1 - cchDate < 0
  345. rc = GetDateFormatW( Locale,
  346. 0,
  347. NULL,
  348. NULL,
  349. lpDateStr,
  350. -1 );
  351. CheckReturnBadParam( rc,
  352. 0,
  353. ERROR_INVALID_PARAMETER,
  354. "cchDate < 0",
  355. &NumErrors );
  356. //
  357. // Invalid Flag.
  358. //
  359. // Variation 1 - flags invalid
  360. rc = GetDateFormatW( Locale,
  361. GDF_INVALID_FLAGS,
  362. NULL,
  363. NULL,
  364. lpDateStr,
  365. BUFSIZE );
  366. CheckReturnBadParam( rc,
  367. 0,
  368. ERROR_INVALID_FLAGS,
  369. "Flag invalid",
  370. &NumErrors );
  371. // Variation 2 - short date AND long date
  372. rc = GetDateFormatW( Locale,
  373. DATE_SHORTDATE | DATE_LONGDATE,
  374. NULL,
  375. NULL,
  376. lpDateStr,
  377. BUFSIZE );
  378. CheckReturnBadParam( rc,
  379. 0,
  380. ERROR_INVALID_FLAGS,
  381. "Flag invalid (shortdate and longdate)",
  382. &NumErrors );
  383. // Variation 3 - pFormat not null AND short date
  384. rc = GetDateFormatW( Locale,
  385. DATE_SHORTDATE,
  386. NULL,
  387. L"dddd",
  388. lpDateStr,
  389. BUFSIZE );
  390. CheckReturnBadParam( rc,
  391. 0,
  392. ERROR_INVALID_FLAGS,
  393. "pFormat not null and short date",
  394. &NumErrors );
  395. // Variation 4 - pFormat not null AND long date
  396. rc = GetDateFormatW( Locale,
  397. DATE_LONGDATE,
  398. NULL,
  399. L"dddd",
  400. lpDateStr,
  401. BUFSIZE );
  402. CheckReturnBadParam( rc,
  403. 0,
  404. ERROR_INVALID_FLAGS,
  405. "pFormat not null and long date",
  406. &NumErrors );
  407. // Variation 5 - pFormat not null AND no user override
  408. rc = GetDateFormatW( Locale,
  409. LOCALE_NOUSEROVERRIDE,
  410. NULL,
  411. L"dddd",
  412. lpDateStr,
  413. BUFSIZE );
  414. CheckReturnBadParam( rc,
  415. 0,
  416. ERROR_INVALID_FLAGS,
  417. "pFormat not null and no user override",
  418. &NumErrors );
  419. // Variation 6 - Use CP ACP, pFormat not null AND no user override
  420. rc = GetDateFormatW( Locale,
  421. LOCALE_USE_CP_ACP | LOCALE_NOUSEROVERRIDE,
  422. NULL,
  423. L"dddd",
  424. lpDateStr,
  425. BUFSIZE );
  426. CheckReturnBadParam( rc,
  427. 0,
  428. ERROR_INVALID_FLAGS,
  429. "Use CP ACP, pFormat not null and no user override",
  430. &NumErrors );
  431. //
  432. // Buffer Too Small.
  433. //
  434. // Variation 1 - cchDate = too small
  435. rc = GetDateFormatW( Locale,
  436. 0,
  437. NULL,
  438. NULL,
  439. lpDateStr,
  440. 2 );
  441. CheckReturnBadParam( rc,
  442. 0,
  443. ERROR_INSUFFICIENT_BUFFER,
  444. "cchDate too small",
  445. &NumErrors );
  446. //
  447. // Bad date passed in.
  448. //
  449. // Variation 1 - bad wMonth (0)
  450. MyDate.wYear = 1993;
  451. MyDate.wMonth = 0;
  452. MyDate.wDayOfWeek = 6;
  453. MyDate.wDay = 1;
  454. MyDate.wHour = 15;
  455. MyDate.wMinute = 45;
  456. MyDate.wSecond = 25;
  457. MyDate.wMilliseconds = 13;
  458. rc = GetDateFormatW( Locale,
  459. 0,
  460. &MyDate,
  461. NULL,
  462. lpDateStr,
  463. BUFSIZE );
  464. CheckReturnBadParam( rc,
  465. 0,
  466. ERROR_INVALID_PARAMETER,
  467. "bad wMonth (0)",
  468. &NumErrors );
  469. // Variation 2 - bad wMonth (13)
  470. MyDate.wYear = 1993;
  471. MyDate.wMonth = 13;
  472. MyDate.wDayOfWeek = 6;
  473. MyDate.wDay = 1;
  474. MyDate.wHour = 15;
  475. MyDate.wMinute = 45;
  476. MyDate.wSecond = 25;
  477. MyDate.wMilliseconds = 13;
  478. rc = GetDateFormatW( Locale,
  479. 0,
  480. &MyDate,
  481. NULL,
  482. lpDateStr,
  483. BUFSIZE );
  484. CheckReturnBadParam( rc,
  485. 0,
  486. ERROR_INVALID_PARAMETER,
  487. "bad wMonth (13)",
  488. &NumErrors );
  489. // Variation 3 - bad wDay
  490. MyDate.wYear = 1993;
  491. MyDate.wMonth = 5;
  492. MyDate.wDayOfWeek = 6;
  493. MyDate.wDay = 32;
  494. MyDate.wHour = 15;
  495. MyDate.wMinute = 45;
  496. MyDate.wSecond = 25;
  497. MyDate.wMilliseconds = 13;
  498. rc = GetDateFormatW( Locale,
  499. 0,
  500. &MyDate,
  501. NULL,
  502. lpDateStr,
  503. BUFSIZE );
  504. CheckReturnBadParam( rc,
  505. 0,
  506. ERROR_INVALID_PARAMETER,
  507. "bad wDay (May 32)",
  508. &NumErrors );
  509. // Variation 4 - bad wDay
  510. MyDate.wYear = 1993;
  511. MyDate.wMonth = 4;
  512. MyDate.wDayOfWeek = 6;
  513. MyDate.wDay = 31;
  514. MyDate.wHour = 15;
  515. MyDate.wMinute = 45;
  516. MyDate.wSecond = 25;
  517. MyDate.wMilliseconds = 13;
  518. rc = GetDateFormatW( Locale,
  519. 0,
  520. &MyDate,
  521. NULL,
  522. lpDateStr,
  523. BUFSIZE );
  524. CheckReturnBadParam( rc,
  525. 0,
  526. ERROR_INVALID_PARAMETER,
  527. "bad wDay (April 31)",
  528. &NumErrors );
  529. // Variation 5 - bad wDay
  530. MyDate.wYear = 1993;
  531. MyDate.wMonth = 6;
  532. MyDate.wDayOfWeek = 6;
  533. MyDate.wDay = 31;
  534. MyDate.wHour = 15;
  535. MyDate.wMinute = 45;
  536. MyDate.wSecond = 25;
  537. MyDate.wMilliseconds = 13;
  538. rc = GetDateFormatW( Locale,
  539. 0,
  540. &MyDate,
  541. NULL,
  542. lpDateStr,
  543. BUFSIZE );
  544. CheckReturnBadParam( rc,
  545. 0,
  546. ERROR_INVALID_PARAMETER,
  547. "bad wDay (June 31)",
  548. &NumErrors );
  549. // Variation 6 - bad wDay
  550. MyDate.wYear = 1993;
  551. MyDate.wMonth = 9;
  552. MyDate.wDayOfWeek = 6;
  553. MyDate.wDay = 31;
  554. MyDate.wHour = 15;
  555. MyDate.wMinute = 45;
  556. MyDate.wSecond = 25;
  557. MyDate.wMilliseconds = 13;
  558. rc = GetDateFormatW( Locale,
  559. 0,
  560. &MyDate,
  561. NULL,
  562. lpDateStr,
  563. BUFSIZE );
  564. CheckReturnBadParam( rc,
  565. 0,
  566. ERROR_INVALID_PARAMETER,
  567. "bad wDay (Sept 31)",
  568. &NumErrors );
  569. // Variation 7 - bad wDay
  570. MyDate.wYear = 1993;
  571. MyDate.wMonth = 11;
  572. MyDate.wDayOfWeek = 6;
  573. MyDate.wDay = 31;
  574. MyDate.wHour = 15;
  575. MyDate.wMinute = 45;
  576. MyDate.wSecond = 25;
  577. MyDate.wMilliseconds = 13;
  578. rc = GetDateFormatW( Locale,
  579. 0,
  580. &MyDate,
  581. NULL,
  582. lpDateStr,
  583. BUFSIZE );
  584. CheckReturnBadParam( rc,
  585. 0,
  586. ERROR_INVALID_PARAMETER,
  587. "bad wDay (Nov 31)",
  588. &NumErrors );
  589. // Variation 8 - bad wDay
  590. MyDate.wYear = 1993;
  591. MyDate.wMonth = 2;
  592. MyDate.wDayOfWeek = 6;
  593. MyDate.wDay = 29;
  594. MyDate.wHour = 15;
  595. MyDate.wMinute = 45;
  596. MyDate.wSecond = 25;
  597. MyDate.wMilliseconds = 13;
  598. rc = GetDateFormatW( Locale,
  599. 0,
  600. &MyDate,
  601. NULL,
  602. lpDateStr,
  603. BUFSIZE );
  604. CheckReturnBadParam( rc,
  605. 0,
  606. ERROR_INVALID_PARAMETER,
  607. "bad wDay (Feb 29, 1993)",
  608. &NumErrors );
  609. // Variation 9 - bad wDay
  610. MyDate.wYear = 1993;
  611. MyDate.wMonth = 2;
  612. MyDate.wDayOfWeek = 6;
  613. MyDate.wDay = 30;
  614. MyDate.wHour = 15;
  615. MyDate.wMinute = 45;
  616. MyDate.wSecond = 25;
  617. MyDate.wMilliseconds = 13;
  618. rc = GetDateFormatW( Locale,
  619. 0,
  620. &MyDate,
  621. NULL,
  622. lpDateStr,
  623. BUFSIZE );
  624. CheckReturnBadParam( rc,
  625. 0,
  626. ERROR_INVALID_PARAMETER,
  627. "bad wDay (Feb 30, 1993)",
  628. &NumErrors );
  629. // Variation 10 - bad wDay
  630. MyDate.wYear = 2100;
  631. MyDate.wMonth = 2;
  632. MyDate.wDayOfWeek = 6;
  633. MyDate.wDay = 29;
  634. MyDate.wHour = 15;
  635. MyDate.wMinute = 45;
  636. MyDate.wSecond = 25;
  637. MyDate.wMilliseconds = 13;
  638. rc = GetDateFormatW( Locale,
  639. 0,
  640. &MyDate,
  641. NULL,
  642. lpDateStr,
  643. BUFSIZE );
  644. CheckReturnBadParam( rc,
  645. 0,
  646. ERROR_INVALID_PARAMETER,
  647. "bad wDay (Feb 29, 2100)",
  648. &NumErrors );
  649. // Variation 11 - bad wDayOfWeek
  650. MyDate.wYear = 1993;
  651. MyDate.wMonth = 5;
  652. MyDate.wDayOfWeek = 7;
  653. MyDate.wDay = 1;
  654. MyDate.wHour = 15;
  655. MyDate.wMinute = 45;
  656. MyDate.wSecond = 25;
  657. MyDate.wMilliseconds = 13;
  658. rc = GetDateFormatW( Locale,
  659. 0,
  660. &MyDate,
  661. NULL,
  662. lpDateStr,
  663. BUFSIZE );
  664. CheckReturnValidW( rc,
  665. -1,
  666. lpDateStr,
  667. ENGLISH_US,
  668. "bad wDayOfWeek (7)",
  669. &NumErrors );
  670. // Variation 12 - bad wDayOfWeek
  671. MyDate.wYear = 1993;
  672. MyDate.wMonth = 5;
  673. MyDate.wDayOfWeek = 4;
  674. MyDate.wDay = 1;
  675. MyDate.wHour = 15;
  676. MyDate.wMinute = 45;
  677. MyDate.wSecond = 25;
  678. MyDate.wMilliseconds = 13;
  679. rc = GetDateFormatW( Locale,
  680. 0,
  681. &MyDate,
  682. NULL,
  683. lpDateStr,
  684. BUFSIZE );
  685. CheckReturnValidW( rc,
  686. -1,
  687. lpDateStr,
  688. ENGLISH_US,
  689. "bad wDayOfWeek (Thursday, May 1, 1993)",
  690. &NumErrors );
  691. //
  692. // DATE_LTRREADING and DATE_RTLREADING flags.
  693. //
  694. SetLastError(0);
  695. rc = GetDateFormatW( Locale,
  696. DATE_LTRREADING | DATE_RTLREADING,
  697. &MyDate,
  698. NULL,
  699. lpDateStr,
  700. BUFSIZE );
  701. CheckReturnBadParam( rc,
  702. 0,
  703. ERROR_INVALID_FLAGS,
  704. "LTR and RTL flags",
  705. &NumErrors );
  706. //
  707. // Return total number of errors found.
  708. //
  709. return (NumErrors);
  710. }
  711. ////////////////////////////////////////////////////////////////////////////
  712. //
  713. // GDF_NormalCase
  714. //
  715. // This routine tests the normal cases of the API routine.
  716. //
  717. // 04-30-93 JulieB Created.
  718. ////////////////////////////////////////////////////////////////////////////
  719. int GDF_NormalCase()
  720. {
  721. int NumErrors = 0; // error count - to be returned
  722. int rc; // return code
  723. SYSTEMTIME MyDate; // structure to hold custom date
  724. int ctr; // loop counter
  725. #ifdef PERF
  726. DbgBreakPoint();
  727. #endif
  728. //
  729. // Locales.
  730. //
  731. // Variation 1 - System Default Locale
  732. rc = GetDateFormatW( LOCALE_SYSTEM_DEFAULT,
  733. 0,
  734. NULL,
  735. NULL,
  736. lpDateStr,
  737. BUFSIZE );
  738. CheckReturnEqual( rc,
  739. 0,
  740. "system default locale",
  741. &NumErrors );
  742. // Variation 2 - Current User Locale
  743. rc = GetDateFormatW( LOCALE_USER_DEFAULT,
  744. 0,
  745. NULL,
  746. NULL,
  747. lpDateStr,
  748. BUFSIZE );
  749. CheckReturnEqual( rc,
  750. 0,
  751. "current user locale",
  752. &NumErrors );
  753. //
  754. // Language Neutral.
  755. //
  756. // Variation 1 - neutral
  757. rc = GetDateFormatW( 0x0000,
  758. 0,
  759. &SysDate,
  760. NULL,
  761. lpDateStr,
  762. BUFSIZE );
  763. CheckReturnValidW( rc,
  764. -1,
  765. lpDateStr,
  766. ENGLISH_US,
  767. "neutral locale",
  768. &NumErrors );
  769. // Variation 2 - sys default
  770. rc = GetDateFormatW( 0x0400,
  771. 0,
  772. &SysDate,
  773. NULL,
  774. lpDateStr,
  775. BUFSIZE );
  776. CheckReturnValidW( rc,
  777. -1,
  778. lpDateStr,
  779. ENGLISH_US,
  780. "sys default locale",
  781. &NumErrors );
  782. // Variation 3 - user default
  783. rc = GetDateFormatW( 0x0800,
  784. 0,
  785. &SysDate,
  786. NULL,
  787. lpDateStr,
  788. BUFSIZE );
  789. CheckReturnValidW( rc,
  790. -1,
  791. lpDateStr,
  792. ENGLISH_US,
  793. "user default locale",
  794. &NumErrors );
  795. // Variation 4 - sub lang neutral US
  796. rc = GetDateFormatW( 0x0009,
  797. 0,
  798. &SysDate,
  799. NULL,
  800. lpDateStr,
  801. BUFSIZE );
  802. CheckReturnValidW( rc,
  803. -1,
  804. lpDateStr,
  805. ENGLISH_US,
  806. "sub lang neutral US",
  807. &NumErrors );
  808. // Variation 5 - sub lang neutral Czech
  809. rc = GetDateFormatW( 0x0005,
  810. 0,
  811. &SysDate,
  812. NULL,
  813. lpDateStr,
  814. BUFSIZE );
  815. CheckReturnValidW( rc,
  816. -1,
  817. lpDateStr,
  818. CZECH,
  819. "sub lang neutral Czech",
  820. &NumErrors );
  821. //
  822. // Use CP ACP.
  823. //
  824. // Variation 1 - Use CP ACP, System Default Locale
  825. rc = GetDateFormatW( LOCALE_SYSTEM_DEFAULT,
  826. LOCALE_USE_CP_ACP,
  827. NULL,
  828. NULL,
  829. lpDateStr,
  830. BUFSIZE );
  831. CheckReturnEqual( rc,
  832. 0,
  833. "Use CP ACP, system default locale",
  834. &NumErrors );
  835. //
  836. // cchDate.
  837. //
  838. // Variation 1 - cchDate = size of lpDateStr buffer
  839. rc = GetDateFormatW( Locale,
  840. 0,
  841. &SysDate,
  842. NULL,
  843. lpDateStr,
  844. BUFSIZE );
  845. CheckReturnValidW( rc,
  846. -1,
  847. lpDateStr,
  848. ENGLISH_US,
  849. "cchDate = bufsize",
  850. &NumErrors );
  851. // Variation 2 - cchDate = 0
  852. lpDateStr[0] = 0x0000;
  853. rc = GetDateFormatW( Locale,
  854. 0,
  855. &SysDate,
  856. NULL,
  857. lpDateStr,
  858. 0 );
  859. CheckReturnValidW( rc,
  860. -1,
  861. NULL,
  862. ENGLISH_US,
  863. "cchDate zero",
  864. &NumErrors );
  865. // Variation 3 - cchDate = 0, lpDateStr = NULL
  866. rc = GetDateFormatW( Locale,
  867. 0,
  868. &SysDate,
  869. NULL,
  870. NULL,
  871. 0 );
  872. CheckReturnValidW( rc,
  873. -1,
  874. NULL,
  875. ENGLISH_US,
  876. "cchDate (NULL ptr)",
  877. &NumErrors );
  878. //
  879. // lpFormat.
  880. //
  881. // Variation 1 - Year
  882. rc = GetDateFormatW( Locale,
  883. 0,
  884. &SysDate,
  885. L"yyyy",
  886. lpDateStr,
  887. BUFSIZE );
  888. CheckReturnValidW( rc,
  889. -1,
  890. lpDateStr,
  891. YEAR,
  892. "lpFormat year (yyyy)",
  893. &NumErrors );
  894. // Variation 2 - Year
  895. rc = GetDateFormatW( Locale,
  896. 0,
  897. &SysDate,
  898. L"yyy",
  899. lpDateStr,
  900. BUFSIZE );
  901. CheckReturnValidW( rc,
  902. -1,
  903. lpDateStr,
  904. YEAR,
  905. "lpFormat year (yyy)",
  906. &NumErrors );
  907. // Variation 3 - Year
  908. rc = GetDateFormatW( Locale,
  909. 0,
  910. &SysDate,
  911. L"yyyyy",
  912. lpDateStr,
  913. BUFSIZE );
  914. CheckReturnValidW( rc,
  915. -1,
  916. lpDateStr,
  917. YEAR,
  918. "lpFormat year (yyyyy)",
  919. &NumErrors );
  920. // Variation 4 - Year
  921. rc = GetDateFormatW( Locale,
  922. 0,
  923. &SysDate,
  924. L"yy",
  925. lpDateStr,
  926. BUFSIZE );
  927. CheckReturnValidW( rc,
  928. -1,
  929. lpDateStr,
  930. YEAR_2,
  931. "lpFormat year (yy)",
  932. &NumErrors );
  933. // Variation 5 - Year
  934. rc = GetDateFormatW( Locale,
  935. 0,
  936. &SysDate,
  937. L"y",
  938. lpDateStr,
  939. BUFSIZE );
  940. CheckReturnValidW( rc,
  941. -1,
  942. lpDateStr,
  943. YEAR_2,
  944. "lpFormat year (y)",
  945. &NumErrors );
  946. // Variation 6 - US day of week
  947. rc = GetDateFormatW( Locale,
  948. 0,
  949. &SysDate,
  950. L"dddd",
  951. lpDateStr,
  952. BUFSIZE );
  953. CheckReturnValidW( rc,
  954. -1,
  955. lpDateStr,
  956. US_DAYOFWEEK,
  957. "US day of week",
  958. &NumErrors );
  959. // Variation 7 - US day of week
  960. rc = GetDateFormatW( Locale,
  961. 0,
  962. &SysDate,
  963. L"ddddd",
  964. lpDateStr,
  965. BUFSIZE );
  966. CheckReturnValidW( rc,
  967. -1,
  968. lpDateStr,
  969. US_DAYOFWEEK,
  970. "US day of week (ddddd)",
  971. &NumErrors );
  972. // Variation 8 - US abbrev day of week
  973. rc = GetDateFormatW( Locale,
  974. 0,
  975. &SysDate,
  976. L"ddd",
  977. lpDateStr,
  978. BUFSIZE );
  979. CheckReturnValidW( rc,
  980. -1,
  981. lpDateStr,
  982. US_ABBREVDAY,
  983. "US abbrev day of week",
  984. &NumErrors );
  985. // Variation 9 - US Month
  986. rc = GetDateFormatW( Locale,
  987. 0,
  988. &SysDate,
  989. L"MMMM",
  990. lpDateStr,
  991. BUFSIZE );
  992. CheckReturnValidW( rc,
  993. -1,
  994. lpDateStr,
  995. US_MONTH,
  996. "US Month",
  997. &NumErrors );
  998. // Variation 10 - US Month
  999. rc = GetDateFormatW( Locale,
  1000. 0,
  1001. &SysDate,
  1002. L"MMMMM",
  1003. lpDateStr,
  1004. BUFSIZE );
  1005. CheckReturnValidW( rc,
  1006. -1,
  1007. lpDateStr,
  1008. US_MONTH,
  1009. "US Month (MMMMM)",
  1010. &NumErrors );
  1011. // Variation 11 - US Abbrev Month
  1012. rc = GetDateFormatW( Locale,
  1013. 0,
  1014. &SysDate,
  1015. L"MMM",
  1016. lpDateStr,
  1017. BUFSIZE );
  1018. CheckReturnValidW( rc,
  1019. -1,
  1020. lpDateStr,
  1021. US_ABBREVMONTH,
  1022. "US Abbrev Month",
  1023. &NumErrors );
  1024. // Variation 12 - SPANISH day of week
  1025. rc = GetDateFormatW( 0x040a,
  1026. 0,
  1027. &SysDate,
  1028. L"dddd",
  1029. lpDateStr,
  1030. BUFSIZE );
  1031. CheckReturnValidW( rc,
  1032. -1,
  1033. lpDateStr,
  1034. SPANISH_DAYOFWEEK,
  1035. "SPANISH day of week",
  1036. &NumErrors );
  1037. // Variation 13 - SPANISH day of week
  1038. rc = GetDateFormatW( 0x040a,
  1039. 0,
  1040. &SysDate,
  1041. L"ddddd",
  1042. lpDateStr,
  1043. BUFSIZE );
  1044. CheckReturnValidW( rc,
  1045. -1,
  1046. lpDateStr,
  1047. SPANISH_DAYOFWEEK,
  1048. "SPANISH day of week (ddddd)",
  1049. &NumErrors );
  1050. // Variation 14 - SPANISH abbrev day of week
  1051. rc = GetDateFormatW( 0x040a,
  1052. 0,
  1053. &SysDate,
  1054. L"ddd",
  1055. lpDateStr,
  1056. BUFSIZE );
  1057. CheckReturnValidW( rc,
  1058. -1,
  1059. lpDateStr,
  1060. SPANISH_ABBREVDAY,
  1061. "SPANISH abbrev day of week",
  1062. &NumErrors );
  1063. // Variation 15 - SPANISH Month
  1064. rc = GetDateFormatW( 0x040a,
  1065. 0,
  1066. &SysDate,
  1067. L"MMMM",
  1068. lpDateStr,
  1069. BUFSIZE );
  1070. CheckReturnValidW( rc,
  1071. -1,
  1072. lpDateStr,
  1073. SPANISH_MONTH,
  1074. "SPANISH Month",
  1075. &NumErrors );
  1076. // Variation 16 - SPANISH Month
  1077. rc = GetDateFormatW( 0x040a,
  1078. 0,
  1079. &SysDate,
  1080. L"MMMMM",
  1081. lpDateStr,
  1082. BUFSIZE );
  1083. CheckReturnValidW( rc,
  1084. -1,
  1085. lpDateStr,
  1086. SPANISH_MONTH,
  1087. "SPANISH Month (MMMMM)",
  1088. &NumErrors );
  1089. // Variation 17 - SPANISH Abbrev Month
  1090. rc = GetDateFormatW( 0x040a,
  1091. 0,
  1092. &SysDate,
  1093. L"MMM",
  1094. lpDateStr,
  1095. BUFSIZE );
  1096. CheckReturnValidW( rc,
  1097. -1,
  1098. lpDateStr,
  1099. SPANISH_ABBREVMONTH,
  1100. "SPANISH Abbrev Month",
  1101. &NumErrors );
  1102. //
  1103. // Single quote usage.
  1104. //
  1105. // Variation 1 - US single quote
  1106. rc = GetDateFormatW( Locale,
  1107. 0,
  1108. &SysDate,
  1109. L"dddd, MMMM dd, '''yy",
  1110. lpDateStr,
  1111. BUFSIZE );
  1112. CheckReturnValidW( rc,
  1113. -1,
  1114. lpDateStr,
  1115. L"Saturday, May 01, 'yy",
  1116. "US single quote",
  1117. &NumErrors );
  1118. // Variation 2 - US single quote 2
  1119. rc = GetDateFormatW( Locale,
  1120. 0,
  1121. &SysDate,
  1122. L"dddd, MMMM dd, ''''yy",
  1123. lpDateStr,
  1124. BUFSIZE );
  1125. CheckReturnValidW( rc,
  1126. -1,
  1127. lpDateStr,
  1128. L"Saturday, May 01, '93",
  1129. "US single quote 2",
  1130. &NumErrors );
  1131. // Variation 3 - US single quote 3
  1132. rc = GetDateFormatW( Locale,
  1133. 0,
  1134. &SysDate,
  1135. L" 'year: '''yy",
  1136. lpDateStr,
  1137. BUFSIZE );
  1138. CheckReturnValidW( rc,
  1139. -1,
  1140. lpDateStr,
  1141. L" year: '93",
  1142. "US single quote 3",
  1143. &NumErrors );
  1144. // Variation 4 - SHORTDATE single quote
  1145. rc = GetLocaleInfoW( 0x0409,
  1146. LOCALE_SSHORTDATE,
  1147. pSShortDate,
  1148. BUFSIZE );
  1149. CheckReturnEqual( rc,
  1150. 0,
  1151. "GetLocaleInfoW SSHORTDATE",
  1152. &NumErrors );
  1153. rc = SetLocaleInfoW( 0x0409,
  1154. LOCALE_SSHORTDATE,
  1155. L"MM''''dd''''yy" );
  1156. CheckReturnValidW( rc,
  1157. TRUE,
  1158. NULL,
  1159. NULL,
  1160. "SetLocaleInfoW SSHORTDATE",
  1161. &NumErrors );
  1162. rc = GetDateFormatW( 0x0409,
  1163. DATE_SHORTDATE,
  1164. &SysDate,
  1165. NULL,
  1166. lpDateStr,
  1167. BUFSIZE );
  1168. CheckReturnValidW( rc,
  1169. -1,
  1170. lpDateStr,
  1171. L"05'01'93",
  1172. "ShortDate single quote 1",
  1173. &NumErrors );
  1174. rc = SetLocaleInfoW( 0x0409,
  1175. LOCALE_SSHORTDATE,
  1176. L"'Date: 'MMM ''''yy" );
  1177. CheckReturnValidW( rc,
  1178. TRUE,
  1179. NULL,
  1180. NULL,
  1181. "SetLocaleInfoW SSHORTDATE",
  1182. &NumErrors );
  1183. rc = GetDateFormatW( 0x0409,
  1184. DATE_SHORTDATE,
  1185. &SysDate,
  1186. NULL,
  1187. lpDateStr,
  1188. BUFSIZE );
  1189. CheckReturnValidW( rc,
  1190. -1,
  1191. lpDateStr,
  1192. L"Date: May '93",
  1193. "ShortDate single quote 2",
  1194. &NumErrors );
  1195. rc = SetLocaleInfoW( 0x0409,
  1196. LOCALE_SSHORTDATE,
  1197. pSShortDate );
  1198. CheckReturnValidW( rc,
  1199. TRUE,
  1200. NULL,
  1201. NULL,
  1202. "SetLocaleInfoW SSHORTDATE Final",
  1203. &NumErrors );
  1204. //
  1205. // Test all locales - Short Date flag value.
  1206. //
  1207. for (ctr = 0; ctr < NumLocales; ctr++)
  1208. {
  1209. rc = GetDateFormatW( pAllLocales[ctr],
  1210. DATE_SHORTDATE,
  1211. &SysDate,
  1212. NULL,
  1213. lpDateStr,
  1214. BUFSIZE );
  1215. CheckReturnValidLoopW( rc,
  1216. -1,
  1217. lpDateStr,
  1218. pShortDate[ctr],
  1219. "ShortDate",
  1220. pAllLocales[ctr],
  1221. &NumErrors );
  1222. }
  1223. //
  1224. // Test all locales - Long Date flag value.
  1225. //
  1226. for (ctr = 0; ctr < NumLocales; ctr++)
  1227. {
  1228. rc = GetDateFormatW( pAllLocales[ctr],
  1229. DATE_LONGDATE,
  1230. &SysDate,
  1231. NULL,
  1232. lpDateStr,
  1233. BUFSIZE );
  1234. CheckReturnValidLoopW( rc,
  1235. -1,
  1236. lpDateStr,
  1237. pLongDate[ctr],
  1238. "LongDate",
  1239. pAllLocales[ctr],
  1240. &NumErrors );
  1241. }
  1242. //
  1243. // Test all locales - Year Month flag value.
  1244. //
  1245. for (ctr = 0; ctr < NumLocales; ctr++)
  1246. {
  1247. rc = GetDateFormatW( pAllLocales[ctr],
  1248. DATE_YEARMONTH,
  1249. &SysDate,
  1250. NULL,
  1251. lpDateStr,
  1252. BUFSIZE );
  1253. CheckReturnValidLoopW( rc,
  1254. -1,
  1255. lpDateStr,
  1256. pYearMonth[ctr],
  1257. "YearMonth",
  1258. pAllLocales[ctr],
  1259. &NumErrors );
  1260. }
  1261. //
  1262. // NO User Override flag value.
  1263. //
  1264. // Variation 1 - NOUSEROVERRIDE
  1265. rc = GetDateFormatW( Locale,
  1266. LOCALE_NOUSEROVERRIDE,
  1267. &SysDate,
  1268. NULL,
  1269. lpDateStr,
  1270. BUFSIZE );
  1271. CheckReturnValidW( rc,
  1272. -1,
  1273. lpDateStr,
  1274. ENGLISH_US,
  1275. "NoUserOverride",
  1276. &NumErrors );
  1277. //
  1278. // Test Russian date formats.
  1279. //
  1280. // Variation 1 - LONGDATE Russian
  1281. rc = GetDateFormatW( 0x0419,
  1282. 0,
  1283. &SysDate,
  1284. L"MMMM",
  1285. lpDateStr,
  1286. BUFSIZE );
  1287. CheckReturnValidW( rc,
  1288. -1,
  1289. lpDateStr,
  1290. L_RUSSIAN_2,
  1291. "LongDate Russian 2",
  1292. &NumErrors );
  1293. // Variation 2 - LONGDATE Russian
  1294. rc = GetDateFormatW( 0x0419,
  1295. 0,
  1296. &SysDate,
  1297. L"MMMM d",
  1298. lpDateStr,
  1299. BUFSIZE );
  1300. CheckReturnValidW( rc,
  1301. -1,
  1302. lpDateStr,
  1303. L_RUSSIAN_3,
  1304. "LongDate Russian 3",
  1305. &NumErrors );
  1306. // Variation 3 - LONGDATE Russian
  1307. rc = GetDateFormatW( 0x0419,
  1308. 0,
  1309. &SysDate,
  1310. L"d yy MMMM",
  1311. lpDateStr,
  1312. BUFSIZE );
  1313. CheckReturnValidW( rc,
  1314. -1,
  1315. lpDateStr,
  1316. L_RUSSIAN_4,
  1317. "LongDate Russian 4",
  1318. &NumErrors );
  1319. //
  1320. // Test Polish date formats.
  1321. //
  1322. // Variation 1 - LONGDATE Polish
  1323. rc = GetDateFormatW( 0x0415,
  1324. 0,
  1325. &SysDate,
  1326. L"MMMM",
  1327. lpDateStr,
  1328. BUFSIZE );
  1329. CheckReturnValidW( rc,
  1330. -1,
  1331. lpDateStr,
  1332. L_POLISH_2,
  1333. "LongDate Polish 2",
  1334. &NumErrors );
  1335. // Variation 2 - LONGDATE Polish
  1336. rc = GetDateFormatW( 0x0415,
  1337. 0,
  1338. &SysDate,
  1339. L"MMMM d",
  1340. lpDateStr,
  1341. BUFSIZE );
  1342. CheckReturnValidW( rc,
  1343. -1,
  1344. lpDateStr,
  1345. L_POLISH_3,
  1346. "LongDate Polish 3",
  1347. &NumErrors );
  1348. // Variation 3 - LONGDATE Polish
  1349. rc = GetDateFormatW( 0x0415,
  1350. 0,
  1351. &SysDate,
  1352. L"d yy MMMM",
  1353. lpDateStr,
  1354. BUFSIZE );
  1355. CheckReturnValidW( rc,
  1356. -1,
  1357. lpDateStr,
  1358. L_POLISH_4,
  1359. "LongDate Polish 4",
  1360. &NumErrors );
  1361. //
  1362. // Test various calendars.
  1363. //
  1364. // Variation 1 - English
  1365. rc = GetDateFormatW( 0x0409,
  1366. DATE_USE_ALT_CALENDAR,
  1367. &SysDate,
  1368. NULL,
  1369. lpDateStr,
  1370. BUFSIZE );
  1371. CheckReturnValidW( rc,
  1372. -1,
  1373. lpDateStr,
  1374. ENGLISH_US,
  1375. "Alt Calendar English (ShortDate)",
  1376. &NumErrors );
  1377. // Variation 2 - English
  1378. rc = GetDateFormatW( 0x0409,
  1379. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1380. &SysDate,
  1381. NULL,
  1382. lpDateStr,
  1383. BUFSIZE );
  1384. CheckReturnValidW( rc,
  1385. -1,
  1386. lpDateStr,
  1387. L_ENGLISH_US,
  1388. "Alt Calendar English (LongDate)",
  1389. &NumErrors );
  1390. // Variation 3 - Japan
  1391. rc = GetDateFormatW( 0x0411,
  1392. DATE_USE_ALT_CALENDAR,
  1393. &SysDate,
  1394. NULL,
  1395. lpDateStr,
  1396. BUFSIZE );
  1397. CheckReturnValidW( rc,
  1398. -1,
  1399. lpDateStr,
  1400. JAPAN_ALT,
  1401. "Alt Calendar Japan (ShortDate)",
  1402. &NumErrors );
  1403. // Variation 4 - Japan
  1404. rc = GetDateFormatW( 0x0411,
  1405. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1406. &SysDate,
  1407. NULL,
  1408. lpDateStr,
  1409. BUFSIZE );
  1410. CheckReturnValidW( rc,
  1411. -1,
  1412. lpDateStr,
  1413. L_JAPAN_ALT,
  1414. "Alt Calendar Japan (LongDate)",
  1415. &NumErrors );
  1416. #if 0
  1417. // Variation 5 - China
  1418. rc = GetDateFormatW( 0x0404,
  1419. DATE_USE_ALT_CALENDAR,
  1420. &SysDate,
  1421. NULL,
  1422. lpDateStr,
  1423. BUFSIZE );
  1424. CheckReturnValidW( rc,
  1425. -1,
  1426. lpDateStr,
  1427. CHINA_ALT,
  1428. "Alt Calendar China (ShortDate)",
  1429. &NumErrors );
  1430. // Variation 6 - China
  1431. rc = GetDateFormatW( 0x0404,
  1432. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1433. &SysDate,
  1434. NULL,
  1435. lpDateStr,
  1436. BUFSIZE );
  1437. CheckReturnValidW( rc,
  1438. -1,
  1439. lpDateStr,
  1440. L_CHINA_ALT,
  1441. "Alt Calendar China (LongDate)",
  1442. &NumErrors );
  1443. #endif
  1444. // Variation 7 - Korea
  1445. rc = GetDateFormatW( 0x0412,
  1446. DATE_USE_ALT_CALENDAR,
  1447. &SysDate,
  1448. NULL,
  1449. lpDateStr,
  1450. BUFSIZE );
  1451. CheckReturnValidW( rc,
  1452. -1,
  1453. lpDateStr,
  1454. KOREA_ALT,
  1455. "Alt Calendar Korea (ShortDate)",
  1456. &NumErrors );
  1457. // Variation 8 - Korea
  1458. rc = GetDateFormatW( 0x0412,
  1459. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1460. &SysDate,
  1461. NULL,
  1462. lpDateStr,
  1463. BUFSIZE );
  1464. CheckReturnValidW( rc,
  1465. -1,
  1466. lpDateStr,
  1467. L_KOREA_ALT,
  1468. "Alt Calendar Korea (LongDate)",
  1469. &NumErrors );
  1470. //
  1471. // Different dates for calendars.
  1472. //
  1473. // Variation 1 - Japan
  1474. MyDate.wYear = 1913;
  1475. MyDate.wMonth = 5;
  1476. MyDate.wDayOfWeek = 6;
  1477. MyDate.wDay = 1;
  1478. MyDate.wHour = 15;
  1479. MyDate.wMinute = 45;
  1480. MyDate.wSecond = 25;
  1481. MyDate.wMilliseconds = 13;
  1482. rc = GetDateFormatW( 0x0411,
  1483. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1484. &MyDate,
  1485. NULL,
  1486. lpDateStr,
  1487. BUFSIZE );
  1488. CheckReturnValidW( rc,
  1489. -1,
  1490. lpDateStr,
  1491. L_JAPAN_ALT_2,
  1492. "Alt Calendar Japan (long) 2",
  1493. &NumErrors );
  1494. #if 0
  1495. // Variation 2 - China
  1496. MyDate.wYear = 1832;
  1497. MyDate.wMonth = 5;
  1498. MyDate.wDayOfWeek = 6;
  1499. MyDate.wDay = 1;
  1500. MyDate.wHour = 15;
  1501. MyDate.wMinute = 45;
  1502. MyDate.wSecond = 25;
  1503. MyDate.wMilliseconds = 13;
  1504. rc = GetDateFormatW( 0x0404,
  1505. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1506. &MyDate,
  1507. NULL,
  1508. lpDateStr,
  1509. BUFSIZE );
  1510. CheckReturnValidW( rc,
  1511. -1,
  1512. lpDateStr,
  1513. L_CHINA_ALT_2,
  1514. "Alt Calendar China (long) 2",
  1515. &NumErrors );
  1516. #endif
  1517. // Variation 3 - Korea
  1518. MyDate.wYear = 1832;
  1519. MyDate.wMonth = 5;
  1520. MyDate.wDayOfWeek = 6;
  1521. MyDate.wDay = 1;
  1522. MyDate.wHour = 15;
  1523. MyDate.wMinute = 45;
  1524. MyDate.wSecond = 25;
  1525. MyDate.wMilliseconds = 13;
  1526. rc = GetDateFormatW( 0x0412,
  1527. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1528. &MyDate,
  1529. NULL,
  1530. lpDateStr,
  1531. BUFSIZE );
  1532. CheckReturnValidW( rc,
  1533. -1,
  1534. lpDateStr,
  1535. L_KOREA_ALT_2,
  1536. "Alt Calendar Korea (long) 2",
  1537. &NumErrors );
  1538. // Variation 4 - Japan
  1539. MyDate.wYear = 1832;
  1540. MyDate.wMonth = 5;
  1541. MyDate.wDayOfWeek = 6;
  1542. MyDate.wDay = 1;
  1543. MyDate.wHour = 15;
  1544. MyDate.wMinute = 45;
  1545. MyDate.wSecond = 25;
  1546. MyDate.wMilliseconds = 13;
  1547. rc = GetDateFormatW( 0x0411,
  1548. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1549. &MyDate,
  1550. NULL,
  1551. lpDateStr,
  1552. BUFSIZE );
  1553. CheckReturnValidW( rc,
  1554. -1,
  1555. lpDateStr,
  1556. L_JAPAN_ALT_3,
  1557. "Alt Calendar Japan (long) 3",
  1558. &NumErrors );
  1559. // Variation 5 - Japan
  1560. MyDate.wYear = 1989;
  1561. MyDate.wMonth = 1;
  1562. MyDate.wDayOfWeek = 1;
  1563. MyDate.wDay = 8;
  1564. MyDate.wHour = 15;
  1565. MyDate.wMinute = 45;
  1566. MyDate.wSecond = 25;
  1567. MyDate.wMilliseconds = 13;
  1568. rc = GetDateFormatW( 0x0411,
  1569. DATE_USE_ALT_CALENDAR,
  1570. &MyDate,
  1571. NULL,
  1572. lpDateStr,
  1573. BUFSIZE );
  1574. CheckReturnValidW( rc,
  1575. -1,
  1576. lpDateStr,
  1577. L"\x5e73\x6210 1/1/8",
  1578. "Alt Calendar Japan (short) 1",
  1579. &NumErrors );
  1580. // Variation 6 - Japan
  1581. MyDate.wYear = 1989;
  1582. MyDate.wMonth = 1;
  1583. MyDate.wDayOfWeek = 1;
  1584. MyDate.wDay = 7;
  1585. MyDate.wHour = 15;
  1586. MyDate.wMinute = 45;
  1587. MyDate.wSecond = 25;
  1588. MyDate.wMilliseconds = 13;
  1589. rc = GetDateFormatW( 0x0411,
  1590. DATE_USE_ALT_CALENDAR,
  1591. &MyDate,
  1592. NULL,
  1593. lpDateStr,
  1594. BUFSIZE );
  1595. CheckReturnValidW( rc,
  1596. -1,
  1597. lpDateStr,
  1598. L"\x662d\x548c 64/1/7",
  1599. "Alt Calendar Japan (short) 2",
  1600. &NumErrors );
  1601. // Variation 7 - Japan
  1602. MyDate.wYear = 1989;
  1603. MyDate.wMonth = 2;
  1604. MyDate.wDayOfWeek = 1;
  1605. MyDate.wDay = 3;
  1606. MyDate.wHour = 15;
  1607. MyDate.wMinute = 45;
  1608. MyDate.wSecond = 25;
  1609. MyDate.wMilliseconds = 13;
  1610. rc = GetDateFormatW( 0x0411,
  1611. DATE_USE_ALT_CALENDAR,
  1612. &MyDate,
  1613. NULL,
  1614. lpDateStr,
  1615. BUFSIZE );
  1616. CheckReturnValidW( rc,
  1617. -1,
  1618. lpDateStr,
  1619. L"\x5e73\x6210 1/2/3",
  1620. "Alt Calendar Japan (short) 3",
  1621. &NumErrors );
  1622. // Variation 8 - Japan
  1623. MyDate.wYear = 1926;
  1624. MyDate.wMonth = 2;
  1625. MyDate.wDayOfWeek = 1;
  1626. MyDate.wDay = 3;
  1627. MyDate.wHour = 15;
  1628. MyDate.wMinute = 45;
  1629. MyDate.wSecond = 25;
  1630. MyDate.wMilliseconds = 13;
  1631. rc = GetDateFormatW( 0x0411,
  1632. DATE_USE_ALT_CALENDAR,
  1633. &MyDate,
  1634. NULL,
  1635. lpDateStr,
  1636. BUFSIZE );
  1637. CheckReturnValidW( rc,
  1638. -1,
  1639. lpDateStr,
  1640. L"\x5927\x6b63 15/2/3",
  1641. "Alt Calendar Japan (short) 4",
  1642. &NumErrors );
  1643. // Variation 9 - Japan
  1644. MyDate.wYear = 1989;
  1645. MyDate.wMonth = 1;
  1646. MyDate.wDayOfWeek = 1;
  1647. MyDate.wDay = 8;
  1648. MyDate.wHour = 15;
  1649. MyDate.wMinute = 45;
  1650. MyDate.wSecond = 25;
  1651. MyDate.wMilliseconds = 13;
  1652. rc = GetDateFormatW( 0x0411,
  1653. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1654. &MyDate,
  1655. NULL,
  1656. lpDateStr,
  1657. BUFSIZE );
  1658. CheckReturnValidW( rc,
  1659. -1,
  1660. lpDateStr,
  1661. L"\x5e73\x6210 1\x5e74\x0031\x6708\x0038\x65e5",
  1662. "Alt Calendar Japan (long) 4",
  1663. &NumErrors );
  1664. // Variation 10 - Japan
  1665. MyDate.wYear = 1989;
  1666. MyDate.wMonth = 1;
  1667. MyDate.wDayOfWeek = 1;
  1668. MyDate.wDay = 7;
  1669. MyDate.wHour = 15;
  1670. MyDate.wMinute = 45;
  1671. MyDate.wSecond = 25;
  1672. MyDate.wMilliseconds = 13;
  1673. rc = GetDateFormatW( 0x0411,
  1674. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1675. &MyDate,
  1676. NULL,
  1677. lpDateStr,
  1678. BUFSIZE );
  1679. CheckReturnValidW( rc,
  1680. -1,
  1681. lpDateStr,
  1682. L"\x662d\x548c 64\x5e74\x0031\x6708\x0037\x65e5",
  1683. "Alt Calendar Japan (long) 5",
  1684. &NumErrors );
  1685. //
  1686. // DATE_LTRREADING and DATE_RTLREADING flags.
  1687. //
  1688. rc = GetDateFormatW( Locale,
  1689. DATE_LTRREADING,
  1690. &SysDate,
  1691. NULL,
  1692. lpDateStr,
  1693. BUFSIZE );
  1694. CheckReturnValidW( rc,
  1695. -1,
  1696. lpDateStr,
  1697. L"\x200e\x0035/\x200e\x0031/\x200e\x0031\x0039\x0039\x0033",
  1698. "LTR flag (shortdate) - US",
  1699. &NumErrors );
  1700. rc = GetDateFormatW( Locale,
  1701. DATE_RTLREADING,
  1702. &SysDate,
  1703. NULL,
  1704. lpDateStr,
  1705. BUFSIZE );
  1706. CheckReturnValidW( rc,
  1707. -1,
  1708. lpDateStr,
  1709. L"\x200f\x0035/\x200f\x0031/\x200f\x0031\x0039\x0039\x0033",
  1710. "RTL flag (shortdate) - US",
  1711. &NumErrors );
  1712. rc = GetDateFormatW( Locale,
  1713. DATE_SHORTDATE | DATE_LTRREADING,
  1714. &SysDate,
  1715. NULL,
  1716. lpDateStr,
  1717. BUFSIZE );
  1718. CheckReturnValidW( rc,
  1719. -1,
  1720. lpDateStr,
  1721. L"\x200e\x0035/\x200e\x0031/\x200e\x0031\x0039\x0039\x0033",
  1722. "LTR flag (shortdate) - US 2",
  1723. &NumErrors );
  1724. rc = GetDateFormatW( Locale,
  1725. DATE_SHORTDATE | DATE_RTLREADING,
  1726. &SysDate,
  1727. NULL,
  1728. lpDateStr,
  1729. BUFSIZE );
  1730. CheckReturnValidW( rc,
  1731. -1,
  1732. lpDateStr,
  1733. L"\x200f\x0035/\x200f\x0031/\x200f\x0031\x0039\x0039\x0033",
  1734. "RTL flag (shortdate) - US 2",
  1735. &NumErrors );
  1736. rc = GetDateFormatW( Locale,
  1737. DATE_LONGDATE | DATE_LTRREADING,
  1738. &SysDate,
  1739. NULL,
  1740. lpDateStr,
  1741. BUFSIZE );
  1742. CheckReturnValidW( rc,
  1743. -1,
  1744. lpDateStr,
  1745. L"\x200eSaturday, \x200eMay \x200e\x0030\x0031, \x200e\x0031\x0039\x0039\x0033",
  1746. "LTR flag (longdate) - US",
  1747. &NumErrors );
  1748. rc = GetDateFormatW( Locale,
  1749. DATE_LONGDATE | DATE_RTLREADING,
  1750. &SysDate,
  1751. NULL,
  1752. lpDateStr,
  1753. BUFSIZE );
  1754. CheckReturnValidW( rc,
  1755. -1,
  1756. lpDateStr,
  1757. L"\x200fSaturday, \x200fMay \x200f\x0030\x0031, \x200f\x0031\x0039\x0039\x0033",
  1758. "RTL flag (longdate) - US",
  1759. &NumErrors );
  1760. // Iran - Farsi
  1761. if (IsValidLocale(0x0429, LCID_INSTALLED))
  1762. {
  1763. rc = GetDateFormatW( 0x0429,
  1764. DATE_LTRREADING,
  1765. &SysDate,
  1766. NULL,
  1767. lpDateStr,
  1768. BUFSIZE );
  1769. CheckReturnValidW( rc,
  1770. -1,
  1771. lpDateStr,
  1772. L"\x200e\x0035/\x200e\x0031/\x200e\x0031\x0039\x0039\x0033",
  1773. "LTR - Iran Farsi",
  1774. &NumErrors );
  1775. rc = GetDateFormatW( 0x0429,
  1776. DATE_RTLREADING,
  1777. &SysDate,
  1778. NULL,
  1779. lpDateStr,
  1780. BUFSIZE );
  1781. CheckReturnValidW( rc,
  1782. -1,
  1783. lpDateStr,
  1784. L"\x200f\x0035/\x200f\x0031/\x200f\x0031\x0039\x0039\x0033",
  1785. "RTL - Iran Farsi",
  1786. &NumErrors );
  1787. }
  1788. //
  1789. // Hijri Calendar.
  1790. //
  1791. if (IsValidLocale(0x0401, LCID_INSTALLED))
  1792. {
  1793. // Variation 1 - Hijri
  1794. MyDate.wYear = 1945;
  1795. MyDate.wMonth = 11;
  1796. MyDate.wDayOfWeek = 1;
  1797. MyDate.wDay = 12;
  1798. MyDate.wHour = 15;
  1799. MyDate.wMinute = 45;
  1800. MyDate.wSecond = 25;
  1801. MyDate.wMilliseconds = 13;
  1802. rc = GetDateFormatW( 0x0401,
  1803. DATE_SHORTDATE,
  1804. &MyDate,
  1805. NULL,
  1806. lpDateStr,
  1807. BUFSIZE );
  1808. CheckReturnValidW( rc,
  1809. -1,
  1810. lpDateStr,
  1811. L"07/12/64",
  1812. "Hijri (short) 1",
  1813. &NumErrors );
  1814. // Variation 2 - Hijri
  1815. MyDate.wYear = 1945;
  1816. MyDate.wMonth = 11;
  1817. MyDate.wDayOfWeek = 1;
  1818. MyDate.wDay = 12;
  1819. MyDate.wHour = 15;
  1820. MyDate.wMinute = 45;
  1821. MyDate.wSecond = 25;
  1822. MyDate.wMilliseconds = 13;
  1823. rc = GetDateFormatW( 0x0401,
  1824. DATE_LONGDATE,
  1825. &MyDate,
  1826. NULL,
  1827. lpDateStr,
  1828. BUFSIZE );
  1829. CheckReturnValidW( rc,
  1830. -1,
  1831. lpDateStr,
  1832. L"07/\x0630\x0648\x00a0\x0627\x0644\x062d\x062c\x0629/1364", // year 1364
  1833. "Hijri (long) 1",
  1834. &NumErrors );
  1835. // Variation 3 - Hijri
  1836. MyDate.wYear = 1945;
  1837. MyDate.wMonth = 11;
  1838. MyDate.wDayOfWeek = 1;
  1839. MyDate.wDay = 12;
  1840. MyDate.wHour = 15;
  1841. MyDate.wMinute = 45;
  1842. MyDate.wSecond = 25;
  1843. MyDate.wMilliseconds = 13;
  1844. rc = GetDateFormatW( 0x0401,
  1845. DATE_USE_ALT_CALENDAR | DATE_SHORTDATE,
  1846. &MyDate,
  1847. NULL,
  1848. lpDateStr,
  1849. BUFSIZE );
  1850. CheckReturnValidW( rc,
  1851. -1,
  1852. lpDateStr,
  1853. L"07/12/64", // year 1364
  1854. "Alt Calendar Hijri (short) 1",
  1855. &NumErrors );
  1856. // Variation 4 - Hijri
  1857. MyDate.wYear = 1945;
  1858. MyDate.wMonth = 11;
  1859. MyDate.wDayOfWeek = 1;
  1860. MyDate.wDay = 12;
  1861. MyDate.wHour = 15;
  1862. MyDate.wMinute = 45;
  1863. MyDate.wSecond = 25;
  1864. MyDate.wMilliseconds = 13;
  1865. rc = GetDateFormatW( 0x0401,
  1866. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1867. &MyDate,
  1868. NULL,
  1869. lpDateStr,
  1870. BUFSIZE );
  1871. CheckReturnValidW( rc,
  1872. -1,
  1873. lpDateStr,
  1874. L"07/\x0630\x0648\x00a0\x0627\x0644\x062d\x062c\x0629/1364", // year 1364
  1875. "Alt Calendar Hijri (long) 1",
  1876. &NumErrors );
  1877. }
  1878. //
  1879. // Hebrew Calendar.
  1880. //
  1881. if (IsValidLocale(0x040d, LCID_INSTALLED))
  1882. {
  1883. // Variation 1 - Hebrew
  1884. MyDate.wYear = 1945;
  1885. MyDate.wMonth = 11;
  1886. MyDate.wDayOfWeek = 1;
  1887. MyDate.wDay = 12;
  1888. MyDate.wHour = 15;
  1889. MyDate.wMinute = 45;
  1890. MyDate.wSecond = 25;
  1891. MyDate.wMilliseconds = 13;
  1892. rc = GetDateFormatW( 0x040d,
  1893. DATE_SHORTDATE,
  1894. &MyDate,
  1895. NULL,
  1896. lpDateStr,
  1897. BUFSIZE );
  1898. CheckReturnValidW( rc,
  1899. -1,
  1900. lpDateStr,
  1901. L"12/11/1945",
  1902. "Hebrew (short) 1",
  1903. &NumErrors );
  1904. // Variation 2 - Hebrew
  1905. MyDate.wYear = 1945;
  1906. MyDate.wMonth = 11;
  1907. MyDate.wDayOfWeek = 1;
  1908. MyDate.wDay = 12;
  1909. MyDate.wHour = 15;
  1910. MyDate.wMinute = 45;
  1911. MyDate.wSecond = 25;
  1912. MyDate.wMilliseconds = 13;
  1913. rc = GetDateFormatW( 0x040d,
  1914. DATE_LONGDATE,
  1915. &MyDate,
  1916. NULL,
  1917. lpDateStr,
  1918. BUFSIZE );
  1919. CheckReturnValidW( rc,
  1920. -1,
  1921. lpDateStr,
  1922. L"\x05d9\x05d5\x05dd\x00a0\x05e9\x05e0\x05d9 12 \x05e0\x05d5\x05d1\x05de\x05d1\x05e8 1945",
  1923. "Hebrew (long) 1",
  1924. &NumErrors );
  1925. // Variation 3 - Hebrew
  1926. MyDate.wYear = 1945;
  1927. MyDate.wMonth = 11;
  1928. MyDate.wDayOfWeek = 1;
  1929. MyDate.wDay = 12;
  1930. MyDate.wHour = 15;
  1931. MyDate.wMinute = 45;
  1932. MyDate.wSecond = 25;
  1933. MyDate.wMilliseconds = 13;
  1934. rc = GetDateFormatW( 0x040d,
  1935. DATE_USE_ALT_CALENDAR | DATE_SHORTDATE,
  1936. &MyDate,
  1937. NULL,
  1938. lpDateStr,
  1939. BUFSIZE );
  1940. CheckReturnValidW( rc, // Kislev 7, 5706
  1941. -1,
  1942. lpDateStr,
  1943. L"\x05d6'/\x05db\x05e1\x05dc\x05d5/\x05ea\x05e9\"\x05d5",
  1944. "Alt Calendar Hebrew (short) 1",
  1945. &NumErrors );
  1946. // Variation 4 - Hebrew
  1947. MyDate.wYear = 1945;
  1948. MyDate.wMonth = 11;
  1949. MyDate.wDayOfWeek = 1;
  1950. MyDate.wDay = 12;
  1951. MyDate.wHour = 15;
  1952. MyDate.wMinute = 45;
  1953. MyDate.wSecond = 25;
  1954. MyDate.wMilliseconds = 13;
  1955. rc = GetDateFormatW( 0x040d,
  1956. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1957. &MyDate,
  1958. NULL,
  1959. lpDateStr,
  1960. BUFSIZE );
  1961. CheckReturnValidW( rc, // Kislev 7, 5706
  1962. -1,
  1963. lpDateStr,
  1964. L"\x05d9\x05d5\x05dd\x00a0\x05e9\x05e0\x05d9 \x05d6' \x05db\x05e1\x05dc\x05d5 \x05ea\x05e9\"\x05d5",
  1965. "Alt Calendar Hebrew (long) 1",
  1966. &NumErrors );
  1967. // Variation 5 - Hebrew
  1968. MyDate.wYear = 1984;
  1969. MyDate.wMonth = 9;
  1970. MyDate.wDayOfWeek = 1;
  1971. MyDate.wDay = 27;
  1972. MyDate.wHour = 15;
  1973. MyDate.wMinute = 45;
  1974. MyDate.wSecond = 25;
  1975. MyDate.wMilliseconds = 13;
  1976. rc = GetDateFormatW( 0x040d,
  1977. DATE_USE_ALT_CALENDAR | DATE_SHORTDATE,
  1978. &MyDate,
  1979. NULL,
  1980. lpDateStr,
  1981. BUFSIZE );
  1982. CheckReturnValidW( rc, // Tishri 1, 5745
  1983. -1,
  1984. lpDateStr,
  1985. L"\x05d0'/\x05ea\x05e9\x05e8\x05d9/\x05ea\x05e9\x05de\"\x05d4",
  1986. "Alt Calendar Hebrew (short) 2",
  1987. &NumErrors );
  1988. // Variation 6 - Hebrew
  1989. MyDate.wYear = 1984;
  1990. MyDate.wMonth = 9;
  1991. MyDate.wDayOfWeek = 1;
  1992. MyDate.wDay = 27;
  1993. MyDate.wHour = 15;
  1994. MyDate.wMinute = 45;
  1995. MyDate.wSecond = 25;
  1996. MyDate.wMilliseconds = 13;
  1997. rc = GetDateFormatW( 0x040d,
  1998. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  1999. &MyDate,
  2000. NULL,
  2001. lpDateStr,
  2002. BUFSIZE );
  2003. CheckReturnValidW( rc, // Tishri 1, 5745
  2004. -1,
  2005. lpDateStr,
  2006. L"\x05d9\x05d5\x05dd\x00a0\x05d7\x05de\x05d9\x05e9\x05d9 \x05d0' \x05ea\x05e9\x05e8\x05d9 \x05ea\x05e9\x05de\"\x05d4",
  2007. "Alt Calendar Hebrew (long) 2",
  2008. &NumErrors );
  2009. }
  2010. //
  2011. // Return total number of errors found.
  2012. //
  2013. return (NumErrors);
  2014. }
  2015. ////////////////////////////////////////////////////////////////////////////
  2016. //
  2017. // GDF_Ansi
  2018. //
  2019. // This routine tests the Ansi version of the API routine.
  2020. //
  2021. // 04-30-93 JulieB Created.
  2022. ////////////////////////////////////////////////////////////////////////////
  2023. int GDF_Ansi()
  2024. {
  2025. int NumErrors = 0; // error count - to be returned
  2026. int rc; // return code
  2027. SYSTEMTIME MyDate; // structure to hold custom date
  2028. BYTE pDateStrA[BUFSIZE]; // ptr to date string
  2029. MyDate.wYear = 1993;
  2030. MyDate.wMonth = 5;
  2031. MyDate.wDayOfWeek = 6;
  2032. MyDate.wDay = 1;
  2033. MyDate.wHour = 15;
  2034. MyDate.wMinute = 45;
  2035. MyDate.wSecond = 25;
  2036. MyDate.wMilliseconds = 13;
  2037. //
  2038. // GetDateFormatA.
  2039. //
  2040. // Variation 1 - US single quote
  2041. rc = GetDateFormatA( Locale,
  2042. 0,
  2043. &MyDate,
  2044. "dddd, MMMM dd, ''''yy",
  2045. pDateStrA,
  2046. BUFSIZE );
  2047. CheckReturnValidA( rc,
  2048. -1,
  2049. pDateStrA,
  2050. "Saturday, May 01, '93",
  2051. NULL,
  2052. "A version US single quote",
  2053. &NumErrors );
  2054. // Variation 2 - US single quote (no dest)
  2055. rc = GetDateFormatA( Locale,
  2056. 0,
  2057. &MyDate,
  2058. "dddd, MMMM dd, ''''yy",
  2059. NULL,
  2060. 0 );
  2061. CheckReturnValidA( rc,
  2062. -1,
  2063. NULL,
  2064. "Saturday, May 01, '93",
  2065. NULL,
  2066. "A version US single quote, no Dest",
  2067. &NumErrors );
  2068. //
  2069. // Use CP ACP.
  2070. //
  2071. // Variation 1 - Use CP ACP, US single quote
  2072. rc = GetDateFormatA( Locale,
  2073. LOCALE_USE_CP_ACP,
  2074. &MyDate,
  2075. "dddd, MMMM dd, ''''yy",
  2076. pDateStrA,
  2077. BUFSIZE );
  2078. CheckReturnValidA( rc,
  2079. -1,
  2080. pDateStrA,
  2081. "Saturday, May 01, '93",
  2082. NULL,
  2083. "A version Use CP ACP, US single quote",
  2084. &NumErrors );
  2085. //
  2086. // Make sure the A and W versions set the same error value.
  2087. //
  2088. SetLastError(0);
  2089. rc = GetDateFormatA( Locale,
  2090. DATE_SHORTDATE,
  2091. &MyDate,
  2092. NULL,
  2093. pDateStrA,
  2094. -1 );
  2095. CheckReturnBadParam( rc,
  2096. 0,
  2097. ERROR_INVALID_PARAMETER,
  2098. "A and W same bad param - A version",
  2099. &NumErrors );
  2100. SetLastError(0);
  2101. rc = GetDateFormatW( Locale,
  2102. DATE_SHORTDATE,
  2103. &MyDate,
  2104. NULL,
  2105. lpDateStr,
  2106. -1 );
  2107. CheckReturnBadParam( rc,
  2108. 0,
  2109. ERROR_INVALID_PARAMETER,
  2110. "A and W same bad param - W version",
  2111. &NumErrors );
  2112. //
  2113. // DATE_LTRREADING and DATE_RTLREADING flags.
  2114. //
  2115. SetLastError(0);
  2116. rc = GetDateFormatA( Locale,
  2117. DATE_LTRREADING | DATE_RTLREADING,
  2118. &MyDate,
  2119. NULL,
  2120. pDateStrA,
  2121. BUFSIZE );
  2122. CheckReturnBadParam( rc,
  2123. 0,
  2124. ERROR_INVALID_FLAGS,
  2125. "A version - LTR and RTL flags",
  2126. &NumErrors );
  2127. SetLastError(0);
  2128. rc = GetDateFormatA( Locale,
  2129. DATE_LTRREADING,
  2130. &MyDate,
  2131. NULL,
  2132. pDateStrA,
  2133. BUFSIZE );
  2134. CheckReturnBadParam( rc,
  2135. 0,
  2136. ERROR_INVALID_FLAGS,
  2137. "A version - LTR flag",
  2138. &NumErrors );
  2139. SetLastError(0);
  2140. rc = GetDateFormatA( Locale,
  2141. DATE_RTLREADING,
  2142. &MyDate,
  2143. NULL,
  2144. pDateStrA,
  2145. BUFSIZE );
  2146. CheckReturnBadParam( rc,
  2147. 0,
  2148. ERROR_INVALID_FLAGS,
  2149. "A version - RTL flag",
  2150. &NumErrors );
  2151. // Iran - Farsi
  2152. if (IsValidLocale(0x0429, LCID_INSTALLED))
  2153. {
  2154. rc = GetDateFormatA( 0x0429,
  2155. DATE_LTRREADING,
  2156. &SysDate,
  2157. NULL,
  2158. pDateStrA,
  2159. BUFSIZE );
  2160. CheckReturnValidA( rc,
  2161. -1,
  2162. pDateStrA,
  2163. "\xfd\x35/\xfd\x31/\xfd\x31\x39\x39\x33",
  2164. NULL,
  2165. "A version - LTR - Iran Farsi",
  2166. &NumErrors );
  2167. rc = GetDateFormatA( 0x0429,
  2168. DATE_RTLREADING,
  2169. &SysDate,
  2170. NULL,
  2171. pDateStrA,
  2172. BUFSIZE );
  2173. CheckReturnValidA( rc,
  2174. -1,
  2175. pDateStrA,
  2176. "\xfe\x35/\xfe\x31/\xfe\x31\x39\x39\x33",
  2177. NULL,
  2178. "A version - RTL - Iran Farsi",
  2179. &NumErrors );
  2180. }
  2181. //
  2182. // Hijri Calendar.
  2183. //
  2184. if (IsValidLocale(0x0401, LCID_INSTALLED))
  2185. {
  2186. // Variation 1 - Hijri
  2187. MyDate.wYear = 1945;
  2188. MyDate.wMonth = 11;
  2189. MyDate.wDayOfWeek = 1;
  2190. MyDate.wDay = 12;
  2191. MyDate.wHour = 15;
  2192. MyDate.wMinute = 45;
  2193. MyDate.wSecond = 25;
  2194. MyDate.wMilliseconds = 13;
  2195. rc = GetDateFormatA( 0x0401,
  2196. DATE_SHORTDATE,
  2197. &MyDate,
  2198. NULL,
  2199. pDateStrA,
  2200. BUFSIZE );
  2201. CheckReturnValidA( rc,
  2202. -1,
  2203. pDateStrA,
  2204. "07/12/64",
  2205. NULL,
  2206. "A version Hijri (short) 1",
  2207. &NumErrors );
  2208. // Variation 2 - Hijri
  2209. MyDate.wYear = 1945;
  2210. MyDate.wMonth = 11;
  2211. MyDate.wDayOfWeek = 1;
  2212. MyDate.wDay = 12;
  2213. MyDate.wHour = 15;
  2214. MyDate.wMinute = 45;
  2215. MyDate.wSecond = 25;
  2216. MyDate.wMilliseconds = 13;
  2217. rc = GetDateFormatA( 0x0401,
  2218. DATE_LONGDATE,
  2219. &MyDate,
  2220. NULL,
  2221. pDateStrA,
  2222. BUFSIZE );
  2223. CheckReturnValidA( rc,
  2224. -1,
  2225. pDateStrA,
  2226. "07/\xd0\xe6\xa0\xc7\xe1\xcd\xcc\xc9/1364", // year 1364
  2227. NULL,
  2228. "A version Hijri (long) 1",
  2229. &NumErrors );
  2230. // Variation 3 - Hijri
  2231. MyDate.wYear = 1945;
  2232. MyDate.wMonth = 11;
  2233. MyDate.wDayOfWeek = 1;
  2234. MyDate.wDay = 12;
  2235. MyDate.wHour = 15;
  2236. MyDate.wMinute = 45;
  2237. MyDate.wSecond = 25;
  2238. MyDate.wMilliseconds = 13;
  2239. rc = GetDateFormatA( 0x0401,
  2240. DATE_USE_ALT_CALENDAR | DATE_SHORTDATE,
  2241. &MyDate,
  2242. NULL,
  2243. pDateStrA,
  2244. BUFSIZE );
  2245. CheckReturnValidA( rc,
  2246. -1,
  2247. pDateStrA,
  2248. "07/12/64", // year 1364
  2249. NULL,
  2250. "A version Alt Calendar Hijri (short) 1",
  2251. &NumErrors );
  2252. // Variation 4 - Hijri
  2253. MyDate.wYear = 1945;
  2254. MyDate.wMonth = 11;
  2255. MyDate.wDayOfWeek = 1;
  2256. MyDate.wDay = 12;
  2257. MyDate.wHour = 15;
  2258. MyDate.wMinute = 45;
  2259. MyDate.wSecond = 25;
  2260. MyDate.wMilliseconds = 13;
  2261. rc = GetDateFormatA( 0x0401,
  2262. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  2263. &MyDate,
  2264. NULL,
  2265. pDateStrA,
  2266. BUFSIZE );
  2267. CheckReturnValidA( rc,
  2268. -1,
  2269. pDateStrA,
  2270. "07/\xd0\xe6\xa0\xc7\xe1\xcd\xcc\xc9/1364", // year 1364
  2271. NULL,
  2272. "A version Alt Calendar Hijri (long) 1",
  2273. &NumErrors );
  2274. }
  2275. //
  2276. // Hebrew Calendar.
  2277. //
  2278. if (IsValidLocale(0x040d, LCID_INSTALLED))
  2279. {
  2280. // Variation 1 - Hebrew
  2281. MyDate.wYear = 1945;
  2282. MyDate.wMonth = 11;
  2283. MyDate.wDayOfWeek = 1;
  2284. MyDate.wDay = 12;
  2285. MyDate.wHour = 15;
  2286. MyDate.wMinute = 45;
  2287. MyDate.wSecond = 25;
  2288. MyDate.wMilliseconds = 13;
  2289. rc = GetDateFormatA( 0x040d,
  2290. DATE_SHORTDATE,
  2291. &MyDate,
  2292. NULL,
  2293. pDateStrA,
  2294. BUFSIZE );
  2295. CheckReturnValidA( rc,
  2296. -1,
  2297. pDateStrA,
  2298. "12/11/1945",
  2299. NULL,
  2300. "A version Hebrew (short) 1",
  2301. &NumErrors );
  2302. // Variation 2 - Hebrew
  2303. MyDate.wYear = 1945;
  2304. MyDate.wMonth = 11;
  2305. MyDate.wDayOfWeek = 1;
  2306. MyDate.wDay = 12;
  2307. MyDate.wHour = 15;
  2308. MyDate.wMinute = 45;
  2309. MyDate.wSecond = 25;
  2310. MyDate.wMilliseconds = 13;
  2311. rc = GetDateFormatA( 0x040d,
  2312. DATE_LONGDATE,
  2313. &MyDate,
  2314. NULL,
  2315. pDateStrA,
  2316. BUFSIZE );
  2317. CheckReturnValidA( rc,
  2318. -1,
  2319. pDateStrA,
  2320. "\xe9\xe5\xed\xa0\xf9\xf0\xe9 12 \xf0\xe5\xe1\xee\xe1\xf8 1945",
  2321. NULL,
  2322. "A version Hebrew (long) 1",
  2323. &NumErrors );
  2324. // Variation 3 - Hebrew
  2325. MyDate.wYear = 1945;
  2326. MyDate.wMonth = 11;
  2327. MyDate.wDayOfWeek = 1;
  2328. MyDate.wDay = 12;
  2329. MyDate.wHour = 15;
  2330. MyDate.wMinute = 45;
  2331. MyDate.wSecond = 25;
  2332. MyDate.wMilliseconds = 13;
  2333. rc = GetDateFormatA( 0x040d,
  2334. DATE_USE_ALT_CALENDAR | DATE_SHORTDATE,
  2335. &MyDate,
  2336. NULL,
  2337. pDateStrA,
  2338. BUFSIZE );
  2339. CheckReturnValidA( rc, // Kislev 7, 5706
  2340. -1,
  2341. pDateStrA,
  2342. "\xe6'/\xeb\xf1\xec\xe5/\xfa\xf9\"\xe5",
  2343. NULL,
  2344. "A version Alt Calendar Hebrew (short) 1",
  2345. &NumErrors );
  2346. // Variation 4 - Hebrew
  2347. MyDate.wYear = 1945;
  2348. MyDate.wMonth = 11;
  2349. MyDate.wDayOfWeek = 1;
  2350. MyDate.wDay = 12;
  2351. MyDate.wHour = 15;
  2352. MyDate.wMinute = 45;
  2353. MyDate.wSecond = 25;
  2354. MyDate.wMilliseconds = 13;
  2355. rc = GetDateFormatA( 0x040d,
  2356. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  2357. &MyDate,
  2358. NULL,
  2359. pDateStrA,
  2360. BUFSIZE );
  2361. CheckReturnValidA( rc, // Kislev 7, 5706
  2362. -1,
  2363. pDateStrA,
  2364. "\xe9\xe5\xed\xa0\xf9\xf0\xe9 \xe6' \xeb\xf1\xec\xe5 \xfa\xf9\"\xe5",
  2365. NULL,
  2366. "A version Alt Calendar Hebrew (long) 1",
  2367. &NumErrors );
  2368. // Variation 5 - Hebrew
  2369. MyDate.wYear = 1984;
  2370. MyDate.wMonth = 9;
  2371. MyDate.wDayOfWeek = 1;
  2372. MyDate.wDay = 27;
  2373. MyDate.wHour = 15;
  2374. MyDate.wMinute = 45;
  2375. MyDate.wSecond = 25;
  2376. MyDate.wMilliseconds = 13;
  2377. rc = GetDateFormatA( 0x040d,
  2378. DATE_USE_ALT_CALENDAR | DATE_SHORTDATE,
  2379. &MyDate,
  2380. NULL,
  2381. pDateStrA,
  2382. BUFSIZE );
  2383. CheckReturnValidA( rc, // Tishri 1, 5745
  2384. -1,
  2385. pDateStrA,
  2386. "\xe0'/\xfa\xf9\xf8\xe9/\xfa\xf9\xee\"\xe4",
  2387. NULL,
  2388. "A version Alt Calendar Hebrew (short) 2",
  2389. &NumErrors );
  2390. // Variation 6 - Hebrew
  2391. MyDate.wYear = 1984;
  2392. MyDate.wMonth = 9;
  2393. MyDate.wDayOfWeek = 1;
  2394. MyDate.wDay = 27;
  2395. MyDate.wHour = 15;
  2396. MyDate.wMinute = 45;
  2397. MyDate.wSecond = 25;
  2398. MyDate.wMilliseconds = 13;
  2399. rc = GetDateFormatA( 0x040d,
  2400. DATE_USE_ALT_CALENDAR | DATE_LONGDATE,
  2401. &MyDate,
  2402. NULL,
  2403. pDateStrA,
  2404. BUFSIZE );
  2405. CheckReturnValidA( rc, // Tishri 1, 5745
  2406. -1,
  2407. pDateStrA,
  2408. "\xe9\xe5\xed\xa0\xe7\xee\xe9\xf9\xe9 \xe0' \xfa\xf9\xf8\xe9 \xfa\xf9\xee\"\xe4",
  2409. NULL,
  2410. "A version Alt Calendar Hebrew (long) 2",
  2411. &NumErrors );
  2412. }
  2413. //
  2414. // Return total number of errors found.
  2415. //
  2416. return (NumErrors);
  2417. }