2 /********************************************************************
4 * Copyright (c) 1997-2015, International Business Machines Corporation and
5 * others. All Rights Reserved.
6 ********************************************************************/
8 #include "unicode/utypes.h"
10 #if !UCONFIG_NO_FORMATTING
13 //TODO: define it in compiler flag
14 //#define DTIFMTTS_DEBUG 1
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"
34 //#define PRINTMESG(msg) { std::cout << "(" << __FILE__ << ":" << __LINE__ << ") " << msg << "\n"; }
35 #define PRINTMESG(msg) { std::cout << msg; }
38 #define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
43 void DateIntervalFormatTest::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* /*par*/ ) {
44 if (exec
) logln("TestSuite DateIntervalFormat");
47 TESTCASE(1, testFormat
);
48 TESTCASE(2, testFormatUserDII
);
49 TESTCASE(3, testSetIntervalPatternNoSideEffect
);
50 TESTCASE(4, testYearFormats
);
51 TESTCASE(5, testStress
);
52 TESTCASE(6, testTicket11583_2
);
53 default: name
= ""; break;
58 * Test various generic API methods of DateIntervalFormat for API coverage.
60 void DateIntervalFormatTest::testAPI() {
62 /* ====== Test create interval instance with default locale and skeleton
64 UErrorCode status
= U_ZERO_ERROR
;
65 logln("Testing DateIntervalFormat create instance with default locale and skeleton");
67 DateIntervalFormat
* dtitvfmt
= DateIntervalFormat::createInstance(UDAT_YEAR_MONTH_DAY
, status
);
68 if(U_FAILURE(status
)) {
69 dataerrln("ERROR: Could not create DateIntervalFormat (skeleton + default locale) - exitting");
76 /* ====== Test create interval instance with given locale and skeleton
78 status
= U_ZERO_ERROR
;
79 logln("Testing DateIntervalFormat create instance with given locale and skeleton");
81 dtitvfmt
= DateIntervalFormat::createInstance(UDAT_YEAR_MONTH_DAY
, Locale::getJapanese(), status
);
82 if(U_FAILURE(status
)) {
83 dataerrln("ERROR: Could not create DateIntervalFormat (skeleton + locale) - exitting");
90 /* ====== Test create interval instance with dateIntervalInfo and skeleton
92 status
= U_ZERO_ERROR
;
93 logln("Testing DateIntervalFormat create instance with dateIntervalInfo and skeleton");
95 DateIntervalInfo
* dtitvinf
= new DateIntervalInfo(Locale::getSimplifiedChinese(), status
);
97 dtitvfmt
= DateIntervalFormat::createInstance("EEEdMMMyhms", *dtitvinf
, status
);
100 if(U_FAILURE(status
)) {
101 dataerrln("ERROR: Could not create DateIntervalFormat (skeleton + DateIntervalInfo + default locale) - exitting");
108 /* ====== Test create interval instance with dateIntervalInfo and skeleton
110 status
= U_ZERO_ERROR
;
111 logln("Testing DateIntervalFormat create instance with dateIntervalInfo and skeleton");
113 dtitvinf
= new DateIntervalInfo(Locale::getSimplifiedChinese(), status
);
115 dtitvfmt
= DateIntervalFormat::createInstance("EEEdMMMyhms", Locale::getSimplifiedChinese(), *dtitvinf
, status
);
117 if(U_FAILURE(status
)) {
118 dataerrln("ERROR: Could not create DateIntervalFormat (skeleton + DateIntervalInfo + locale) - exitting");
121 // not deleted, test clone
124 // ====== Test clone()
125 status
= U_ZERO_ERROR
;
126 logln("Testing DateIntervalFormat clone");
128 DateIntervalFormat
* another
= (DateIntervalFormat
*)dtitvfmt
->clone();
129 if ( (*another
) != (*dtitvfmt
) ) {
130 dataerrln("ERROR: clone failed");
134 // ====== Test getDateIntervalInfo, setDateIntervalInfo, adoptDateIntervalInfo
135 status
= U_ZERO_ERROR
;
136 logln("Testing DateIntervalFormat getDateIntervalInfo");
137 const DateIntervalInfo
* inf
= another
->getDateIntervalInfo();
138 dtitvfmt
->setDateIntervalInfo(*inf
, status
);
139 const DateIntervalInfo
* anotherInf
= dtitvfmt
->getDateIntervalInfo();
140 if ( (*inf
) != (*anotherInf
) || U_FAILURE(status
) ) {
141 dataerrln("ERROR: getDateIntervalInfo/setDateIntervalInfo failed");
145 // We make sure that setDateIntervalInfo does not corrupt the cache. See ticket 9919.
146 status
= U_ZERO_ERROR
;
147 logln("Testing DateIntervalFormat setDateIntervalInfo");
148 const Locale
&enLocale
= Locale::getEnglish();
149 LocalPointer
<DateIntervalFormat
> dif(DateIntervalFormat::createInstance("yMd", enLocale
, status
));
150 if (U_FAILURE(status
)) {
151 errln("Failure encountered: %s", u_errorName(status
));
154 UnicodeString expected
;
155 LocalPointer
<Calendar
> fromTime(Calendar::createInstance(enLocale
, status
));
156 LocalPointer
<Calendar
> toTime(Calendar::createInstance(enLocale
, status
));
157 if (U_FAILURE(status
)) {
158 errln("Failure encountered: %s", u_errorName(status
));
161 FieldPosition pos
= 0;
162 fromTime
->set(2013, 3, 26);
163 toTime
->set(2013, 3, 28);
164 dif
->format(*fromTime
, *toTime
, expected
, pos
, status
);
165 if (U_FAILURE(status
)) {
166 errln("Failure encountered: %s", u_errorName(status
));
169 LocalPointer
<DateIntervalInfo
> dii(new DateIntervalInfo(Locale::getEnglish(), status
), status
);
170 if (U_FAILURE(status
)) {
171 errln("Failure encountered: %s", u_errorName(status
));
174 dii
->setIntervalPattern(ctou("yMd"), UCAL_DATE
, ctou("M/d/y \\u2013 d"), status
);
175 dif
->setDateIntervalInfo(*dii
, status
);
176 if (U_FAILURE(status
)) {
177 errln("Failure encountered: %s", u_errorName(status
));
180 dif
.adoptInstead(DateIntervalFormat::createInstance("yMd", enLocale
, status
));
181 if (U_FAILURE(status
)) {
182 errln("Failure encountered: %s", u_errorName(status
));
185 UnicodeString actual
;
187 dif
->format(*fromTime
, *toTime
, actual
, pos
, status
);
188 if (U_FAILURE(status
)) {
189 errln("Failure encountered: %s", u_errorName(status
));
192 if (expected
!= actual
) {
193 errln("DateIntervalFormat.setIntervalInfo should have no side effects.");
198 status = U_ZERO_ERROR;
199 DateIntervalInfo* nonConstInf = inf->clone();
200 dtitvfmt->adoptDateIntervalInfo(nonConstInf, status);
201 anotherInf = dtitvfmt->getDateIntervalInfo();
202 if ( (*inf) != (*anotherInf) || U_FAILURE(status) ) {
203 dataerrln("ERROR: adoptDateIntervalInfo failed");
207 // ====== Test getDateFormat, setDateFormat, adoptDateFormat
209 status
= U_ZERO_ERROR
;
210 logln("Testing DateIntervalFormat getDateFormat");
212 const DateFormat* fmt = another->getDateFormat();
213 dtitvfmt->setDateFormat(*fmt, status);
214 const DateFormat* anotherFmt = dtitvfmt->getDateFormat();
215 if ( (*fmt) != (*anotherFmt) || U_FAILURE(status) ) {
216 dataerrln("ERROR: getDateFormat/setDateFormat failed");
219 status = U_ZERO_ERROR;
220 DateFormat* nonConstFmt = (DateFormat*)fmt->clone();
221 dtitvfmt->adoptDateFormat(nonConstFmt, status);
222 anotherFmt = dtitvfmt->getDateFormat();
223 if ( (*fmt) != (*anotherFmt) || U_FAILURE(status) ) {
224 dataerrln("ERROR: adoptDateFormat failed");
230 // ======= Test getStaticClassID()
232 logln("Testing getStaticClassID()");
235 if(dtitvfmt
->getDynamicClassID() != DateIntervalFormat::getStaticClassID()) {
236 errln("ERROR: getDynamicClassID() didn't return the expected value");
241 // ====== test constructor/copy constructor and assignment
242 /* they are protected, no test
243 logln("Testing DateIntervalFormat constructor and assigment operator");
244 status = U_ZERO_ERROR;
246 DateFormat* constFmt = (constFmt*)dtitvfmt->getDateFormat()->clone();
247 inf = dtitvfmt->getDateIntervalInfo()->clone();
250 DateIntervalFormat* dtifmt = new DateIntervalFormat(fmt, inf, status);
251 if(U_FAILURE(status)) {
252 dataerrln("ERROR: Could not create DateIntervalFormat (default) - exitting");
256 DateIntervalFormat* dtifmt2 = new(dtifmt);
257 if ( (*dtifmt) != (*dtifmt2) ) {
258 dataerrln("ERROR: Could not create DateIntervalFormat (default) - exitting");
262 DateIntervalFormat dtifmt3 = (*dtifmt);
263 if ( (*dtifmt) != dtifmt3 ) {
264 dataerrln("ERROR: Could not create DateIntervalFormat (default) - exitting");
274 //===== test format and parse ==================
275 Formattable formattable
;
276 formattable
.setInt64(10);
278 FieldPosition pos
= 0;
279 status
= U_ZERO_ERROR
;
280 dtitvfmt
->format(formattable
, res
, pos
, status
);
281 if ( status
!= U_ILLEGAL_ARGUMENT_ERROR
) {
282 dataerrln("ERROR: format non-date-interval object should set U_ILLEGAL_ARGUMENT_ERROR - exitting");
286 DateInterval
* dtitv
= new DateInterval(3600*24*365, 3600*24*366);
287 formattable
.adoptObject(dtitv
);
290 status
= U_ZERO_ERROR
;
291 dtitvfmt
->format(formattable
, res
, pos
, status
);
292 if ( U_FAILURE(status
) ) {
293 dataerrln("ERROR: format date interval failed - exitting");
297 const DateFormat
* dfmt
= dtitvfmt
->getDateFormat();
298 Calendar
* fromCal
= dfmt
->getCalendar()->clone();
299 Calendar
* toCal
= dfmt
->getCalendar()->clone();
302 status
= U_ZERO_ERROR
;
303 dtitvfmt
->format(*fromCal
, *toCal
, res
, pos
, status
);
304 if ( U_FAILURE(status
) ) {
305 dataerrln("ERROR: format date interval failed - exitting");
312 Formattable fmttable
;
313 status
= U_ZERO_ERROR
;
314 // TODO: why do I need cast?
315 ((Format
*)dtitvfmt
)->parseObject(res
, fmttable
, status
);
316 if ( status
!= U_INVALID_FORMAT_ERROR
) {
317 dataerrln("ERROR: parse should set U_INVALID_FORMAT_ERROR - exitting");
323 //====== test setting time zone
324 logln("Testing DateIntervalFormat set & format with different time zones, get time zone");
325 status
= U_ZERO_ERROR
;
326 dtitvfmt
= DateIntervalFormat::createInstance("MMMdHHmm", Locale::getEnglish(), status
);
327 if ( U_SUCCESS(status
) ) {
328 UDate date1
= 1299090600000.0; // 2011-Mar-02 1030 in US/Pacific, 2011-Mar-03 0330 in Asia/Tokyo
329 UDate date2
= 1299115800000.0; // 2011-Mar-02 1730 in US/Pacific, 2011-Mar-03 1030 in Asia/Tokyo
331 DateInterval
* dtitv12
= new DateInterval(date1
, date2
);
332 TimeZone
* tzCalif
= TimeZone::createTimeZone("US/Pacific");
333 TimeZone
* tzTokyo
= TimeZone::createTimeZone("Asia/Tokyo");
334 UnicodeString fmtCalif
= UnicodeString(ctou("Mar 2, 10:30 - 17:30"));
335 UnicodeString fmtTokyo
= UnicodeString(ctou("Mar 3, 03:30 - 10:30"));
337 dtitvfmt
->adoptTimeZone(tzCalif
);
340 status
= U_ZERO_ERROR
;
341 dtitvfmt
->format(dtitv12
, res
, pos
, status
);
342 if ( U_SUCCESS(status
) ) {
343 if ( res
.compare(fmtCalif
) != 0 ) {
344 errln("ERROR: DateIntervalFormat::format for tzCalif, expect " + fmtCalif
+ ", get " + res
);
347 errln("ERROR: DateIntervalFormat::format for tzCalif, status %s", u_errorName(status
));
350 dtitvfmt
->setTimeZone(*tzTokyo
);
353 status
= U_ZERO_ERROR
;
354 dtitvfmt
->format(dtitv12
, res
, pos
, status
);
355 if ( U_SUCCESS(status
) ) {
356 if ( res
.compare(fmtTokyo
) != 0 ) {
357 errln("ERROR: DateIntervalFormat::format for fmtTokyo, expect " + fmtTokyo
+ ", get " + res
);
360 errln("ERROR: DateIntervalFormat::format for tzTokyo, status %s", u_errorName(status
));
363 if ( dtitvfmt
->getTimeZone() != *tzTokyo
) {
364 errln("ERROR: DateIntervalFormat::getTimeZone returns mismatch.");
367 delete tzTokyo
; // tzCalif was owned by dtitvfmt which should have deleted it
371 errln("ERROR: DateIntervalFormat::createInstance(\"MdHH\", Locale::getEnglish(), ...), status %s", u_errorName(status
));
373 //====== test format in testFormat()
375 //====== test DateInterval class (better coverage)
376 DateInterval
dtitv1(3600*24*365, 3600*24*366);
377 DateInterval
dtitv2(dtitv1
);
379 if (!(dtitv1
== dtitv2
)) {
380 errln("ERROR: Copy constructor failed for DateInterval.");
383 DateInterval
dtitv3(3600*365, 3600*366);
385 if (!(dtitv3
== dtitv1
)) {
386 errln("ERROR: Equal operator failed for DateInterval.");
389 DateInterval
*dtitv4
= dtitv1
.clone();
390 if (*dtitv4
!= dtitv1
) {
391 errln("ERROR: Equal operator failed for DateInterval.");
400 void DateIntervalFormatTest::testFormat() {
401 // first item is date pattern
402 // followed by a group of locale/from_data/to_data/skeleton/interval_data
403 const char* DATA
[] = {
404 "yyyy MM dd HH:mm:ss",
406 "root", "2007 11 10 10:10:10", "2007 12 10 10:10:10", "yM", "2007-11 \\u2013 2007-12",
408 // test 'H' and 'h', using availableFormat in fallback
409 "en", "2007 11 10 10:10:10", "2007 11 10 15:10:10", "Hms", "10:10:10 - 15:10:10",
410 "en", "2007 11 10 10:10:10", "2007 11 10 15:10:10", "hms", "10:10:10 AM - 3:10:10 PM",
412 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMM", "October 2007 - October 2008",
413 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMM", "Oct 2007 - Oct 2008",
414 // test skeleton with both date and time
415 "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",
417 "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 - 11:10 AM",
419 "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "hms", "10:10:10 AM - 11:10:10 AM",
420 "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "Hms", "10:10:10 - 11:10:10",
421 "en", "2007 11 10 20:10:10", "2007 11 10 21:10:10", "Hms", "20:10:10 - 21:10:10",
423 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10, 2007 - Friday, October 10, 2008",
425 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMy", "October 10, 2007 - October 10, 2008",
427 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMM", "October 10, 2007 - October 10, 2008",
429 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMMy", "October 2007 - October 2008",
431 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMM", "Wednesday, October 10, 2007 - Friday, October 10, 2008",
433 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMMy", "Wed, Oct 10, 2007 - Fri, Oct 10, 2008",
435 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMy", "Oct 10, 2007 - Oct 10, 2008",
437 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "Oct 10, 2007 - Oct 10, 2008",
439 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Oct 2007 - Oct 2008",
441 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMM", "Wed, Oct 10, 2007 - Fri, Oct 10, 2008",
443 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Wed, 10/10/2007 - Fri, 10/10/2008",
445 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10/10/2007 - 10/10/2008",
447 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dM", "10/10/2007 - 10/10/2008",
449 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10/2007 - 10/2008",
451 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Wed, 10/10/2007 - Fri, 10/10/2008",
453 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "d", "10/10/2007 - 10/10/2008",
455 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Ed", "10 Wed - 10 Fri",
457 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007 - 2008",
459 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10/2007 - 10/2008",
463 "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",
464 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Hm", "10/10/2007, 10:10 - 10/10/2008, 10:10",
465 "en", "2007 10 10 20:10:10", "2008 10 10 20:10:10", "Hm", "10/10/2007, 20:10 - 10/10/2008, 20:10",
467 "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",
469 "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",
471 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "h", "10/10/2007, 10 AM - 10/10/2008, 10 AM",
473 "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",
475 "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",
477 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 - Fri, 10/10/2008",
479 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EddMMy", "Wed, 10/10/2007 - Fri, 10/10/2008",
481 "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",
483 "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",
485 "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",
487 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMMy", "O 10, 2007 - O 10, 2008",
489 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEEdM", "W, 10/10/2007 - F, 10/10/2008",
491 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10 - Saturday, November 10, 2007",
493 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMy", "October 10 - November 10, 2007",
495 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMM", "October 10 - November 10",
497 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "October - November 2007",
499 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMM", "Wednesday, October 10 - Saturday, November 10",
501 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMMy", "Wed, Oct 10 - Sat, Nov 10, 2007",
503 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMy", "Oct 10 - Nov 10, 2007",
505 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "Oct 10 - Nov 10",
507 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Oct - Nov 2007",
509 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMM", "Wed, Oct 10 - Sat, Nov 10",
511 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMy", "Wed, 10/10/2007 - Sat, 11/10/2007",
513 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMy", "10/10/2007 - 11/10/2007",
516 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10/2007 - 11/2007",
518 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdM", "Wed, 10/10 - Sat, 11/10",
520 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10/10 - 11/10",
522 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Ed", "10 Wed - 10 Sat",
524 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "y", "2007",
526 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "M", "10 - 11",
528 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Oct - Nov",
530 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMM", "October - November",
532 "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",
533 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Hm", "10/10/2007, 10:10 - 11/10/2007, 10:10",
534 "en", "2007 10 10 20:10:10", "2007 11 10 20:10:10", "Hm", "10/10/2007, 20:10 - 11/10/2007, 20:10",
536 "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",
538 "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",
540 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "h", "10/10/2007, 10 AM - 11/10/2007, 10 AM",
542 "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",
544 "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",
546 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 - Sat, 11/10/2007",
548 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EddMMy", "Wed, 10/10/2007 - Sat, 11/10/2007",
551 "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",
553 "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",
555 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMMy", "O 10 - N 10, 2007",
557 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEEdM", "W, 10/10 - S, 11/10",
559 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMMy", "Saturday, November 10 - Tuesday, November 20, 2007",
561 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMy", "November 10 - 20, 2007",
563 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMM", "November 10 - 20",
566 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMM", "Saturday, November 10 - Tuesday, November 20",
568 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMMy", "Sat, Nov 10 - Tue, Nov 20, 2007",
570 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMy", "Nov 10 - 20, 2007",
572 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMM", "Nov 10 - 20",
574 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov 2007",
576 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMM", "Sat, Nov 10 - Tue, Nov 20",
578 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sat, 11/10/2007 - Tue, 11/20/2007",
580 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "11/10/2007 - 11/20/2007",
582 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 - 11/20",
584 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "11/2007",
586 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "Sat, 11/10 - Tue, 11/20",
588 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10 - 20",
590 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Ed", "10 Sat - 20 Tue",
592 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007",
594 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11",
596 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "Nov",
598 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMM", "November",
600 "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",
601 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Hm", "11/10/2007, 10:10 - 11/20/2007, 10:10",
602 "en", "2007 11 10 20:10:10", "2007 11 20 20:10:10", "Hm", "11/10/2007, 20:10 - 11/20/2007, 20:10",
604 "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",
606 "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",
608 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "h", "11/10/2007, 10 AM - 11/20/2007, 10 AM",
610 "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",
612 "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",
614 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEddMMyyyy", "Sat, 11/10/2007 - Tue, 11/20/2007",
616 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EddMMy", "Sat, 11/10/2007 - Tue, 11/20/2007",
618 "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",
620 "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",
622 "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",
623 "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",
624 "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",
626 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMMy", "N 10 - 20, 2007",
628 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEEdM", "S, 11/10 - T, 11/20",
630 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "Wednesday, January 10, 2007",
632 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMMy", "January 10, 2007",
634 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMM", "January 10",
636 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMMy", "January 2007",
638 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMM", "Wednesday, January 10",
640 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdMMMy", "Wed, Jan 10, 2007",
642 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMy", "Jan 10, 2007",
644 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "Jan 10",
646 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan 2007",
648 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdMMM", "Wed, Jan 10",
651 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMy", "1/10/2007",
653 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dM", "1/10",
655 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "My", "1/2007",
657 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdM", "Wed, 1/10",
659 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "d", "10",
661 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Ed", "10 Wed",
663 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "y", "2007",
665 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "M", "1",
667 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMM", "Jan",
669 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMM", "January",
671 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "10:00 AM - 2:10 PM",
672 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Hm", "10:00 - 14:10",
674 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmv", "10:00 AM - 2:10 PM PT",
676 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "10:00 AM - 2:10 PM PST",
678 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 AM - 2 PM",
679 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "H", "10 - 14",
682 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hz", "10 AM - 2 PM PST",
684 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEddMMyyyy", "Wed, 01/10/2007",
686 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EddMMy", "Wed, 01/10/2007",
688 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hhmm", "10:00 AM - 2:10 PM",
689 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "HHmm", "10:00 - 14:10",
691 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hhmmzz", "10:00 AM - 2:10 PM PST",
693 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hms", "10:00:10 AM - 2:10:10 PM",
694 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Hms", "10:00:10 - 14:10:10",
696 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMMMy", "J 10, 2007",
698 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEEdM", "W, 1/10",
699 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMMy", "January 10, 2007",
701 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMM", "January 10",
703 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "MMMMy", "January 2007",
705 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMMM", "Wednesday, January 10",
707 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMMMy", "Wed, Jan 10, 2007",
709 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMy", "Jan 10, 2007",
711 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMM", "Jan 10",
714 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMMM", "Wed, Jan 10",
716 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMy", "Wed, 1/10/2007",
718 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMy", "1/10/2007",
721 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "My", "1/2007",
723 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdM", "Wed, 1/10",
725 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "d", "10",
728 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "y", "2007",
730 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "M", "1",
734 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "10:00 - 10:20 AM",
735 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "Hm", "10:00 - 10:20",
738 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmz", "10:00 - 10:20 AM PST",
741 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hv", "10 AM PT",
745 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EddMMy", "Wed, 01/10/2007",
747 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hhmm", "10:00 - 10:20 AM",
748 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "HHmm", "10:00 - 10:20",
750 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hhmmzz", "10:00 - 10:20 AM PST",
753 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMMMy", "J 10, 2007",
756 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMMy", "Wednesday, January 10, 2007",
758 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMMMy", "January 10, 2007",
761 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "MMMMy", "January 2007",
763 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMM", "Wednesday, January 10",
766 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMMy", "Jan 10, 2007",
768 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMM", "Jan 10",
771 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdMMM", "Wed, Jan 10",
773 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdMy", "Wed, 1/10/2007",
775 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMy", "1/10/2007",
778 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "My", "1/2007",
780 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdM", "Wed, 1/10",
782 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "d", "10",
785 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "y", "2007",
787 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "M", "1",
790 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "MMMM", "January",
792 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "10:10 AM",
793 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Hm", "10:10",
796 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 AM PST",
798 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "10 AM",
800 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hv", "10 AM PT",
803 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEddMMyyyy", "Wed, 01/10/2007",
806 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hhmm", "10:10 AM",
807 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "HHmm", "10:10",
809 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hhmmzz", "10:10 AM PST",
812 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMMMMy", "J 10, 2007",
814 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEEdM", "W, 1/10",
816 "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",
819 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMy", "2007\\u5e7410\\u670810\\u65e5\\u81f311\\u670810\\u65e5",
822 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "2007\\u5e7410\\u6708\\u81f311\\u6708",
825 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "2007/10/10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4 \\u4E0A\\u534810:10 \\u2013 2007/11/10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4 \\u4E0A\\u534810:10",
827 "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",
830 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMM", "11\\u670810\\u65e5\\u81f320\\u65e5",
832 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMMy", "2007\\u5E7411\\u6708", // (fixed expected result per ticket:6626:)
834 "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",
837 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "2007/11/10\\u5468\\u516d\\u81f32007/11/20\\u5468\\u4e8c",
840 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 \\u2013 11/20",
842 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "2007\\u5E7411\\u6708",
844 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "11/10\\u5468\\u516d\\u81f311/20\\u5468\\u4e8c",
847 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007\\u5E74", // (fixed expected result per ticket:6626:)
849 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11\\u6708",
851 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "11\\u6708", // (fixed expected result per ticket:6626: and others)
854 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "2007/11/10 GMT-8 \\u4e0a\\u534810:10 \\u2013 2007/11/20 GMT-8 \\u4e0a\\u534810:10",
856 "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",
858 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "2007\\u5e741\\u670810\\u65e5 \\u661f\\u671f\\u4e09", // (fixed expected result per ticket:6626:)
860 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10",
863 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "GMT-8\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10",
865 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "\\u4e0a\\u534810\\u65F6\\u81f3\\u4e0b\\u53482\\u65f6",
867 "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",
869 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "\\u4e0a\\u534810:00\\u81f310:20",
871 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:00\\u81F310:20",
873 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "GMT-8\\u4e0a\\u534810\\u65f6",
875 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "\\u4e0a\\u534810:10",
877 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "\\u4e0a\\u534810\\u65f6",
879 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. 2007 \\u2013 Freitag, 10. Okt. 2008",
882 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "10. Okt. 2007 \\u2013 10. Okt. 2008",
884 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Okt. 2007 \\u2013 Okt. 2008",
887 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Mi., 10.10.2007 \\u2013 Fr., 10.10.2008",
889 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10.10.2007 \\u2013 10.10.2008",
892 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10.2007 \\u2013 10.2008",
894 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Mi., 10.10.2007 \\u2013 Fr., 10.10.2008",
897 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007\\u20132008",
899 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10.2007 \\u2013 10.2008",
902 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10.10.2007, 10:10 vorm. \\u2013 10.10.2008, 10:10 vorm.",
903 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Hm", "10.10.2007, 10:10 \\u2013 10.10.2008, 10:10",
905 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. \\u2013 Samstag, 10. Nov. 2007",
908 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "10. Okt. \\u2013 10. Nov.",
910 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Okt.\\u2013Nov. 2007",
912 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMM", "Mittwoch, 10. Okt. \\u2013 Samstag, 10. Nov.",
915 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dM", "10.10. \\u2013 10.11.",
917 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10.2007 \\u2013 11.2007",
920 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10.10. \\u2013 10.11.",
922 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "y", "2007",
925 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Okt.\\u2013Nov.",
928 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10.10.2007, 10:10:10 vorm. \\u2013 10.11.2007, 10:10:10 vorm.",
929 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Hms", "10.10.2007, 10:10:10 \\u2013 10.11.2007, 10:10:10",
931 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMy", "Samstag, 10. \\u2013 Dienstag, 20. Nov. 2007",
933 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMy", "10.\\u201320. Nov. 2007",
936 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov. 2007",
938 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMM", "Samstag, 10. \\u2013 Dienstag, 20. Nov.",
940 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sa., 10.11.2007 \\u2013 Di., 20.11.2007",
943 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "10.11. \\u2013 20.11.",
945 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "11.2007",
948 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10.\\u201320.",
950 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007",
953 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "10.11.2007, 10:10 vorm. Los Angeles Zeit \\u2013 20.11.2007, 10:10 vorm. Los Angeles Zeit",
955 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007",
958 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "10. Jan.",
960 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan. 2007",
962 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMM", "Mittwoch, 10. Jan.",
965 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 vorm. \\u2013 2 nachm.",
966 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "H", "10\\u201314 Uhr",
968 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMM", "Mittwoch, 10. Jan.",
971 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "10:00\\u201310:20 vorm. Los Angeles Zeit",
973 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmz", "10:00\\u201310:20 vorm. GMT-8",
975 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "10 vorm.",
976 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "H", "10 Uhr",
979 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "10 vorm. GMT-8",
981 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007",
984 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmv", "10:10 vorm. Los Angeles Zeit",
986 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 vorm. GMT-8",
989 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hv", "10 vorm. Los Angeles Zeit",
991 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hz", "10 vorm. GMT-8",
993 // Thai (default calendar buddhist)
995 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E1E\\u0E38\\u0E18\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. 2550 \\u2013 \\u0E27\\u0E31\\u0E19\\u0E28\\u0E38\\u0E01\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. 2551",
998 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMMM", "10 \\u0E15.\\u0E04. 2550 \\u2013 10 \\u0E15.\\u0E04. 2551",
1000 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "MMMy", "\\u0E15.\\u0E04. 2550 \\u2013 \\u0E15.\\u0E04. 2551",
1003 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdMy", "\\u0E1E. 10/10/2550 \\u2013 \\u0E28. 10/10/2551",
1005 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMy", "10/10/2550 \\u2013 10/10/2551",
1008 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "My", "10/2550 \\u2013 10/2551",
1010 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdM", "\\u0E1E. 10/10/2550 \\u2013 \\u0E28. 10/10/2551",
1013 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "y", "2550\\u20132551",
1015 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "M", "10/2550 \\u2013 10/2551",
1018 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E1E\\u0E38\\u0E18\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. \\u2013 \\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48 10 \\u0E1E.\\u0E22. 2550",
1021 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dMMM", "10 \\u0E15.\\u0E04. \\u2013 10 \\u0E1E.\\u0E22.",
1023 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "MMMy", "\\u0E15.\\u0E04.\\u2013\\u0E1E.\\u0E22. 2550",
1025 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dM", "10/10 \\u2013 10/11",
1027 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "My", "10/2550 \\u2013 11/2550",
1030 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "d", "10/10 \\u2013 10/11",
1032 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "y", "\\u0E1E.\\u0E28. 2550",
1035 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "MMM", "\\u0E15.\\u0E04.\\u2013\\u0E1E.\\u0E22.",
1038 expect(DATA
, ARRAY_SIZE(DATA
));
1042 void DateIntervalFormatTest::expect(const char** data
, int32_t data_length
) {
1044 UErrorCode ec
= U_ZERO_ERROR
;
1045 UnicodeString str
, str2
;
1046 const char* pattern
= data
[0];
1049 #ifdef DTIFMTTS_DEBUG
1052 sprintf(mesg
, "locale: %s\n", locName
);
1056 while (i
<data_length
) {
1057 const char* locName
= data
[i
++];
1058 Locale
loc(locName
);
1059 SimpleDateFormat
ref(pattern
, loc
, ec
);
1060 if (U_FAILURE(ec
)) {
1061 dataerrln("contruct SimpleDateFormat in expect failed: %s", u_errorName(ec
));
1065 const char* datestr
= data
[i
++];
1066 const char* datestr_2
= data
[i
++];
1067 #ifdef DTIFMTTS_DEBUG
1068 sprintf(mesg
, "original date: %s - %s\n", datestr
, datestr_2
);
1071 UDate date
= ref
.parse(ctou(datestr
), ec
);
1072 if (!assertSuccess("parse 1st data in expect", ec
)) return;
1073 UDate date_2
= ref
.parse(ctou(datestr_2
), ec
);
1074 if (!assertSuccess("parse 2nd data in expect", ec
)) return;
1075 DateInterval
dtitv(date
, date_2
);
1077 const UnicodeString
& oneSkeleton
= data
[i
++];
1079 DateIntervalFormat
* dtitvfmt
= DateIntervalFormat::createInstance(oneSkeleton
, loc
, ec
);
1080 if (!assertSuccess("createInstance(skeleton) in expect", ec
)) return;
1081 FieldPosition pos
=0;
1082 dtitvfmt
->format(&dtitv
, str
.remove(), pos
, ec
);
1083 if (!assertSuccess("format in expect", ec
)) return;
1084 assertEquals((UnicodeString
)"\"" + locName
+ "\\" + oneSkeleton
+ "\\" + datestr
+ "\\" + datestr_2
+ "\"", ctou(data
[i
++]), str
);
1088 #ifdef DTIFMTTS_DEBUG
1089 str
.extract(0, str
.length(), result
, "UTF-8");
1090 sprintf(mesg
, "interval date: %s\n", result
);
1093 std::cout
<< "\"" << locName
<< "\", "
1094 << "\"" << datestr
<< "\", "
1095 << "\"" << datestr_2
<< "\", ";
1096 printUnicodeString(oneSkeleton
);
1097 printUnicodeString(str
);
1098 std::cout
<< "\n\n";
1106 * Test format using user defined DateIntervalInfo
1108 void DateIntervalFormatTest::testFormatUserDII() {
1109 // first item is date pattern
1110 const char* DATA
[] = {
1111 "yyyy MM dd HH:mm:ss",
1112 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Oct 10, 2007 --- Oct 10, 2008",
1114 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 Oct 10 - Nov 2007",
1116 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Nov 10, 2007 --- Nov 20, 2007",
1118 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Jan 10, 2007",
1120 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "Jan 10, 2007",
1122 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Jan 10, 2007",
1124 "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "2007\\u5e7410\\u670810\\u65e5 --- 2008\\u5e7410\\u670810\\u65e5",
1126 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 10\\u6708 10 - 11\\u6708 2007",
1128 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007\\u5e7411\\u670810\\u65e5 --- 2007\\u5e7411\\u670820\\u65e5",
1130 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket:6626:)
1132 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket:6626:)
1134 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket:6626:)
1136 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10. Okt. 2007 --- 10. Okt. 2008",
1139 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10. Nov. 2007 --- 20. Nov. 2007",
1141 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10. Jan. 2007",
1143 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10. Jan. 2007",
1146 "es", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10 oct 2007 --- 10 oct 2008",
1148 "es", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 oct 10 - nov 2007",
1150 "es", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10 nov 2007 --- 20 nov 2007",
1152 "es", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10 ene 2007",
1154 "es", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10 ene 2007",
1156 "es", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "10 ene 2007",
1158 expectUserDII(DATA
, ARRAY_SIZE(DATA
));
1162 void DateIntervalFormatTest::testSetIntervalPatternNoSideEffect() {
1163 UErrorCode ec
= U_ZERO_ERROR
;
1164 LocalPointer
<DateIntervalInfo
> dtitvinf(new DateIntervalInfo(ec
), ec
);
1165 if (U_FAILURE(ec
)) {
1166 errln("Failure encountered: %s", u_errorName(ec
));
1169 UnicodeString expected
;
1170 dtitvinf
->getIntervalPattern(ctou("yMd"), UCAL_DATE
, expected
, ec
);
1171 dtitvinf
->setIntervalPattern(ctou("yMd"), UCAL_DATE
, ctou("M/d/y \\u2013 d"), ec
);
1172 if (U_FAILURE(ec
)) {
1173 errln("Failure encountered: %s", u_errorName(ec
));
1176 dtitvinf
.adoptInsteadAndCheckErrorCode(new DateIntervalInfo(ec
), ec
);
1177 if (U_FAILURE(ec
)) {
1178 errln("Failure encountered: %s", u_errorName(ec
));
1181 UnicodeString actual
;
1182 dtitvinf
->getIntervalPattern(ctou("yMd"), UCAL_DATE
, actual
, ec
);
1183 if (U_FAILURE(ec
)) {
1184 errln("Failure encountered: %s", u_errorName(ec
));
1187 if (expected
!= actual
) {
1188 errln("DateIntervalInfo.setIntervalPattern should have no side effects.");
1192 void DateIntervalFormatTest::testYearFormats() {
1193 const Locale
&enLocale
= Locale::getEnglish();
1194 UErrorCode status
= U_ZERO_ERROR
;
1195 LocalPointer
<Calendar
> fromTime(Calendar::createInstance(enLocale
, status
));
1196 LocalPointer
<Calendar
> toTime(Calendar::createInstance(enLocale
, status
));
1197 if (U_FAILURE(status
)) {
1198 errln("Failure encountered: %s", u_errorName(status
));
1201 // April 26, 113. Three digit year so that we can test 2 digit years;
1202 // 4 digit years with padded 0's and full years.
1203 fromTime
->set(113, 3, 26);
1205 toTime
->set(113, 3, 28);
1207 LocalPointer
<DateIntervalFormat
> dif(DateIntervalFormat::createInstance("yyyyMd", enLocale
, status
));
1208 if (U_FAILURE(status
)) {
1209 dataerrln("Failure encountered: %s", u_errorName(status
));
1212 UnicodeString actual
;
1213 UnicodeString
expected(ctou("4/26/0113 - 4/28/0113"));
1214 FieldPosition pos
= 0;
1215 dif
->format(*fromTime
, *toTime
, actual
, pos
, status
);
1216 if (U_FAILURE(status
)) {
1217 errln("Failure encountered: %s", u_errorName(status
));
1220 if (actual
!= expected
) {
1221 errln("Expected " + expected
+ ", got: " + actual
);
1225 LocalPointer
<DateIntervalFormat
> dif(DateIntervalFormat::createInstance("yyMd", enLocale
, status
));
1226 if (U_FAILURE(status
)) {
1227 errln("Failure encountered: %s", u_errorName(status
));
1230 UnicodeString actual
;
1231 UnicodeString
expected(ctou("4/26/13 - 4/28/13"));
1232 FieldPosition pos
= 0;
1233 dif
->format(*fromTime
, *toTime
, actual
, pos
, status
);
1234 if (U_FAILURE(status
)) {
1235 errln("Failure encountered: %s", u_errorName(status
));
1238 if (actual
!= expected
) {
1239 errln("Expected " + expected
+ ", got: " + actual
);
1243 LocalPointer
<DateIntervalFormat
> dif(DateIntervalFormat::createInstance("yMd", enLocale
, status
));
1244 if (U_FAILURE(status
)) {
1245 errln("Failure encountered: %s", u_errorName(status
));
1248 UnicodeString actual
;
1249 UnicodeString
expected(ctou("4/26/113 - 4/28/113"));
1250 FieldPosition pos
= 0;
1251 dif
->format(*fromTime
, *toTime
, actual
, pos
, status
);
1252 if (U_FAILURE(status
)) {
1253 errln("Failure encountered: %s", u_errorName(status
));
1256 if (actual
!= expected
) {
1257 errln("Expected " + expected
+ ", got: " + actual
);
1262 void DateIntervalFormatTest::expectUserDII(const char** data
,
1263 int32_t data_length
) {
1266 UErrorCode ec
= U_ZERO_ERROR
;
1267 const char* pattern
= data
[0];
1270 while ( i
< data_length
) {
1271 const char* locName
= data
[i
++];
1272 Locale
loc(locName
);
1273 SimpleDateFormat
ref(pattern
, loc
, ec
);
1274 if (U_FAILURE(ec
)) {
1275 dataerrln("contruct SimpleDateFormat in expectUserDII failed: %s", u_errorName(ec
));
1278 const char* datestr
= data
[i
++];
1279 const char* datestr_2
= data
[i
++];
1280 UDate date
= ref
.parse(ctou(datestr
), ec
);
1281 if (!assertSuccess("parse in expectUserDII", ec
)) return;
1282 UDate date_2
= ref
.parse(ctou(datestr_2
), ec
);
1283 if (!assertSuccess("parse in expectUserDII", ec
)) return;
1284 DateInterval
dtitv(date
, date_2
);
1287 // test user created DateIntervalInfo
1288 DateIntervalInfo
* dtitvinf
= new DateIntervalInfo(ec
);
1289 dtitvinf
->setFallbackIntervalPattern("{0} --- {1}", ec
);
1290 dtitvinf
->setIntervalPattern(UDAT_YEAR_ABBR_MONTH_DAY
, UCAL_MONTH
, "yyyy MMM d - MMM y",ec
);
1291 if (!assertSuccess("DateIntervalInfo::setIntervalPattern", ec
)) return;
1292 dtitvinf
->setIntervalPattern(UDAT_YEAR_ABBR_MONTH_DAY
, UCAL_HOUR_OF_DAY
, "yyyy MMM d HH:mm - HH:mm", ec
);
1293 if (!assertSuccess("DateIntervalInfo::setIntervalPattern", ec
)) return;
1294 DateIntervalFormat
* dtitvfmt
= DateIntervalFormat::createInstance(UDAT_YEAR_ABBR_MONTH_DAY
, loc
, *dtitvinf
, ec
);
1296 if (!assertSuccess("createInstance(skeleton,dtitvinf) in expectUserDII", ec
)) return;
1297 FieldPosition pos
=0;
1298 dtitvfmt
->format(&dtitv
, str
.remove(), pos
, ec
);
1299 if (!assertSuccess("format in expectUserDII", ec
)) return;
1300 assertEquals((UnicodeString
)"\"" + locName
+ "\\" + datestr
+ "\\" + datestr_2
+ "\"", ctou(data
[i
++]), str
);
1301 #ifdef DTIFMTTS_DEBUG
1304 PRINTMESG("interval format using user defined DateIntervalInfo\n");
1305 str
.extract(0, str
.length(), result
, "UTF-8");
1306 sprintf(mesg
, "interval date: %s\n", result
);
1314 void DateIntervalFormatTest::testStress() {
1316 logln("Quick mode: Skipping test");
1319 const char* DATA
[] = {
1320 "yyyy MM dd HH:mm:ss",
1321 "2007 10 10 10:10:10", "2008 10 10 10:10:10",
1322 "2007 10 10 10:10:10", "2007 11 10 10:10:10",
1323 "2007 11 10 10:10:10", "2007 11 20 10:10:10",
1324 "2007 01 10 10:00:10", "2007 01 10 14:10:10",
1325 "2007 01 10 10:00:10", "2007 01 10 10:20:10",
1326 "2007 01 10 10:10:10", "2007 01 10 10:10:20",
1329 const char* testLocale
[][3] = {
1371 uint32_t localeIndex
;
1372 for ( localeIndex
= 0; localeIndex
< ARRAY_SIZE(testLocale
); ++localeIndex
) {
1374 uprv_strcpy(locName
, testLocale
[localeIndex
][0]);
1375 uprv_strcat(locName
, testLocale
[localeIndex
][1]);
1376 stress(DATA
, ARRAY_SIZE(DATA
), Locale(testLocale
[localeIndex
][0], testLocale
[localeIndex
][1], testLocale
[localeIndex
][2]), locName
);
1381 void DateIntervalFormatTest::stress(const char** data
, int32_t data_length
,
1382 const Locale
& loc
, const char* locName
) {
1383 UnicodeString skeleton
[] = {
1411 "EEddMMyyyy", // following could be normalized
1415 "hms", // following could not be normalized
1421 UErrorCode ec
= U_ZERO_ERROR
;
1422 UnicodeString str
, str2
;
1423 SimpleDateFormat
ref(data
[i
++], loc
, ec
);
1424 if (!assertSuccess("construct SimpleDateFormat", ec
)) return;
1426 #ifdef DTIFMTTS_DEBUG
1429 sprintf(mesg
, "locale: %s\n", locName
);
1433 while (i
<data_length
) {
1436 const char* datestr
= data
[i
++];
1437 const char* datestr_2
= data
[i
++];
1438 #ifdef DTIFMTTS_DEBUG
1439 sprintf(mesg
, "original date: %s - %s\n", datestr
, datestr_2
);
1442 UDate date
= ref
.parse(ctou(datestr
), ec
);
1443 if (!assertSuccess("parse", ec
)) return;
1444 UDate date_2
= ref
.parse(ctou(datestr_2
), ec
);
1445 if (!assertSuccess("parse", ec
)) return;
1446 DateInterval
dtitv(date
, date_2
);
1448 for ( uint32_t skeletonIndex
= 0;
1449 skeletonIndex
< ARRAY_SIZE(skeleton
);
1451 const UnicodeString
& oneSkeleton
= skeleton
[skeletonIndex
];
1452 DateIntervalFormat
* dtitvfmt
= DateIntervalFormat::createInstance(oneSkeleton
, loc
, ec
);
1453 if (!assertSuccess("createInstance(skeleton)", ec
)) return;
1455 // reset the calendar to be Gregorian calendar for "th"
1456 if ( uprv_strcmp(locName, "th") == 0 ) {
1457 GregorianCalendar* gregCal = new GregorianCalendar(loc, ec);
1458 if (!assertSuccess("GregorianCalendar()", ec)) return;
1459 const DateFormat* dformat = dtitvfmt->getDateFormat();
1460 DateFormat* newOne = (DateFormat*)dformat->clone();
1461 newOne->adoptCalendar(gregCal);
1462 //dtitvfmt->adoptDateFormat(newOne, ec);
1463 dtitvfmt->setDateFormat(*newOne, ec);
1465 if (!assertSuccess("adoptDateFormat()", ec)) return;
1468 FieldPosition pos
=0;
1469 dtitvfmt
->format(&dtitv
, str
.remove(), pos
, ec
);
1470 if (!assertSuccess("format", ec
)) return;
1471 #ifdef DTIFMTTS_DEBUG
1472 oneSkeleton
.extract(0, oneSkeleton
.length(), result
, "UTF-8");
1473 sprintf(mesg
, "interval by skeleton: %s\n", result
);
1475 str
.extract(0, str
.length(), result
, "UTF-8");
1476 sprintf(mesg
, "interval date: %s\n", result
);
1482 // test user created DateIntervalInfo
1484 DateIntervalInfo
* dtitvinf
= new DateIntervalInfo(ec
);
1485 dtitvinf
->setFallbackIntervalPattern("{0} --- {1}", ec
);
1486 dtitvinf
->setIntervalPattern(UDAT_YEAR_ABBR_MONTH_DAY
, UCAL_MONTH
, "yyyy MMM d - MMM y",ec
);
1487 if (!assertSuccess("DateIntervalInfo::setIntervalPattern", ec
)) return;
1488 dtitvinf
->setIntervalPattern(UDAT_YEAR_ABBR_MONTH_DAY
, UCAL_HOUR_OF_DAY
, "yyyy MMM d HH:mm - HH:mm", ec
);
1489 if (!assertSuccess("DateIntervalInfo::setIntervalPattern", ec
)) return;
1490 DateIntervalFormat
* dtitvfmt
= DateIntervalFormat::createInstance(UDAT_YEAR_ABBR_MONTH_DAY
, loc
, *dtitvinf
, ec
);
1492 if (!assertSuccess("createInstance(skeleton,dtitvinf)", ec
)) return;
1493 FieldPosition pos
=0;
1494 dtitvfmt
->format(&dtitv
, str
.remove(), pos
, ec
);
1495 if ( uprv_strcmp(locName
, "th") ) {
1496 if (!assertSuccess("format", ec
)) return;
1497 #ifdef DTIFMTTS_DEBUG
1498 PRINTMESG("interval format using user defined DateIntervalInfo\n");
1499 str
.extract(0, str
.length(), result
, "UTF-8");
1500 sprintf(mesg
, "interval date: %s\n", result
);
1504 // for "th", the default calendar is Budhist,
1506 assertTrue("Default calendar for \"th\" is Budhist", ec
== U_ILLEGAL_ARGUMENT_ERROR
);
1513 void DateIntervalFormatTest::testTicket11583_2() {
1514 UErrorCode status
= U_ZERO_ERROR
;
1515 LocalPointer
<DateIntervalFormat
> fmt(
1516 DateIntervalFormat::createInstance("yMMM", "es-US", status
));
1517 if (!assertSuccess("Error create format object", status
)) {
1520 DateInterval
interval((UDate
) 1232364615000.0, (UDate
) 1328787015000.0);
1521 UnicodeString appendTo
;
1522 FieldPosition
fpos(FieldPosition::DONT_CARE
);
1523 UnicodeString
expected("ene de 2009 \\u2013 feb de 2012");
1526 expected
.unescape(),
1527 fmt
->format(&interval
, appendTo
, fpos
, status
));
1528 if (!assertSuccess("Error formatting", status
)) {
1533 #endif /* #if !UCONFIG_NO_FORMATTING */