]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/dtifmtts.cpp
ICU-511.34.tar.gz
[apple/icu.git] / icuSources / test / intltest / dtifmtts.cpp
1
2 /********************************************************************
3 * COPYRIGHT:
4 * Copyright (c) 1997-2013, International Business Machines Corporation and
5 * others. All Rights Reserved.
6 ********************************************************************/
7
8 #include "unicode/utypes.h"
9
10 #if !UCONFIG_NO_FORMATTING
11
12
13 //TODO: define it in compiler flag
14 //#define DTIFMTTS_DEBUG 1
15
16
17 #ifdef DTIFMTTS_DEBUG
18 #include <iostream>
19 #endif
20
21
22 #include "cstring.h"
23 #include "dtifmtts.h"
24 #include "unicode/gregocal.h"
25 #include "unicode/dtintrv.h"
26 #include "unicode/dtitvinf.h"
27 #include "unicode/dtitvfmt.h"
28 #include "unicode/localpointer.h"
29 #include "unicode/timezone.h"
30
31
32
33 #ifdef DTIFMTTS_DEBUG
34 //#define PRINTMESG(msg) { std::cout << "(" << __FILE__ << ":" << __LINE__ << ") " << msg << "\n"; }
35 #define PRINTMESG(msg) { std::cout << msg; }
36 #endif
37
38 #define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
39
40 #include <stdio.h>
41
42
43 void DateIntervalFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) {
44 if (exec) logln("TestSuite DateIntervalFormat");
45 switch (index) {
46 TESTCASE(0, testAPI);
47 TESTCASE(1, testFormat);
48 TESTCASE(2, testFormatUserDII);
49 TESTCASE(3, testSetIntervalPatternNoSideEffect);
50 TESTCASE(4, testStress);
51 default: name = ""; break;
52 }
53 }
54
55 /**
56 * Test various generic API methods of DateIntervalFormat for API coverage.
57 */
58 void DateIntervalFormatTest::testAPI() {
59
60 /* ====== Test create interval instance with default locale and skeleton
61 */
62 UErrorCode status = U_ZERO_ERROR;
63 logln("Testing DateIntervalFormat create instance with default locale and skeleton");
64
65 DateIntervalFormat* dtitvfmt = DateIntervalFormat::createInstance(UDAT_YEAR_MONTH_DAY, status);
66 if(U_FAILURE(status)) {
67 dataerrln("ERROR: Could not create DateIntervalFormat (skeleton + default locale) - exitting");
68 return;
69 } else {
70 delete dtitvfmt;
71 }
72
73
74 /* ====== Test create interval instance with given locale and skeleton
75 */
76 status = U_ZERO_ERROR;
77 logln("Testing DateIntervalFormat create instance with given locale and skeleton");
78
79 dtitvfmt = DateIntervalFormat::createInstance(UDAT_YEAR_MONTH_DAY, Locale::getJapanese(), status);
80 if(U_FAILURE(status)) {
81 dataerrln("ERROR: Could not create DateIntervalFormat (skeleton + locale) - exitting");
82 return;
83 } else {
84 delete dtitvfmt;
85 }
86
87
88 /* ====== Test create interval instance with dateIntervalInfo and skeleton
89 */
90 status = U_ZERO_ERROR;
91 logln("Testing DateIntervalFormat create instance with dateIntervalInfo and skeleton");
92
93 DateIntervalInfo* dtitvinf = new DateIntervalInfo(Locale::getSimplifiedChinese(), status);
94
95 dtitvfmt = DateIntervalFormat::createInstance("EEEdMMMyhms", *dtitvinf, status);
96 delete dtitvinf;
97
98 if(U_FAILURE(status)) {
99 dataerrln("ERROR: Could not create DateIntervalFormat (skeleton + DateIntervalInfo + default locale) - exitting");
100 return;
101 } else {
102 delete dtitvfmt;
103 }
104
105
106 /* ====== Test create interval instance with dateIntervalInfo and skeleton
107 */
108 status = U_ZERO_ERROR;
109 logln("Testing DateIntervalFormat create instance with dateIntervalInfo and skeleton");
110
111 dtitvinf = new DateIntervalInfo(Locale::getSimplifiedChinese(), status);
112
113 dtitvfmt = DateIntervalFormat::createInstance("EEEdMMMyhms", Locale::getSimplifiedChinese(), *dtitvinf, status);
114 delete dtitvinf;
115 if(U_FAILURE(status)) {
116 dataerrln("ERROR: Could not create DateIntervalFormat (skeleton + DateIntervalInfo + locale) - exitting");
117 return;
118 }
119 // not deleted, test clone
120
121
122 // ====== Test clone()
123 status = U_ZERO_ERROR;
124 logln("Testing DateIntervalFormat clone");
125
126 DateIntervalFormat* another = (DateIntervalFormat*)dtitvfmt->clone();
127 if ( (*another) != (*dtitvfmt) ) {
128 dataerrln("ERROR: clone failed");
129 }
130
131
132 // ====== Test getDateIntervalInfo, setDateIntervalInfo, adoptDateIntervalInfo
133 status = U_ZERO_ERROR;
134 logln("Testing DateIntervalFormat getDateIntervalInfo");
135 const DateIntervalInfo* inf = another->getDateIntervalInfo();
136 dtitvfmt->setDateIntervalInfo(*inf, status);
137 const DateIntervalInfo* anotherInf = dtitvfmt->getDateIntervalInfo();
138 if ( (*inf) != (*anotherInf) || U_FAILURE(status) ) {
139 dataerrln("ERROR: getDateIntervalInfo/setDateIntervalInfo failed");
140 }
141
142 {
143 // We make sure that setDateIntervalInfo does not corrupt the cache. See ticket 9919.
144 status = U_ZERO_ERROR;
145 logln("Testing DateIntervalFormat setDateIntervalInfo");
146 const Locale &enLocale = Locale::getEnglish();
147 LocalPointer<DateIntervalFormat> dif(DateIntervalFormat::createInstance("yMd", enLocale, status));
148 if (U_FAILURE(status)) {
149 errln("Failure encountered: %s", u_errorName(status));
150 return;
151 }
152 UnicodeString expected;
153 LocalPointer<Calendar> fromTime(Calendar::createInstance(enLocale, status));
154 LocalPointer<Calendar> toTime(Calendar::createInstance(enLocale, status));
155 if (U_FAILURE(status)) {
156 errln("Failure encountered: %s", u_errorName(status));
157 return;
158 }
159 FieldPosition pos = 0;
160 fromTime->set(2013, 3, 26);
161 toTime->set(2013, 3, 28);
162 dif->format(*fromTime, *toTime, expected, pos, status);
163 if (U_FAILURE(status)) {
164 errln("Failure encountered: %s", u_errorName(status));
165 return;
166 }
167 LocalPointer<DateIntervalInfo> dii(new DateIntervalInfo(Locale::getEnglish(), status));
168 if (U_FAILURE(status)) {
169 errln("Failure encountered: %s", u_errorName(status));
170 return;
171 }
172 dii->setIntervalPattern(ctou("yMd"), UCAL_DATE, ctou("M/d/y \\u2013 d"), status);
173 dif->setDateIntervalInfo(*dii, status);
174 if (U_FAILURE(status)) {
175 errln("Failure encountered: %s", u_errorName(status));
176 return;
177 }
178 dif.adoptInstead(DateIntervalFormat::createInstance("yMd", enLocale, status));
179 if (U_FAILURE(status)) {
180 errln("Failure encountered: %s", u_errorName(status));
181 return;
182 }
183 UnicodeString actual;
184 pos = 0;
185 dif->format(*fromTime, *toTime, actual, pos, status);
186 if (U_FAILURE(status)) {
187 errln("Failure encountered: %s", u_errorName(status));
188 return;
189 }
190 if (expected != actual) {
191 errln("DateIntervalFormat.setIntervalInfo should have no side effects.");
192 }
193 }
194
195 /*
196 status = U_ZERO_ERROR;
197 DateIntervalInfo* nonConstInf = inf->clone();
198 dtitvfmt->adoptDateIntervalInfo(nonConstInf, status);
199 anotherInf = dtitvfmt->getDateIntervalInfo();
200 if ( (*inf) != (*anotherInf) || U_FAILURE(status) ) {
201 dataerrln("ERROR: adoptDateIntervalInfo failed");
202 }
203 */
204
205 // ====== Test getDateFormat, setDateFormat, adoptDateFormat
206
207 status = U_ZERO_ERROR;
208 logln("Testing DateIntervalFormat getDateFormat");
209 /*
210 const DateFormat* fmt = another->getDateFormat();
211 dtitvfmt->setDateFormat(*fmt, status);
212 const DateFormat* anotherFmt = dtitvfmt->getDateFormat();
213 if ( (*fmt) != (*anotherFmt) || U_FAILURE(status) ) {
214 dataerrln("ERROR: getDateFormat/setDateFormat failed");
215 }
216
217 status = U_ZERO_ERROR;
218 DateFormat* nonConstFmt = (DateFormat*)fmt->clone();
219 dtitvfmt->adoptDateFormat(nonConstFmt, status);
220 anotherFmt = dtitvfmt->getDateFormat();
221 if ( (*fmt) != (*anotherFmt) || U_FAILURE(status) ) {
222 dataerrln("ERROR: adoptDateFormat failed");
223 }
224 delete fmt;
225 */
226
227
228 // ======= Test getStaticClassID()
229
230 logln("Testing getStaticClassID()");
231
232
233 if(dtitvfmt->getDynamicClassID() != DateIntervalFormat::getStaticClassID()) {
234 errln("ERROR: getDynamicClassID() didn't return the expected value");
235 }
236
237 delete another;
238
239 // ====== test constructor/copy constructor and assignment
240 /* they are protected, no test
241 logln("Testing DateIntervalFormat constructor and assigment operator");
242 status = U_ZERO_ERROR;
243
244 DateFormat* constFmt = (constFmt*)dtitvfmt->getDateFormat()->clone();
245 inf = dtitvfmt->getDateIntervalInfo()->clone();
246
247
248 DateIntervalFormat* dtifmt = new DateIntervalFormat(fmt, inf, status);
249 if(U_FAILURE(status)) {
250 dataerrln("ERROR: Could not create DateIntervalFormat (default) - exitting");
251 return;
252 }
253
254 DateIntervalFormat* dtifmt2 = new(dtifmt);
255 if ( (*dtifmt) != (*dtifmt2) ) {
256 dataerrln("ERROR: Could not create DateIntervalFormat (default) - exitting");
257 return;
258 }
259
260 DateIntervalFormat dtifmt3 = (*dtifmt);
261 if ( (*dtifmt) != dtifmt3 ) {
262 dataerrln("ERROR: Could not create DateIntervalFormat (default) - exitting");
263 return;
264 }
265
266 delete dtifmt2;
267 delete dtifmt3;
268 delete dtifmt;
269 */
270
271
272 //===== test format and parse ==================
273 Formattable formattable;
274 formattable.setInt64(10);
275 UnicodeString res;
276 FieldPosition pos = 0;
277 status = U_ZERO_ERROR;
278 dtitvfmt->format(formattable, res, pos, status);
279 if ( status != U_ILLEGAL_ARGUMENT_ERROR ) {
280 dataerrln("ERROR: format non-date-interval object should set U_ILLEGAL_ARGUMENT_ERROR - exitting");
281 return;
282 }
283
284 DateInterval* dtitv = new DateInterval(3600*24*365, 3600*24*366);
285 formattable.adoptObject(dtitv);
286 res.remove();
287 pos = 0;
288 status = U_ZERO_ERROR;
289 dtitvfmt->format(formattable, res, pos, status);
290 if ( U_FAILURE(status) ) {
291 dataerrln("ERROR: format date interval failed - exitting");
292 return;
293 }
294
295 const DateFormat* dfmt = dtitvfmt->getDateFormat();
296 Calendar* fromCal = dfmt->getCalendar()->clone();
297 Calendar* toCal = dfmt->getCalendar()->clone();
298 res.remove();
299 pos = 0;
300 status = U_ZERO_ERROR;
301 dtitvfmt->format(*fromCal, *toCal, res, pos, status);
302 if ( U_FAILURE(status) ) {
303 dataerrln("ERROR: format date interval failed - exitting");
304 return;
305 }
306 delete fromCal;
307 delete toCal;
308
309
310 Formattable fmttable;
311 status = U_ZERO_ERROR;
312 // TODO: why do I need cast?
313 ((Format*)dtitvfmt)->parseObject(res, fmttable, status);
314 if ( status != U_INVALID_FORMAT_ERROR ) {
315 dataerrln("ERROR: parse should set U_INVALID_FORMAT_ERROR - exitting");
316 return;
317 }
318
319 delete dtitvfmt;
320
321 //====== test setting time zone
322 logln("Testing DateIntervalFormat set & format with different time zones, get time zone");
323 status = U_ZERO_ERROR;
324 dtitvfmt = DateIntervalFormat::createInstance("MMMdHHmm", Locale::getEnglish(), status);
325 if ( U_SUCCESS(status) ) {
326 UDate date1 = 1299090600000.0; // 2011-Mar-02 1030 in US/Pacific, 2011-Mar-03 0330 in Asia/Tokyo
327 UDate date2 = 1299115800000.0; // 2011-Mar-02 1730 in US/Pacific, 2011-Mar-03 1030 in Asia/Tokyo
328
329 DateInterval * dtitv12 = new DateInterval(date1, date2);
330 TimeZone * tzCalif = TimeZone::createTimeZone("US/Pacific");
331 TimeZone * tzTokyo = TimeZone::createTimeZone("Asia/Tokyo");
332 UnicodeString fmtCalif = UnicodeString(ctou("Mar 2, 10:30 - 17:30"));
333 UnicodeString fmtTokyo = UnicodeString(ctou("Mar 3, 03:30 - 10:30"));
334
335 dtitvfmt->adoptTimeZone(tzCalif);
336 res.remove();
337 pos = 0;
338 status = U_ZERO_ERROR;
339 dtitvfmt->format(dtitv12, res, pos, status);
340 if ( U_SUCCESS(status) ) {
341 if ( res.compare(fmtCalif) != 0 ) {
342 errln("ERROR: DateIntervalFormat::format for tzCalif, expect " + fmtCalif + ", get " + res);
343 }
344 } else {
345 errln("ERROR: DateIntervalFormat::format for tzCalif, status %s", u_errorName(status));
346 }
347
348 dtitvfmt->setTimeZone(*tzTokyo);
349 res.remove();
350 pos = 0;
351 status = U_ZERO_ERROR;
352 dtitvfmt->format(dtitv12, res, pos, status);
353 if ( U_SUCCESS(status) ) {
354 if ( res.compare(fmtTokyo) != 0 ) {
355 errln("ERROR: DateIntervalFormat::format for fmtTokyo, expect " + fmtTokyo + ", get " + res);
356 }
357 } else {
358 errln("ERROR: DateIntervalFormat::format for tzTokyo, status %s", u_errorName(status));
359 }
360
361 if ( dtitvfmt->getTimeZone() != *tzTokyo ) {
362 errln("ERROR: DateIntervalFormat::getTimeZone returns mismatch.");
363 }
364
365 delete tzTokyo; // tzCalif was owned by dtitvfmt which should have deleted it
366 delete dtitv12;
367 delete dtitvfmt;
368 } else {
369 errln("ERROR: DateIntervalFormat::createInstance(\"MdHH\", Locale::getEnglish(), ...), status %s", u_errorName(status));
370 }
371 //====== test format in testFormat()
372
373 //====== test DateInterval class (better coverage)
374 DateInterval dtitv1(3600*24*365, 3600*24*366);
375 DateInterval dtitv2(dtitv1);
376
377 if (!(dtitv1 == dtitv2)) {
378 errln("ERROR: Copy constructor failed for DateInterval.");
379 }
380
381 DateInterval dtitv3(3600*365, 3600*366);
382 dtitv3 = dtitv1;
383 if (!(dtitv3 == dtitv1)) {
384 errln("ERROR: Equal operator failed for DateInterval.");
385 }
386
387 DateInterval *dtitv4 = dtitv1.clone();
388 if (*dtitv4 != dtitv1) {
389 errln("ERROR: Equal operator failed for DateInterval.");
390 }
391 delete dtitv4;
392 }
393
394
395 /**
396 * Test format
397 */
398 void DateIntervalFormatTest::testFormat() {
399 // first item is date pattern
400 // followed by a group of locale/from_data/to_data/skeleton/interval_data
401 const char* DATA[] = {
402 "yyyy MM dd HH:mm:ss",
403 // test root
404 "root", "2007 11 10 10:10:10", "2007 12 10 10:10:10", "yM", "2007-11 \\u2013 2007-12",
405
406 // test 'H' and 'h', using availableFormat in fallback
407 "en", "2007 11 10 10:10:10", "2007 11 10 15:10:10", "Hms", "10:10:10 - 15:10:10",
408 "en", "2007 11 10 10:10:10", "2007 11 10 15:10:10", "hms", "10:10:10 AM - 3:10:10 PM",
409
410 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMM", "October 2007 - October 2008",
411 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMM", "Oct 2007 - Oct 2008",
412 // test skeleton with both date and time
413 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 AM - Nov 20, 2007, 10:10 AM",
414
415 "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 - 11:10 AM",
416
417 "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "hms", "10:10:10 AM - 11:10:10 AM",
418 "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "Hms", "10:10:10 - 11:10:10",
419 "en", "2007 11 10 20:10:10", "2007 11 10 21:10:10", "Hms", "20:10:10 - 21:10:10",
420
421 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10, 2007 - Friday, October 10, 2008",
422
423 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMy", "October 10, 2007 - October 10, 2008",
424
425 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMM", "October 10, 2007 - October 10, 2008",
426
427 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMMy", "October 2007 - October 2008",
428
429 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMM", "Wednesday, October 10, 2007 - Friday, October 10, 2008",
430
431 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMMy", "Wed, Oct 10, 2007 - Fri, Oct 10, 2008",
432
433 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMy", "Oct 10, 2007 - Oct 10, 2008",
434
435 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "Oct 10, 2007 - Oct 10, 2008",
436
437 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Oct 2007 - Oct 2008",
438
439 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMM", "Wed, Oct 10, 2007 - Fri, Oct 10, 2008",
440
441 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Wed, 10/10/2007 - Fri, 10/10/2008",
442
443 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10/10/2007 - 10/10/2008",
444
445 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dM", "10/10/2007 - 10/10/2008",
446
447 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10/2007 - 10/2008",
448
449 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Wed, 10/10/2007 - Fri, 10/10/2008",
450
451 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "d", "10/10/2007 - 10/10/2008",
452
453 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Ed", "10 Wed - 10 Fri",
454
455 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007 - 2008",
456
457 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10/2007 - 10/2008",
458
459
460
461 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10/10/2007, 10:10 AM - 10/10/2008, 10:10 AM",
462 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Hm", "10/10/2007, 10:10 - 10/10/2008, 10:10",
463 "en", "2007 10 10 20:10:10", "2008 10 10 20:10:10", "Hm", "10/10/2007, 20:10 - 10/10/2008, 20:10",
464
465 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmv", "10/10/2007, 10:10 AM PT - 10/10/2008, 10:10 AM PT",
466
467 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmz", "10/10/2007, 10:10 AM PDT - 10/10/2008, 10:10 AM PDT",
468
469 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "h", "10/10/2007, 10 AM - 10/10/2008, 10 AM",
470
471 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hv", "10/10/2007, 10 AM PT - 10/10/2008, 10 AM PT",
472
473 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hz", "10/10/2007, 10 AM PDT - 10/10/2008, 10 AM PDT",
474
475 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 - Fri, 10/10/2008",
476
477 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EddMMy", "Wed, 10/10/2007 - Fri, 10/10/2008",
478
479 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmm", "10/10/2007, 10:10 AM - 10/10/2008, 10:10 AM",
480
481 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmmzz", "10/10/2007, 10:10 AM PDT - 10/10/2008, 10:10 AM PDT",
482
483 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hms", "10/10/2007, 10:10:10 AM - 10/10/2008, 10:10:10 AM",
484
485 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMMy", "O 10, 2007 - O 10, 2008",
486
487 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEEdM", "W, 10/10/2007 - F, 10/10/2008",
488
489 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10 - Saturday, November 10, 2007",
490
491 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMy", "October 10 - November 10, 2007",
492
493 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMM", "October 10 - November 10",
494
495 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "October - November 2007",
496
497 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMM", "Wednesday, October 10 - Saturday, November 10",
498
499 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMMy", "Wed, Oct 10 - Sat, Nov 10, 2007",
500
501 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMy", "Oct 10 - Nov 10, 2007",
502
503 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "Oct 10 - Nov 10",
504
505 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Oct - Nov 2007",
506
507 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMM", "Wed, Oct 10 - Sat, Nov 10",
508
509 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMy", "Wed, 10/10/2007 - Sat, 11/10/2007",
510
511 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMy", "10/10/2007 - 11/10/2007",
512
513
514 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10/2007 - 11/2007",
515
516 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdM", "Wed, 10/10 - Sat, 11/10",
517
518 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10/10 - 11/10",
519
520 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Ed", "10 Wed - 10 Sat",
521
522 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "y", "2007",
523
524 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "M", "10 - 11",
525
526 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Oct - Nov",
527
528 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMM", "October - November",
529
530 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hm", "10/10/2007, 10:10 AM - 11/10/2007, 10:10 AM",
531 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Hm", "10/10/2007, 10:10 - 11/10/2007, 10:10",
532 "en", "2007 10 10 20:10:10", "2007 11 10 20:10:10", "Hm", "10/10/2007, 20:10 - 11/10/2007, 20:10",
533
534 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "10/10/2007, 10:10 AM PT - 11/10/2007, 10:10 AM PT",
535
536 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmz", "10/10/2007, 10:10 AM PDT - 11/10/2007, 10:10 AM PST",
537
538 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "h", "10/10/2007, 10 AM - 11/10/2007, 10 AM",
539
540 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hv", "10/10/2007, 10 AM PT - 11/10/2007, 10 AM PT",
541
542 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hz", "10/10/2007, 10 AM PDT - 11/10/2007, 10 AM PST",
543
544 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 - Sat, 11/10/2007",
545
546 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EddMMy", "Wed, 10/10/2007 - Sat, 11/10/2007",
547
548
549 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hhmmzz", "10/10/2007, 10:10 AM PDT - 11/10/2007, 10:10 AM PST",
550
551 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10/10/2007, 10:10:10 AM - 11/10/2007, 10:10:10 AM",
552
553 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMMy", "O 10 - N 10, 2007",
554
555 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEEdM", "W, 10/10 - S, 11/10",
556
557 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMMy", "Saturday, November 10 - Tuesday, November 20, 2007",
558
559 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMy", "November 10 - 20, 2007",
560
561 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMM", "November 10 - 20",
562
563
564 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMM", "Saturday, November 10 - Tuesday, November 20",
565
566 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMMy", "Sat, Nov 10 - Tue, Nov 20, 2007",
567
568 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMy", "Nov 10 - 20, 2007",
569
570 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMM", "Nov 10 - 20",
571
572 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov 2007",
573
574 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMM", "Sat, Nov 10 - Tue, Nov 20",
575
576 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sat, 11/10/2007 - Tue, 11/20/2007",
577
578 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "11/10/2007 - 11/20/2007",
579
580 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 - 11/20",
581
582 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "11/2007",
583
584 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "Sat, 11/10 - Tue, 11/20",
585
586 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10 - 20",
587
588 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Ed", "10 Sat - 20 Tue",
589
590 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007",
591
592 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11",
593
594 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "Nov",
595
596 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMM", "November",
597
598 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hm", "11/10/2007, 10:10 AM - 11/20/2007, 10:10 AM",
599 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Hm", "11/10/2007, 10:10 - 11/20/2007, 10:10",
600 "en", "2007 11 10 20:10:10", "2007 11 20 20:10:10", "Hm", "11/10/2007, 20:10 - 11/20/2007, 20:10",
601
602 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "11/10/2007, 10:10 AM PT - 11/20/2007, 10:10 AM PT",
603
604 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "11/10/2007, 10:10 AM PST - 11/20/2007, 10:10 AM PST",
605
606 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "h", "11/10/2007, 10 AM - 11/20/2007, 10 AM",
607
608 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hv", "11/10/2007, 10 AM PT - 11/20/2007, 10 AM PT",
609
610 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hz", "11/10/2007, 10 AM PST - 11/20/2007, 10 AM PST",
611
612 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEddMMyyyy", "Sat, 11/10/2007 - Tue, 11/20/2007",
613
614 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EddMMy", "Sat, 11/10/2007 - Tue, 11/20/2007",
615
616 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hhmm", "11/10/2007, 10:10 AM - 11/20/2007, 10:10 AM",
617
618 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hhmmzz", "11/10/2007, 10:10 AM PST - 11/20/2007, 10:10 AM PST",
619
620 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hms", "11/10/2007, 10:10:10 AM - 11/20/2007, 10:10:10 AM",
621 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Hms", "11/10/2007, 10:10:10 - 11/20/2007, 10:10:10",
622 "en", "2007 11 10 20:10:10", "2007 11 20 20:10:10", "Hms", "11/10/2007, 20:10:10 - 11/20/2007, 20:10:10",
623
624 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMMy", "N 10 - 20, 2007",
625
626 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEEdM", "S, 11/10 - T, 11/20",
627
628 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "Wednesday, January 10, 2007",
629
630 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMMy", "January 10, 2007",
631
632 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMM", "January 10",
633
634 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMMy", "January 2007",
635
636 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMM", "Wednesday, January 10",
637
638 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdMMMy", "Wed, Jan 10, 2007",
639
640 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMy", "Jan 10, 2007",
641
642 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "Jan 10",
643
644 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan 2007",
645
646 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdMMM", "Wed, Jan 10",
647
648
649 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMy", "1/10/2007",
650
651 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dM", "1/10",
652
653 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "My", "1/2007",
654
655 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdM", "Wed, 1/10",
656
657 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "d", "10",
658
659 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Ed", "10 Wed",
660
661 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "y", "2007",
662
663 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "M", "1",
664
665 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMM", "Jan",
666
667 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMM", "January",
668
669 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "10:00 AM - 2:10 PM",
670 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Hm", "10:00 - 14:10",
671
672 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmv", "10:00 AM - 2:10 PM PT",
673
674 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "10:00 AM - 2:10 PM PST",
675
676 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 AM - 2 PM",
677 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "H", "10 - 14",
678
679
680 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hz", "10 AM - 2 PM PST",
681
682 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEddMMyyyy", "Wed, 01/10/2007",
683
684 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EddMMy", "Wed, 01/10/2007",
685
686 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hhmm", "10:00 AM - 2:10 PM",
687 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "HHmm", "10:00 - 14:10",
688
689 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hhmmzz", "10:00 AM - 2:10 PM PST",
690
691 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hms", "10:00:10 AM - 2:10:10 PM",
692 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Hms", "10:00:10 - 14:10:10",
693
694 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMMMy", "J 10, 2007",
695
696 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEEdM", "W, 1/10",
697 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMMy", "January 10, 2007",
698
699 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMM", "January 10",
700
701 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "MMMMy", "January 2007",
702
703 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMMM", "Wednesday, January 10",
704
705 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMMMy", "Wed, Jan 10, 2007",
706
707 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMy", "Jan 10, 2007",
708
709 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMM", "Jan 10",
710
711
712 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMMM", "Wed, Jan 10",
713
714 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMy", "Wed, 1/10/2007",
715
716 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMy", "1/10/2007",
717
718
719 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "My", "1/2007",
720
721 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdM", "Wed, 1/10",
722
723 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "d", "10",
724
725
726 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "y", "2007",
727
728 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "M", "1",
729
730
731
732 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "10:00 - 10:20 AM",
733 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "Hm", "10:00 - 10:20",
734
735
736 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmz", "10:00 - 10:20 AM PST",
737
738
739 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hv", "10 AM PT",
740
741
742
743 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EddMMy", "Wed, 01/10/2007",
744
745 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hhmm", "10:00 - 10:20 AM",
746 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "HHmm", "10:00 - 10:20",
747
748 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hhmmzz", "10:00 - 10:20 AM PST",
749
750
751 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMMMy", "J 10, 2007",
752
753
754 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMMy", "Wednesday, January 10, 2007",
755
756 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMMMy", "January 10, 2007",
757
758
759 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "MMMMy", "January 2007",
760
761 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMM", "Wednesday, January 10",
762
763
764 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMMy", "Jan 10, 2007",
765
766 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMM", "Jan 10",
767
768
769 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdMMM", "Wed, Jan 10",
770
771 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdMy", "Wed, 1/10/2007",
772
773 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMy", "1/10/2007",
774
775
776 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "My", "1/2007",
777
778 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdM", "Wed, 1/10",
779
780 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "d", "10",
781
782
783 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "y", "2007",
784
785 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "M", "1",
786
787
788 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "MMMM", "January",
789
790 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "10:10 AM",
791 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Hm", "10:10",
792
793
794 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 AM PST",
795
796 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "10 AM",
797
798 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hv", "10 AM PT",
799
800
801 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEddMMyyyy", "Wed, 01/10/2007",
802
803
804 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hhmm", "10:10 AM",
805 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "HHmm", "10:10",
806
807 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hhmmzz", "10:10 AM PST",
808
809
810 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMMMMy", "J 10, 2007",
811
812 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEEdM", "W, 1/10",
813
814 "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMMy", "2007\\u5e7410\\u670810\\u65e5\\u661f\\u671f\\u4e09\\u81f32008\\u5e7410\\u670810\\u65e5\\u661f\\u671f\\u4e94",
815
816
817 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMy", "2007\\u5e7410\\u670810\\u65e5\\u81f311\\u670810\\u65e5",
818
819
820 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "2007\\u5e7410\\u6708\\u81f311\\u6708",
821
822
823 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "2007/10/10 \\u4E0A\\u534810:10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4 \\u2013 2007/11/10 \\u4E0A\\u534810:10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4",
824
825 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMMy", "2007\\u5e7411\\u670810\\u65e5\\u661f\\u671f\\u516d\\u81f320\\u65e5\\u661f\\u671f\\u4e8c",
826
827
828 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMM", "11\\u670810\\u65e5\\u81f320\\u65e5",
829
830 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMMy", "2007\\u5E7411\\u6708", // (fixed expected result per ticket:6626:)
831
832 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMM", "11\\u670810\\u65e5\\u661f\\u671f\\u516d\\u81f320\\u65e5\\u661f\\u671f\\u4e8c",
833
834
835 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "2007/11/10\\u5468\\u516d\\u81f32007/11/20\\u5468\\u4e8c",
836
837
838 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 \\u2013 11/20",
839
840 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "2007/11",
841
842 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "11/10\\u5468\\u516d\\u81f311/20\\u5468\\u4e8c",
843
844
845 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007\\u5E74", // (fixed expected result per ticket:6626:)
846
847 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11\\u6708",
848
849 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "11\\u6708", // (fixed expected result per ticket:6626: and others)
850
851
852 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "2007/11/10 \\u4e0a\\u534810:10 GMT-8 \\u2013 2007/11/20 \\u4e0a\\u534810:10 GMT-8",
853
854 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "h", "2007/11/10 \\u4e0a\\u534810\\u65f6 \\u2013 2007/11/20 \\u4e0a\\u534810\\u65f6",
855
856 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "2007\\u5e741\\u670810\\u65e5 \\u661f\\u671f\\u4e09",
857
858 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10",
859
860
861 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "GMT-8\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10",
862
863 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "\\u4e0a\\u534810\\u65F6\\u81f3\\u4e0b\\u53482\\u65f6",
864
865 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810\\u65F6\\u81F3\\u4E0B\\u53482\\u65F6",
866
867 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "\\u4e0a\\u534810:00\\u81f310:20",
868
869 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:00\\u81F310:20",
870
871 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "\\u4e0a\\u534810\\u65f6 GMT-8",
872
873 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "\\u4e0a\\u534810:10",
874
875 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "\\u4e0a\\u534810\\u65f6",
876
877 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. 2007 - Freitag, 10. Okt. 2008",
878
879
880 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "10. Okt. 2007 - 10. Okt. 2008",
881
882 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Okt. 2007 - Okt. 2008",
883
884
885 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Mi., 10.10.2007 - Fr., 10.10.2008",
886
887 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10.10.2007 - 10.10.2008",
888
889
890 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10.2007 - 10.2008",
891
892 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Mi., 10.10.2007 - Fr., 10.10.2008",
893
894
895 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007-2008",
896
897 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10.2007 - 10.2008",
898
899
900 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10.10.2007 10:10 vorm. - 10.10.2008 10:10 vorm.",
901 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Hm", "10.10.2007 10:10 - 10.10.2008 10:10",
902
903 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. - Samstag, 10. Nov. 2007",
904
905
906 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "10. Okt. - 10. Nov.",
907
908 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Okt.-Nov. 2007",
909
910 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMM", "Mittwoch, 10. Okt. - Samstag, 10. Nov.",
911
912
913 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dM", "10.10. - 10.11.",
914
915 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10.2007 - 11.2007",
916
917
918 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10.10. - 10.11.",
919
920 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "y", "2007",
921
922
923 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Okt.-Nov.",
924
925
926 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10.10.2007 10:10:10 vorm. - 10.11.2007 10:10:10 vorm.",
927 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Hms", "10.10.2007 10:10:10 - 10.11.2007 10:10:10",
928
929 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMy", "Samstag, 10. - Dienstag, 20. Nov. 2007",
930
931 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMy", "10.-20. Nov. 2007",
932
933
934 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov. 2007",
935
936 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMM", "Samstag, 10. - Dienstag, 20. Nov.",
937
938 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sa., 10.11.2007 - Di., 20.11.2007",
939
940
941 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "10.11. - 20.11.",
942
943 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "11.2007",
944
945
946 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10.-20.",
947
948 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007",
949
950
951 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "10.11.2007 10:10 vorm. Los Angeles Zeit - 20.11.2007 10:10 vorm. Los Angeles Zeit",
952
953 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007",
954
955
956 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "10. Jan.",
957
958 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan. 2007",
959
960 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMM", "Mittwoch, 10. Jan.",
961
962
963 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 vorm. - 2 nachm.",
964 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "H", "10-14 Uhr",
965
966 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMM", "Mittwoch, 10. Jan.",
967
968
969 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "10:00-10:20 vorm. Los Angeles Zeit",
970
971 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmz", "10:00-10:20 vorm. GMT-8",
972
973 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "10 vorm.",
974 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "H", "10 Uhr",
975
976
977 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "10 vorm. GMT-8",
978
979 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007",
980
981
982 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmv", "10:10 vorm. Los Angeles Zeit",
983
984 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 vorm. GMT-8",
985
986
987 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hv", "10 vorm. Los Angeles Zeit",
988
989 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hz", "10 vorm. GMT-8",
990
991 // Thai (default calendar buddhist)
992
993 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E1E\\u0E38\\u0E18 10 \\u0E15.\\u0E04. 2550 - \\u0E27\\u0E31\\u0E19\\u0E28\\u0E38\\u0E01\\u0E23\\u0E4C 10 \\u0E15.\\u0E04. 2551",
994
995
996 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMMM", "10 \\u0E15.\\u0E04. 2550 - 10 \\u0E15.\\u0E04. 2551",
997
998 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "MMMy", "\\u0E15.\\u0E04. 2550 - \\u0E15.\\u0E04. 2551",
999
1000
1001 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdMy", "\\u0E1E. 10/10/2550 - \\u0E28. 10/10/2551",
1002
1003 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMy", "10/10/2550 - 10/10/2551",
1004
1005
1006 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "My", "10/2550 - 10/2551",
1007
1008 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdM", "\\u0E1E. 10/10/2550 - \\u0E28. 10/10/2551",
1009
1010
1011 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "y", "2550-2551",
1012
1013 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "M", "10/2550 - 10/2551",
1014
1015
1016 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E1E\\u0E38\\u0E18 10 \\u0E15.\\u0E04. - \\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C 10 \\u0E1E.\\u0E22. 2550",
1017
1018
1019 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dMMM", "10 \\u0E15.\\u0E04. - 10 \\u0E1E.\\u0E22.",
1020
1021 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "MMMy", "\\u0E15.\\u0E04.-\\u0E1E.\\u0E22. 2550",
1022
1023 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dM", "10/10 - 10/11",
1024
1025 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "My", "10/2550 - 11/2550",
1026
1027
1028 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "d", "10/10 - 10/11",
1029
1030 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "y", "\\u0E1E.\\u0E28. 2550",
1031
1032
1033 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "MMM", "\\u0E15.\\u0E04.-\\u0E1E.\\u0E22.",
1034
1035 };
1036 expect(DATA, ARRAY_SIZE(DATA));
1037 }
1038
1039
1040 void DateIntervalFormatTest::expect(const char** data, int32_t data_length) {
1041 int32_t i = 0;
1042 UErrorCode ec = U_ZERO_ERROR;
1043 UnicodeString str, str2;
1044 const char* pattern = data[0];
1045 i++;
1046
1047 #ifdef DTIFMTTS_DEBUG
1048 char result[1000];
1049 char mesg[1000];
1050 sprintf(mesg, "locale: %s\n", locName);
1051 PRINTMESG(mesg);
1052 #endif
1053
1054 while (i<data_length) {
1055 const char* locName = data[i++];
1056 Locale loc(locName);
1057 SimpleDateFormat ref(pattern, loc, ec);
1058 if (U_FAILURE(ec)) {
1059 dataerrln("contruct SimpleDateFormat in expect failed: %s", u_errorName(ec));
1060 return;
1061 }
1062 // 'f'
1063 const char* datestr = data[i++];
1064 const char* datestr_2 = data[i++];
1065 #ifdef DTIFMTTS_DEBUG
1066 sprintf(mesg, "original date: %s - %s\n", datestr, datestr_2);
1067 PRINTMESG(mesg)
1068 #endif
1069 UDate date = ref.parse(ctou(datestr), ec);
1070 if (!assertSuccess("parse 1st data in expect", ec)) return;
1071 UDate date_2 = ref.parse(ctou(datestr_2), ec);
1072 if (!assertSuccess("parse 2nd data in expect", ec)) return;
1073 DateInterval dtitv(date, date_2);
1074
1075 const UnicodeString& oneSkeleton = data[i++];
1076
1077 DateIntervalFormat* dtitvfmt = DateIntervalFormat::createInstance(oneSkeleton, loc, ec);
1078 if (!assertSuccess("createInstance(skeleton) in expect", ec)) return;
1079 FieldPosition pos=0;
1080 dtitvfmt->format(&dtitv, str.remove(), pos, ec);
1081 if (!assertSuccess("format in expect", ec)) return;
1082 assertEquals((UnicodeString)"\"" + locName + "\\" + oneSkeleton + "\\" + datestr + "\\" + datestr_2 + "\"", ctou(data[i++]), str);
1083
1084
1085
1086 #ifdef DTIFMTTS_DEBUG
1087 str.extract(0, str.length(), result, "UTF-8");
1088 sprintf(mesg, "interval date: %s\n", result);
1089 std::cout << "//";
1090 PRINTMESG(mesg)
1091 std::cout << "\"" << locName << "\", "
1092 << "\"" << datestr << "\", "
1093 << "\"" << datestr_2 << "\", ";
1094 printUnicodeString(oneSkeleton);
1095 printUnicodeString(str);
1096 std::cout << "\n\n";
1097 #endif
1098 delete dtitvfmt;
1099 }
1100 }
1101
1102
1103 /*
1104 * Test format using user defined DateIntervalInfo
1105 */
1106 void DateIntervalFormatTest::testFormatUserDII() {
1107 // first item is date pattern
1108 const char* DATA[] = {
1109 "yyyy MM dd HH:mm:ss",
1110 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Oct 10, 2007 --- Oct 10, 2008",
1111
1112 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 Oct 10 - Nov 2007",
1113
1114 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Nov 10, 2007 --- Nov 20, 2007",
1115
1116 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Jan 10, 2007",
1117
1118 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "Jan 10, 2007",
1119
1120 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Jan 10, 2007",
1121
1122 "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "2007\\u5e7410\\u670810\\u65e5 --- 2008\\u5e7410\\u670810\\u65e5",
1123
1124 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 10\\u6708 10 - 11\\u6708 2007",
1125
1126 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007\\u5e7411\\u670810\\u65e5 --- 2007\\u5e7411\\u670820\\u65e5",
1127
1128 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket:6626:)
1129
1130 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket:6626:)
1131
1132 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket:6626:)
1133
1134 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10. Okt. 2007 --- 10. Okt. 2008",
1135
1136
1137 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10. Nov. 2007 --- 20. Nov. 2007",
1138
1139 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10. Jan. 2007",
1140
1141 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10. Jan. 2007",
1142
1143
1144 "es", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10 oct 2007 --- 10 oct 2008",
1145
1146 "es", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 oct 10 - nov 2007",
1147
1148 "es", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10 nov 2007 --- 20 nov 2007",
1149
1150 "es", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10 ene 2007",
1151
1152 "es", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10 ene 2007",
1153
1154 "es", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "10 ene 2007",
1155 };
1156 expectUserDII(DATA, ARRAY_SIZE(DATA));
1157 }
1158
1159
1160 void DateIntervalFormatTest::testSetIntervalPatternNoSideEffect() {
1161 UErrorCode ec = U_ZERO_ERROR;
1162 LocalPointer<DateIntervalInfo> dtitvinf(new DateIntervalInfo(ec));
1163 if (U_FAILURE(ec)) {
1164 errln("Failure encountered: %s", u_errorName(ec));
1165 return;
1166 }
1167 UnicodeString expected;
1168 dtitvinf->getIntervalPattern(ctou("yMd"), UCAL_DATE, expected, ec);
1169 dtitvinf->setIntervalPattern(ctou("yMd"), UCAL_DATE, ctou("M/d/y \\u2013 d"), ec);
1170 if (U_FAILURE(ec)) {
1171 errln("Failure encountered: %s", u_errorName(ec));
1172 return;
1173 }
1174 dtitvinf.adoptInstead(new DateIntervalInfo(ec));
1175 if (U_FAILURE(ec)) {
1176 errln("Failure encountered: %s", u_errorName(ec));
1177 return;
1178 }
1179 UnicodeString actual;
1180 dtitvinf->getIntervalPattern(ctou("yMd"), UCAL_DATE, actual, ec);
1181 if (U_FAILURE(ec)) {
1182 errln("Failure encountered: %s", u_errorName(ec));
1183 return;
1184 }
1185 if (expected != actual) {
1186 errln("DateIntervalInfo.setIntervalPattern should have no side effects.");
1187 }
1188 }
1189
1190
1191 void DateIntervalFormatTest::expectUserDII(const char** data,
1192 int32_t data_length) {
1193 int32_t i = 0;
1194 UnicodeString str;
1195 UErrorCode ec = U_ZERO_ERROR;
1196 const char* pattern = data[0];
1197 i++;
1198
1199 while ( i < data_length ) {
1200 const char* locName = data[i++];
1201 Locale loc(locName);
1202 SimpleDateFormat ref(pattern, loc, ec);
1203 if (U_FAILURE(ec)) {
1204 dataerrln("contruct SimpleDateFormat in expectUserDII failed: %s", u_errorName(ec));
1205 return;
1206 }
1207 const char* datestr = data[i++];
1208 const char* datestr_2 = data[i++];
1209 UDate date = ref.parse(ctou(datestr), ec);
1210 if (!assertSuccess("parse in expectUserDII", ec)) return;
1211 UDate date_2 = ref.parse(ctou(datestr_2), ec);
1212 if (!assertSuccess("parse in expectUserDII", ec)) return;
1213 DateInterval dtitv(date, date_2);
1214
1215 ec = U_ZERO_ERROR;
1216 // test user created DateIntervalInfo
1217 DateIntervalInfo* dtitvinf = new DateIntervalInfo(ec);
1218 dtitvinf->setFallbackIntervalPattern("{0} --- {1}", ec);
1219 dtitvinf->setIntervalPattern(UDAT_YEAR_ABBR_MONTH_DAY, UCAL_MONTH, "yyyy MMM d - MMM y",ec);
1220 if (!assertSuccess("DateIntervalInfo::setIntervalPattern", ec)) return;
1221 dtitvinf->setIntervalPattern(UDAT_YEAR_ABBR_MONTH_DAY, UCAL_HOUR_OF_DAY, "yyyy MMM d HH:mm - HH:mm", ec);
1222 if (!assertSuccess("DateIntervalInfo::setIntervalPattern", ec)) return;
1223 DateIntervalFormat* dtitvfmt = DateIntervalFormat::createInstance(UDAT_YEAR_ABBR_MONTH_DAY, loc, *dtitvinf, ec);
1224 delete dtitvinf;
1225 if (!assertSuccess("createInstance(skeleton,dtitvinf) in expectUserDII", ec)) return;
1226 FieldPosition pos=0;
1227 dtitvfmt->format(&dtitv, str.remove(), pos, ec);
1228 if (!assertSuccess("format in expectUserDII", ec)) return;
1229 assertEquals((UnicodeString)"\"" + locName + "\\" + datestr + "\\" + datestr_2 + "\"", ctou(data[i++]), str);
1230 #ifdef DTIFMTTS_DEBUG
1231 char result[1000];
1232 char mesg[1000];
1233 PRINTMESG("interval format using user defined DateIntervalInfo\n");
1234 str.extract(0, str.length(), result, "UTF-8");
1235 sprintf(mesg, "interval date: %s\n", result);
1236 PRINTMESG(mesg);
1237 #endif
1238 delete dtitvfmt;
1239 }
1240 }
1241
1242
1243 void DateIntervalFormatTest::testStress() {
1244 if(quick){
1245 logln("Quick mode: Skipping test");
1246 return;
1247 }
1248 const char* DATA[] = {
1249 "yyyy MM dd HH:mm:ss",
1250 "2007 10 10 10:10:10", "2008 10 10 10:10:10",
1251 "2007 10 10 10:10:10", "2007 11 10 10:10:10",
1252 "2007 11 10 10:10:10", "2007 11 20 10:10:10",
1253 "2007 01 10 10:00:10", "2007 01 10 14:10:10",
1254 "2007 01 10 10:00:10", "2007 01 10 10:20:10",
1255 "2007 01 10 10:10:10", "2007 01 10 10:10:20",
1256 };
1257
1258 const char* testLocale[][3] = {
1259 //{"th", "", ""},
1260 {"en", "", ""},
1261 {"zh", "", ""},
1262 {"de", "", ""},
1263 {"ar", "", ""},
1264 {"en", "GB", ""},
1265 {"fr", "", ""},
1266 {"it", "", ""},
1267 {"nl", "", ""},
1268 {"zh", "TW", ""},
1269 {"ja", "", ""},
1270 {"pt", "BR", ""},
1271 {"ru", "", ""},
1272 {"pl", "", ""},
1273 {"tr", "", ""},
1274 {"es", "", ""},
1275 {"ko", "", ""},
1276 {"sv", "", ""},
1277 {"fi", "", ""},
1278 {"da", "", ""},
1279 {"pt", "PT", ""},
1280 {"ro", "", ""},
1281 {"hu", "", ""},
1282 {"he", "", ""},
1283 {"in", "", ""},
1284 {"cs", "", ""},
1285 {"el", "", ""},
1286 {"no", "", ""},
1287 {"vi", "", ""},
1288 {"bg", "", ""},
1289 {"hr", "", ""},
1290 {"lt", "", ""},
1291 {"sk", "", ""},
1292 {"sl", "", ""},
1293 {"sr", "", ""},
1294 {"ca", "", ""},
1295 {"lv", "", ""},
1296 {"uk", "", ""},
1297 {"hi", "", ""},
1298 };
1299
1300 uint32_t localeIndex;
1301 for ( localeIndex = 0; localeIndex < ARRAY_SIZE(testLocale); ++localeIndex ) {
1302 char locName[32];
1303 uprv_strcpy(locName, testLocale[localeIndex][0]);
1304 uprv_strcat(locName, testLocale[localeIndex][1]);
1305 stress(DATA, ARRAY_SIZE(DATA), Locale(testLocale[localeIndex][0], testLocale[localeIndex][1], testLocale[localeIndex][2]), locName);
1306 }
1307 }
1308
1309
1310 void DateIntervalFormatTest::stress(const char** data, int32_t data_length,
1311 const Locale& loc, const char* locName) {
1312 UnicodeString skeleton[] = {
1313 "EEEEdMMMMy",
1314 "dMMMMy",
1315 "dMMMM",
1316 "MMMMy",
1317 "EEEEdMMMM",
1318 "EdMMMy",
1319 "dMMMy",
1320 "dMMM",
1321 "MMMy",
1322 "EdMMM",
1323 "EdMy",
1324 "dMy",
1325 "dM",
1326 "My",
1327 "EdM",
1328 "d",
1329 "Ed",
1330 "y",
1331 "M",
1332 "MMM",
1333 "MMMM",
1334 "hm",
1335 "hmv",
1336 "hmz",
1337 "h",
1338 "hv",
1339 "hz",
1340 "EEddMMyyyy", // following could be normalized
1341 "EddMMy",
1342 "hhmm",
1343 "hhmmzz",
1344 "hms", // following could not be normalized
1345 "dMMMMMy",
1346 "EEEEEdM",
1347 };
1348
1349 int32_t i = 0;
1350 UErrorCode ec = U_ZERO_ERROR;
1351 UnicodeString str, str2;
1352 SimpleDateFormat ref(data[i++], loc, ec);
1353 if (!assertSuccess("construct SimpleDateFormat", ec)) return;
1354
1355 #ifdef DTIFMTTS_DEBUG
1356 char result[1000];
1357 char mesg[1000];
1358 sprintf(mesg, "locale: %s\n", locName);
1359 PRINTMESG(mesg);
1360 #endif
1361
1362 while (i<data_length) {
1363
1364 // 'f'
1365 const char* datestr = data[i++];
1366 const char* datestr_2 = data[i++];
1367 #ifdef DTIFMTTS_DEBUG
1368 sprintf(mesg, "original date: %s - %s\n", datestr, datestr_2);
1369 PRINTMESG(mesg)
1370 #endif
1371 UDate date = ref.parse(ctou(datestr), ec);
1372 if (!assertSuccess("parse", ec)) return;
1373 UDate date_2 = ref.parse(ctou(datestr_2), ec);
1374 if (!assertSuccess("parse", ec)) return;
1375 DateInterval dtitv(date, date_2);
1376
1377 for ( uint32_t skeletonIndex = 0;
1378 skeletonIndex < ARRAY_SIZE(skeleton);
1379 ++skeletonIndex ) {
1380 const UnicodeString& oneSkeleton = skeleton[skeletonIndex];
1381 DateIntervalFormat* dtitvfmt = DateIntervalFormat::createInstance(oneSkeleton, loc, ec);
1382 if (!assertSuccess("createInstance(skeleton)", ec)) return;
1383 /*
1384 // reset the calendar to be Gregorian calendar for "th"
1385 if ( uprv_strcmp(locName, "th") == 0 ) {
1386 GregorianCalendar* gregCal = new GregorianCalendar(loc, ec);
1387 if (!assertSuccess("GregorianCalendar()", ec)) return;
1388 const DateFormat* dformat = dtitvfmt->getDateFormat();
1389 DateFormat* newOne = (DateFormat*)dformat->clone();
1390 newOne->adoptCalendar(gregCal);
1391 //dtitvfmt->adoptDateFormat(newOne, ec);
1392 dtitvfmt->setDateFormat(*newOne, ec);
1393 delete newOne;
1394 if (!assertSuccess("adoptDateFormat()", ec)) return;
1395 }
1396 */
1397 FieldPosition pos=0;
1398 dtitvfmt->format(&dtitv, str.remove(), pos, ec);
1399 if (!assertSuccess("format", ec)) return;
1400 #ifdef DTIFMTTS_DEBUG
1401 oneSkeleton.extract(0, oneSkeleton.length(), result, "UTF-8");
1402 sprintf(mesg, "interval by skeleton: %s\n", result);
1403 PRINTMESG(mesg)
1404 str.extract(0, str.length(), result, "UTF-8");
1405 sprintf(mesg, "interval date: %s\n", result);
1406 PRINTMESG(mesg)
1407 #endif
1408 delete dtitvfmt;
1409 }
1410
1411 // test user created DateIntervalInfo
1412 ec = U_ZERO_ERROR;
1413 DateIntervalInfo* dtitvinf = new DateIntervalInfo(ec);
1414 dtitvinf->setFallbackIntervalPattern("{0} --- {1}", ec);
1415 dtitvinf->setIntervalPattern(UDAT_YEAR_ABBR_MONTH_DAY, UCAL_MONTH, "yyyy MMM d - MMM y",ec);
1416 if (!assertSuccess("DateIntervalInfo::setIntervalPattern", ec)) return;
1417 dtitvinf->setIntervalPattern(UDAT_YEAR_ABBR_MONTH_DAY, UCAL_HOUR_OF_DAY, "yyyy MMM d HH:mm - HH:mm", ec);
1418 if (!assertSuccess("DateIntervalInfo::setIntervalPattern", ec)) return;
1419 DateIntervalFormat* dtitvfmt = DateIntervalFormat::createInstance(UDAT_YEAR_ABBR_MONTH_DAY, loc, *dtitvinf, ec);
1420 delete dtitvinf;
1421 if (!assertSuccess("createInstance(skeleton,dtitvinf)", ec)) return;
1422 FieldPosition pos=0;
1423 dtitvfmt->format(&dtitv, str.remove(), pos, ec);
1424 if ( uprv_strcmp(locName, "th") ) {
1425 if (!assertSuccess("format", ec)) return;
1426 #ifdef DTIFMTTS_DEBUG
1427 PRINTMESG("interval format using user defined DateIntervalInfo\n");
1428 str.extract(0, str.length(), result, "UTF-8");
1429 sprintf(mesg, "interval date: %s\n", result);
1430 PRINTMESG(mesg)
1431 #endif
1432 } else {
1433 // for "th", the default calendar is Budhist,
1434 // not Gregorian.
1435 assertTrue("Default calendar for \"th\" is Budhist", ec == U_ILLEGAL_ARGUMENT_ERROR);
1436 ec = U_ZERO_ERROR;
1437 }
1438 delete dtitvfmt;
1439 }
1440 }
1441
1442 #endif /* #if !UCONFIG_NO_FORMATTING */