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