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