]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/dtfmttst.cpp
ICU-491.11.2.tar.gz
[apple/icu.git] / icuSources / test / intltest / dtfmttst.cpp
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2012, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************/
6
7 #include "unicode/utypes.h"
8
9 #if !UCONFIG_NO_FORMATTING
10
11 #include "dtfmttst.h"
12 #include "unicode/timezone.h"
13 #include "unicode/gregocal.h"
14 #include "unicode/smpdtfmt.h"
15 #include "unicode/datefmt.h"
16 #include "unicode/simpletz.h"
17 #include "unicode/strenum.h"
18 #include "unicode/dtfmtsym.h"
19 #include "cmemory.h"
20 #include "cstring.h"
21 #include "caltest.h" // for fieldName
22 #include <stdio.h> // for sprintf
23
24 #if U_PLATFORM_HAS_WIN32_API
25 #include "windttst.h"
26 #endif
27
28 #define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
29
30 #define ASSERT_OK(status) if(U_FAILURE(status)) {errcheckln(status, #status " = %s @ %s:%d", u_errorName(status), __FILE__, __LINE__); return; }
31
32 // *****************************************************************************
33 // class DateFormatTest
34 // *****************************************************************************
35
36 void DateFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
37 {
38 // if (exec) logln((UnicodeString)"TestSuite DateFormatTest");
39 switch (index) {
40 TESTCASE(0,TestEquals);
41 TESTCASE(1,TestTwoDigitYearDSTParse);
42 TESTCASE(2,TestFieldPosition);
43 TESTCASE(3,TestPartialParse994);
44 TESTCASE(4,TestRunTogetherPattern985);
45 TESTCASE(5,TestRunTogetherPattern917);
46 TESTCASE(6,TestCzechMonths459);
47 TESTCASE(7,TestLetterDPattern212);
48 TESTCASE(8,TestDayOfYearPattern195);
49 TESTCASE(9,TestQuotePattern161);
50 TESTCASE(10,TestBadInput135);
51 TESTCASE(11,TestBadInput135a);
52 TESTCASE(12,TestTwoDigitYear);
53 TESTCASE(13,TestDateFormatZone061);
54 TESTCASE(14,TestDateFormatZone146);
55 TESTCASE(15,TestLocaleDateFormat);
56 TESTCASE(16,TestWallyWedel);
57 TESTCASE(17,TestDateFormatCalendar);
58 TESTCASE(18,TestSpaceParsing);
59 TESTCASE(19,TestExactCountFormat);
60 TESTCASE(20,TestWhiteSpaceParsing);
61 TESTCASE(21,TestInvalidPattern);
62 TESTCASE(22,TestGeneral);
63 TESTCASE(23,TestGreekMay);
64 TESTCASE(24,TestGenericTime);
65 TESTCASE(25,TestGenericTimeZoneOrder);
66 TESTCASE(26,TestHost);
67 TESTCASE(27,TestEras);
68 TESTCASE(28,TestNarrowNames);
69 TESTCASE(29,TestStandAloneDays);
70 TESTCASE(30,TestStandAloneMonths);
71 TESTCASE(31,TestQuarters);
72 TESTCASE(32,TestZTimeZoneParsing);
73 TESTCASE(33,TestRelative);
74 TESTCASE(34,TestRelativeClone);
75 TESTCASE(35,TestHostClone);
76 TESTCASE(36,TestTimeZoneDisplayName);
77 TESTCASE(37,TestRoundtripWithCalendar);
78 TESTCASE(38,Test6338);
79 TESTCASE(39,Test6726);
80 TESTCASE(40,TestGMTParsing);
81 TESTCASE(41,Test6880);
82 TESTCASE(42,TestISOEra);
83 TESTCASE(43,TestFormalChineseDate);
84 TESTCASE(44,TestNumberAsStringParsing);
85 TESTCASE(45,TestStandAloneGMTParse);
86 TESTCASE(46,TestParsePosition);
87 TESTCASE(47,TestMonthPatterns);
88 TESTCASE(48,TestContext);
89 /*
90 TESTCASE(49,TestRelativeError);
91 TESTCASE(50,TestRelativeOther);
92 */
93 default: name = ""; break;
94 }
95 }
96
97 // Test written by Wally Wedel and emailed to me.
98 void DateFormatTest::TestWallyWedel()
99 {
100 UErrorCode status = U_ZERO_ERROR;
101 /*
102 * Instantiate a TimeZone so we can get the ids.
103 */
104 TimeZone *tz = new SimpleTimeZone(7,"");
105 /*
106 * Computational variables.
107 */
108 int32_t offset, hours, minutes, seconds;
109 /*
110 * Instantiate a SimpleDateFormat set up to produce a full time
111 zone name.
112 */
113 SimpleDateFormat *sdf = new SimpleDateFormat((UnicodeString)"zzzz", status);
114 /*
115 * A String array for the time zone ids.
116 */
117 int32_t ids_length;
118 StringEnumeration* ids = TimeZone::createEnumeration();
119 if (ids == NULL) {
120 dataerrln("Unable to create TimeZone enumeration.");
121 if (sdf != NULL) {
122 delete sdf;
123 }
124 return;
125 }
126 ids_length = ids->count(status);
127 /*
128 * How many ids do we have?
129 */
130 logln("Time Zone IDs size: %d", ids_length);
131 /*
132 * Column headings (sort of)
133 */
134 logln("Ordinal ID offset(h:m) name");
135 /*
136 * Loop through the tzs.
137 */
138 UDate today = Calendar::getNow();
139 Calendar *cal = Calendar::createInstance(status);
140 for (int32_t i = 0; i < ids_length; i++) {
141 // logln(i + " " + ids[i]);
142 const UnicodeString* id = ids->snext(status);
143 TimeZone *ttz = TimeZone::createTimeZone(*id);
144 // offset = ttz.getRawOffset();
145 cal->setTimeZone(*ttz);
146 cal->setTime(today, status);
147 offset = cal->get(UCAL_ZONE_OFFSET, status) + cal->get(UCAL_DST_OFFSET, status);
148 // logln(i + " " + ids[i] + " offset " + offset);
149 const char* sign = "+";
150 if (offset < 0) {
151 sign = "-";
152 offset = -offset;
153 }
154 hours = offset/3600000;
155 minutes = (offset%3600000)/60000;
156 seconds = (offset%60000)/1000;
157 UnicodeString dstOffset = (UnicodeString)"" + sign + (hours < 10 ? "0" : "") +
158 (int32_t)hours + ":" + (minutes < 10 ? "0" : "") + (int32_t)minutes;
159 if (seconds != 0) {
160 dstOffset = dstOffset + ":" + (seconds < 10 ? "0" : "") + seconds;
161 }
162 /*
163 * Instantiate a date so we can display the time zone name.
164 */
165 sdf->setTimeZone(*ttz);
166 /*
167 * Format the output.
168 */
169 UnicodeString fmtOffset;
170 FieldPosition pos(0);
171 sdf->format(today,fmtOffset, pos);
172 // UnicodeString fmtOffset = tzS.toString();
173 UnicodeString *fmtDstOffset = 0;
174 if (fmtOffset.startsWith("GMT") && fmtOffset.length() != 3)
175 {
176 //fmtDstOffset = fmtOffset->substring(3);
177 fmtDstOffset = new UnicodeString();
178 fmtOffset.extract(3, fmtOffset.length(), *fmtDstOffset);
179 }
180 /*
181 * Show our result.
182 */
183 UBool ok = fmtDstOffset == 0 || *fmtDstOffset == dstOffset;
184 if (ok)
185 {
186 logln(UnicodeString() + i + " " + *id + " " + dstOffset +
187 " " + fmtOffset +
188 (fmtDstOffset != 0 ? " ok" : " ?"));
189 }
190 else
191 {
192 errln(UnicodeString() + i + " " + *id + " " + dstOffset +
193 " " + fmtOffset + " *** FAIL ***");
194 }
195 delete ttz;
196 delete fmtDstOffset;
197 }
198 delete cal;
199 // delete ids; // TODO: BAD API
200 delete ids;
201 delete sdf;
202 delete tz;
203 }
204
205 // -------------------------------------
206
207 /**
208 * Test operator==
209 */
210 void
211 DateFormatTest::TestEquals()
212 {
213 DateFormat* fmtA = DateFormat::createDateTimeInstance(DateFormat::MEDIUM, DateFormat::FULL);
214 DateFormat* fmtB = DateFormat::createDateTimeInstance(DateFormat::MEDIUM, DateFormat::FULL);
215 if ( fmtA == NULL || fmtB == NULL){
216 dataerrln("Error calling DateFormat::createDateTimeInstance");
217 delete fmtA;
218 delete fmtB;
219 return;
220 }
221
222 if (!(*fmtA == *fmtB)) errln((UnicodeString)"FAIL");
223 delete fmtA;
224 delete fmtB;
225
226 TimeZone* test = TimeZone::createTimeZone("PDT");
227 delete test;
228 }
229
230 // -------------------------------------
231
232 /**
233 * Test the parsing of 2-digit years.
234 */
235 void
236 DateFormatTest::TestTwoDigitYearDSTParse(void)
237 {
238 UErrorCode status = U_ZERO_ERROR;
239 SimpleDateFormat* fullFmt = new SimpleDateFormat((UnicodeString)"EEE MMM dd HH:mm:ss.SSS zzz yyyy G", status);
240 SimpleDateFormat *fmt = new SimpleDateFormat((UnicodeString)"dd-MMM-yy h:mm:ss 'o''clock' a z", Locale::getEnglish(), status);
241 //DateFormat* fmt = DateFormat::createDateTimeInstance(DateFormat::MEDIUM, DateFormat::FULL, Locale::ENGLISH);
242 UnicodeString* s = new UnicodeString("03-Apr-04 2:20:47 o'clock AM PST", "");
243 TimeZone* defaultTZ = TimeZone::createDefault();
244 TimeZone* PST = TimeZone::createTimeZone("PST");
245 int32_t defaultOffset = defaultTZ->getRawOffset();
246 int32_t PSTOffset = PST->getRawOffset();
247 int32_t hour = 2 + (defaultOffset - PSTOffset) / (60*60*1000);
248 // hour is the expected hour of day, in units of seconds
249 hour = ((hour < 0) ? hour + 24 : hour) * 60*60;
250
251 UnicodeString str;
252
253 if(U_FAILURE(status)) {
254 dataerrln("Could not set up test. exitting - %s", u_errorName(status));
255 return;
256 }
257
258 UDate d = fmt->parse(*s, status);
259 logln(*s + " P> " + ((DateFormat*)fullFmt)->format(d, str));
260 int32_t y, m, day, hr, min, sec;
261 dateToFields(d, y, m, day, hr, min, sec);
262 hour += defaultTZ->inDaylightTime(d, status) ? 1 : 0;
263 hr = hr*60*60;
264 if (hr != hour)
265 errln((UnicodeString)"FAIL: Should parse to hour " + hour + " but got " + hr);
266
267 if (U_FAILURE(status))
268 errln((UnicodeString)"FAIL: " + (int32_t)status);
269
270 delete s;
271 delete fmt;
272 delete fullFmt;
273 delete PST;
274 delete defaultTZ;
275 }
276
277 // -------------------------------------
278
279 UChar toHexString(int32_t i) { return (UChar)(i + (i < 10 ? 0x30 : (0x41 - 10))); }
280
281 UnicodeString&
282 DateFormatTest::escape(UnicodeString& s)
283 {
284 UnicodeString buf;
285 for (int32_t i=0; i<s.length(); ++i)
286 {
287 UChar c = s[(int32_t)i];
288 if (c <= (UChar)0x7F) buf += c;
289 else {
290 buf += (UChar)0x5c; buf += (UChar)0x55;
291 buf += toHexString((c & 0xF000) >> 12);
292 buf += toHexString((c & 0x0F00) >> 8);
293 buf += toHexString((c & 0x00F0) >> 4);
294 buf += toHexString(c & 0x000F);
295 }
296 }
297 return (s = buf);
298 }
299
300 // -------------------------------------
301
302 /**
303 * This MUST be kept in sync with DateFormatSymbols.gPatternChars.
304 */
305 static const char* PATTERN_CHARS = "GyMdkHmsSEDFwWahKzYeugAZvcLQqVU";
306
307 /**
308 * A list of the names of all the fields in DateFormat.
309 * This MUST be kept in sync with DateFormat.
310 */
311 static const char* DATEFORMAT_FIELD_NAMES[] = {
312 "ERA_FIELD",
313 "YEAR_FIELD",
314 "MONTH_FIELD",
315 "DATE_FIELD",
316 "HOUR_OF_DAY1_FIELD",
317 "HOUR_OF_DAY0_FIELD",
318 "MINUTE_FIELD",
319 "SECOND_FIELD",
320 "MILLISECOND_FIELD",
321 "DAY_OF_WEEK_FIELD",
322 "DAY_OF_YEAR_FIELD",
323 "DAY_OF_WEEK_IN_MONTH_FIELD",
324 "WEEK_OF_YEAR_FIELD",
325 "WEEK_OF_MONTH_FIELD",
326 "AM_PM_FIELD",
327 "HOUR1_FIELD",
328 "HOUR0_FIELD",
329 "TIMEZONE_FIELD",
330 "YEAR_WOY_FIELD",
331 "DOW_LOCAL_FIELD",
332 "EXTENDED_YEAR_FIELD",
333 "JULIAN_DAY_FIELD",
334 "MILLISECONDS_IN_DAY_FIELD",
335 "TIMEZONE_RFC_FIELD",
336 "GENERIC_TIMEZONE_FIELD",
337 "STAND_ALONE_DAY_FIELD",
338 "STAND_ALONE_MONTH_FIELD",
339 "QUARTER_FIELD",
340 "STAND_ALONE_QUARTER_FIELD",
341 "TIMEZONE_SPECIAL_FIELD",
342 "YEAR_NAME_FIELD"
343 };
344
345 static const int32_t DATEFORMAT_FIELD_NAMES_LENGTH =
346 sizeof(DATEFORMAT_FIELD_NAMES) / sizeof(DATEFORMAT_FIELD_NAMES[0]);
347
348 /**
349 * Verify that returned field position indices are correct.
350 */
351 void DateFormatTest::TestFieldPosition() {
352 UErrorCode ec = U_ZERO_ERROR;
353 int32_t i, j, exp;
354 UnicodeString buf;
355
356 // Verify data
357 DateFormatSymbols rootSyms(Locale(""), ec);
358 if (U_FAILURE(ec)) {
359 dataerrln("Unable to create DateFormatSymbols - %s", u_errorName(ec));
360 return;
361 }
362
363 // local pattern chars data is not longer loaded
364 // from icu locale bundle
365 assertEquals("patternChars", PATTERN_CHARS, rootSyms.getLocalPatternChars(buf));
366 assertEquals("patternChars", PATTERN_CHARS, DateFormatSymbols::getPatternUChars());
367 assertTrue("DATEFORMAT_FIELD_NAMES", DATEFORMAT_FIELD_NAMES_LENGTH == UDAT_FIELD_COUNT);
368 assertTrue("Data", UDAT_FIELD_COUNT == uprv_strlen(PATTERN_CHARS));
369
370 // Create test formatters
371 const int32_t COUNT = 4;
372 DateFormat* dateFormats[COUNT];
373 dateFormats[0] = DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull, Locale::getUS());
374 dateFormats[1] = DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull, Locale::getFrance());
375 // Make the pattern "G y M d..."
376 buf.remove().append(PATTERN_CHARS);
377 for (j=buf.length()-1; j>=0; --j) buf.insert(j, (UChar)32/*' '*/);
378 dateFormats[2] = new SimpleDateFormat(buf, Locale::getUS(), ec);
379 // Make the pattern "GGGG yyyy MMMM dddd..."
380 for (j=buf.length()-1; j>=0; j-=2) {
381 for (i=0; i<3; ++i) {
382 buf.insert(j, buf.charAt(j));
383 }
384 }
385 dateFormats[3] = new SimpleDateFormat(buf, Locale::getUS(), ec);
386 if(U_FAILURE(ec)){
387 errln(UnicodeString("Could not create SimpleDateFormat object for locale en_US. Error: " )+ UnicodeString(u_errorName(ec)));
388 return;
389 }
390 UDate aug13 = 871508052513.0;
391
392 // Expected output field values for above DateFormats on aug13
393 // Fields are given in order of DateFormat field number
394 const char* EXPECTED[] = {
395 "", "1997", "August", "13", "", "", "34", "12", "",
396 "Wednesday", "", "", "", "", "PM", "2", "", "Pacific Daylight Time", "", "", "", "", "", "", "", "", "", "", "","","",
397
398 "", "1997", "ao\\u00FBt", "13", "", "14", "34", "12", "",
399 "mercredi", "", "", "", "", "", "", "", "heure avanc\\u00e9e du Pacifique", "", "", "", "", "", "", "", "", "", "", "", "","",
400
401 "AD", "1997", "8", "13", "14", "14", "34", "12", "5",
402 "Wed", "225", "2", "33", "3", "PM", "2", "2", "PDT", "1997", "4", "1997", "2450674", "52452513", "-0700", "PT", "4", "8", "3", "3","PDT","1997",
403
404 "Anno Domini", "1997", "August", "0013", "0014", "0014", "0034", "0012", "5130",
405 "Wednesday", "0225", "0002", "0033", "0003", "PM", "0002", "0002", "Pacific Daylight Time", "1997", "Wednesday", "1997", "2450674", "52452513", "GMT-07:00",
406 "Pacific Time", "Wednesday", "August", "3rd quarter", "3rd quarter", "United States Time (Los Angeles)","1997"
407 };
408
409 const int32_t EXPECTED_LENGTH = sizeof(EXPECTED)/sizeof(EXPECTED[0]);
410
411 assertTrue("data size", EXPECTED_LENGTH == COUNT * UDAT_FIELD_COUNT);
412
413 TimeZone* PT = TimeZone::createTimeZone("America/Los_Angeles");
414 for (j = 0, exp = 0; j < COUNT; ++j) {
415 // String str;
416 DateFormat* df = dateFormats[j];
417 df->setTimeZone(*PT);
418 SimpleDateFormat* sdtfmt = dynamic_cast<SimpleDateFormat*>(df);
419 if (sdtfmt != NULL) {
420 logln(" Pattern = " + sdtfmt->toPattern(buf.remove()));
421 } else {
422 logln(" Pattern = ? (not a SimpleDateFormat)");
423 }
424 logln((UnicodeString)" Result = " + df->format(aug13, buf.remove()));
425
426 int32_t expBase = exp; // save for later
427 for (i = 0; i < UDAT_FIELD_COUNT; ++i, ++exp) {
428 FieldPosition pos(i);
429 buf.remove();
430 df->format(aug13, buf, pos);
431 UnicodeString field;
432 buf.extractBetween(pos.getBeginIndex(), pos.getEndIndex(), field);
433 assertEquals((UnicodeString)"field #" + i + " " + DATEFORMAT_FIELD_NAMES[i],
434 ctou(EXPECTED[exp]), field);
435 }
436
437 // test FieldPositionIterator API
438 logln("FieldPositionIterator");
439 {
440 UErrorCode status = U_ZERO_ERROR;
441 FieldPositionIterator posIter;
442 FieldPosition fp;
443
444 buf.remove();
445 df->format(aug13, buf, &posIter, status);
446 while (posIter.next(fp)) {
447 int32_t i = fp.getField();
448 UnicodeString field;
449 buf.extractBetween(fp.getBeginIndex(), fp.getEndIndex(), field);
450 assertEquals((UnicodeString)"field #" + i + " " + DATEFORMAT_FIELD_NAMES[i],
451 ctou(EXPECTED[expBase + i]), field);
452 }
453
454 }
455 }
456
457
458 // test null posIter
459 buf.remove();
460 UErrorCode status = U_ZERO_ERROR;
461 dateFormats[0]->format(aug13, buf, NULL, status);
462 // if we didn't crash, we succeeded.
463
464 for (i=0; i<COUNT; ++i) {
465 delete dateFormats[i];
466 }
467 delete PT;
468 }
469
470 // -------------------------------------
471
472 /**
473 * General parse/format tests. Add test cases as needed.
474 */
475 void DateFormatTest::TestGeneral() {
476 const char* DATA[] = {
477 "yyyy MM dd HH:mm:ss.SSS",
478
479 // Milliseconds are left-justified, since they format as fractions of a second
480 "y/M/d H:mm:ss.S", "fp", "2004 03 10 16:36:31.567", "2004/3/10 16:36:31.5", "2004 03 10 16:36:31.500",
481 "y/M/d H:mm:ss.SS", "fp", "2004 03 10 16:36:31.567", "2004/3/10 16:36:31.56", "2004 03 10 16:36:31.560",
482 "y/M/d H:mm:ss.SSS", "F", "2004 03 10 16:36:31.567", "2004/3/10 16:36:31.567",
483 "y/M/d H:mm:ss.SSSS", "pf", "2004/3/10 16:36:31.5679", "2004 03 10 16:36:31.568", "2004/3/10 16:36:31.5680",
484 };
485 expect(DATA, ARRAY_SIZE(DATA), Locale("en", "", ""));
486 }
487
488 // -------------------------------------
489
490 /**
491 * Verify that strings which contain incomplete specifications are parsed
492 * correctly. In some instances, this means not being parsed at all, and
493 * returning an appropriate error.
494 */
495 void
496 DateFormatTest::TestPartialParse994()
497 {
498 UErrorCode status = U_ZERO_ERROR;
499 SimpleDateFormat* f = new SimpleDateFormat(status);
500 if (U_FAILURE(status)) {
501 dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status));
502 delete f;
503 return;
504 }
505 UDate null = 0;
506 tryPat994(f, "yy/MM/dd HH:mm:ss", "97/01/17 10:11:42", date(97, 1 - 1, 17, 10, 11, 42));
507 tryPat994(f, "yy/MM/dd HH:mm:ss", "97/01/17 10:", null);
508 tryPat994(f, "yy/MM/dd HH:mm:ss", "97/01/17 10", null);
509 tryPat994(f, "yy/MM/dd HH:mm:ss", "97/01/17 ", null);
510 tryPat994(f, "yy/MM/dd HH:mm:ss", "97/01/17", null);
511 if (U_FAILURE(status)) errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
512 delete f;
513 }
514
515 // -------------------------------------
516
517 void
518 DateFormatTest::tryPat994(SimpleDateFormat* format, const char* pat, const char* str, UDate expected)
519 {
520 UErrorCode status = U_ZERO_ERROR;
521 UDate null = 0;
522 logln(UnicodeString("Pattern \"") + pat + "\" String \"" + str + "\"");
523 //try {
524 format->applyPattern(pat);
525 UDate date = format->parse(str, status);
526 if (U_FAILURE(status) || date == null)
527 {
528 logln((UnicodeString)"ParseException: " + (int32_t)status);
529 if (expected != null) errln((UnicodeString)"FAIL: Expected " + dateToString(expected));
530 }
531 else
532 {
533 UnicodeString f;
534 ((DateFormat*)format)->format(date, f);
535 logln(UnicodeString(" parse(") + str + ") -> " + dateToString(date));
536 logln((UnicodeString)" format -> " + f);
537 if (expected == null ||
538 !(date == expected)) errln((UnicodeString)"FAIL: Expected null");//" + expected);
539 if (!(f == str)) errln(UnicodeString("FAIL: Expected ") + str);
540 }
541 //}
542 //catch(ParseException e) {
543 // logln((UnicodeString)"ParseException: " + e.getMessage());
544 // if (expected != null) errln((UnicodeString)"FAIL: Expected " + dateToString(expected));
545 //}
546 //catch(Exception e) {
547 // errln((UnicodeString)"*** Exception:");
548 // e.printStackTrace();
549 //}
550 }
551
552 // -------------------------------------
553
554 /**
555 * Verify the behavior of patterns in which digits for different fields run together
556 * without intervening separators.
557 */
558 void
559 DateFormatTest::TestRunTogetherPattern985()
560 {
561 UErrorCode status = U_ZERO_ERROR;
562 UnicodeString format("yyyyMMddHHmmssSSS");
563 UnicodeString now, then;
564 //UBool flag;
565 SimpleDateFormat *formatter = new SimpleDateFormat(format, status);
566 if (U_FAILURE(status)) {
567 dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status));
568 delete formatter;
569 return;
570 }
571 UDate date1 = Calendar::getNow();
572 ((DateFormat*)formatter)->format(date1, now);
573 logln(now);
574 ParsePosition pos(0);
575 UDate date2 = formatter->parse(now, pos);
576 if (date2 == 0) then = "Parse stopped at " + pos.getIndex();
577 else ((DateFormat*)formatter)->format(date2, then);
578 logln(then);
579 if (!(date2 == date1)) errln((UnicodeString)"FAIL");
580 delete formatter;
581 if (U_FAILURE(status)) errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
582 }
583
584 // -------------------------------------
585
586 /**
587 * Verify the behavior of patterns in which digits for different fields run together
588 * without intervening separators.
589 */
590 void
591 DateFormatTest::TestRunTogetherPattern917()
592 {
593 UErrorCode status = U_ZERO_ERROR;
594 SimpleDateFormat* fmt;
595 UnicodeString myDate;
596 fmt = new SimpleDateFormat((UnicodeString)"yyyy/MM/dd", status);
597 if (U_FAILURE(status)) {
598 dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status));
599 delete fmt;
600 return;
601 }
602 myDate = "1997/02/03";
603 testIt917(fmt, myDate, date(97, 2 - 1, 3));
604 delete fmt;
605 fmt = new SimpleDateFormat((UnicodeString)"yyyyMMdd", status);
606 myDate = "19970304";
607 testIt917(fmt, myDate, date(97, 3 - 1, 4));
608 delete fmt;
609 if (U_FAILURE(status)) errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
610 }
611
612 // -------------------------------------
613
614 void
615 DateFormatTest::testIt917(SimpleDateFormat* fmt, UnicodeString& str, UDate expected)
616 {
617 UErrorCode status = U_ZERO_ERROR;
618 UnicodeString pattern;
619 logln((UnicodeString)"pattern=" + fmt->toPattern(pattern) + " string=" + str);
620 Formattable o;
621 //try {
622 ((Format*)fmt)->parseObject(str, o, status);
623 //}
624 if (U_FAILURE(status)) return;
625 //catch(ParseException e) {
626 // e.printStackTrace();
627 // return;
628 //}
629 logln((UnicodeString)"Parsed object: " + dateToString(o.getDate()));
630 if (!(o.getDate() == expected)) errln((UnicodeString)"FAIL: Expected " + dateToString(expected));
631 UnicodeString formatted; ((Format*)fmt)->format(o, formatted, status);
632 logln((UnicodeString)"Formatted string: " + formatted);
633 if (!(formatted == str)) errln((UnicodeString)"FAIL: Expected " + str);
634 if (U_FAILURE(status)) errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
635 }
636
637 // -------------------------------------
638
639 /**
640 * Verify the handling of Czech June and July, which have the unique attribute that
641 * one is a proper prefix substring of the other.
642 */
643 void
644 DateFormatTest::TestCzechMonths459()
645 {
646 UErrorCode status = U_ZERO_ERROR;
647 DateFormat* fmt = DateFormat::createDateInstance(DateFormat::FULL, Locale("cs", "", ""));
648 if (fmt == NULL){
649 dataerrln("Error calling DateFormat::createDateInstance()");
650 return;
651 }
652
653 UnicodeString pattern;
654 logln((UnicodeString)"Pattern " + ((SimpleDateFormat*) fmt)->toPattern(pattern));
655 UDate june = date(97, UCAL_JUNE, 15);
656 UDate july = date(97, UCAL_JULY, 15);
657 UnicodeString juneStr; fmt->format(june, juneStr);
658 UnicodeString julyStr; fmt->format(july, julyStr);
659 //try {
660 logln((UnicodeString)"format(June 15 1997) = " + juneStr);
661 UDate d = fmt->parse(juneStr, status);
662 UnicodeString s; fmt->format(d, s);
663 int32_t month,yr,day,hr,min,sec; dateToFields(d,yr,month,day,hr,min,sec);
664 logln((UnicodeString)" -> parse -> " + s + " (month = " + month + ")");
665 if (month != UCAL_JUNE) errln((UnicodeString)"FAIL: Month should be June");
666 logln((UnicodeString)"format(July 15 1997) = " + julyStr);
667 d = fmt->parse(julyStr, status);
668 fmt->format(d, s);
669 dateToFields(d,yr,month,day,hr,min,sec);
670 logln((UnicodeString)" -> parse -> " + s + " (month = " + month + ")");
671 if (month != UCAL_JULY) errln((UnicodeString)"FAIL: Month should be July");
672 //}
673 //catch(ParseException e) {
674 if (U_FAILURE(status))
675 errln((UnicodeString)"Exception: " + (int32_t)status);
676 //}
677 delete fmt;
678 }
679
680 // -------------------------------------
681
682 /**
683 * Test the handling of 'D' in patterns.
684 */
685 void
686 DateFormatTest::TestLetterDPattern212()
687 {
688 UErrorCode status = U_ZERO_ERROR;
689 UnicodeString dateString("1995-040.05:01:29");
690 UnicodeString bigD("yyyy-DDD.hh:mm:ss");
691 UnicodeString littleD("yyyy-ddd.hh:mm:ss");
692 UDate expLittleD = date(95, 0, 1, 5, 1, 29);
693 UDate expBigD = expLittleD + 39 * 24 * 3600000.0;
694 expLittleD = expBigD; // Expect the same, with default lenient parsing
695 logln((UnicodeString)"dateString= " + dateString);
696 SimpleDateFormat *formatter = new SimpleDateFormat(bigD, status);
697 if (U_FAILURE(status)) {
698 dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status));
699 delete formatter;
700 return;
701 }
702 ParsePosition pos(0);
703 UDate myDate = formatter->parse(dateString, pos);
704 logln((UnicodeString)"Using " + bigD + " -> " + myDate);
705 if (myDate != expBigD) errln((UnicodeString)"FAIL: bigD - Expected " + dateToString(expBigD));
706 delete formatter;
707 formatter = new SimpleDateFormat(littleD, status);
708 ASSERT_OK(status);
709 pos = ParsePosition(0);
710 myDate = formatter->parse(dateString, pos);
711 logln((UnicodeString)"Using " + littleD + " -> " + dateToString(myDate));
712 if (myDate != expLittleD) errln((UnicodeString)"FAIL: littleD - Expected " + dateToString(expLittleD));
713 delete formatter;
714 if (U_FAILURE(status)) errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
715 }
716
717 // -------------------------------------
718
719 /**
720 * Test the day of year pattern.
721 */
722 void
723 DateFormatTest::TestDayOfYearPattern195()
724 {
725 UErrorCode status = U_ZERO_ERROR;
726 UDate today = Calendar::getNow();
727 int32_t year,month,day,hour,min,sec; dateToFields(today,year,month,day,hour,min,sec);
728 UDate expected = date(year, month, day);
729 logln((UnicodeString)"Test Date: " + dateToString(today));
730 SimpleDateFormat* sdf = (SimpleDateFormat*)DateFormat::createDateInstance();
731 if (sdf == NULL){
732 dataerrln("Error calling DateFormat::createDateInstance()");
733 return;
734 }
735 tryPattern(*sdf, today, 0, expected);
736 tryPattern(*sdf, today, "G yyyy DDD", expected);
737 delete sdf;
738 if (U_FAILURE(status)) errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
739 }
740
741 // -------------------------------------
742
743 void
744 DateFormatTest::tryPattern(SimpleDateFormat& sdf, UDate d, const char* pattern, UDate expected)
745 {
746 UErrorCode status = U_ZERO_ERROR;
747 if (pattern != 0) sdf.applyPattern(pattern);
748 UnicodeString thePat;
749 logln((UnicodeString)"pattern: " + sdf.toPattern(thePat));
750 UnicodeString formatResult; (*(DateFormat*)&sdf).format(d, formatResult);
751 logln((UnicodeString)" format -> " + formatResult);
752 // try {
753 UDate d2 = sdf.parse(formatResult, status);
754 logln((UnicodeString)" parse(" + formatResult + ") -> " + dateToString(d2));
755 if (d2 != expected) errln((UnicodeString)"FAIL: Expected " + dateToString(expected));
756 UnicodeString format2; (*(DateFormat*)&sdf).format(d2, format2);
757 logln((UnicodeString)" format -> " + format2);
758 if (!(formatResult == format2)) errln((UnicodeString)"FAIL: Round trip drift");
759 //}
760 //catch(Exception e) {
761 if (U_FAILURE(status))
762 errln((UnicodeString)"Error: " + (int32_t)status);
763 //}
764 }
765
766 // -------------------------------------
767
768 /**
769 * Test the handling of single quotes in patterns.
770 */
771 void
772 DateFormatTest::TestQuotePattern161()
773 {
774 UErrorCode status = U_ZERO_ERROR;
775 SimpleDateFormat* formatter = new SimpleDateFormat((UnicodeString)"MM/dd/yyyy 'at' hh:mm:ss a zzz", status);
776 if (U_FAILURE(status)) {
777 dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status));
778 delete formatter;
779 return;
780 }
781 UDate currentTime_1 = date(97, UCAL_AUGUST, 13, 10, 42, 28);
782 UnicodeString dateString; ((DateFormat*)formatter)->format(currentTime_1, dateString);
783 UnicodeString exp("08/13/1997 at 10:42:28 AM ");
784 logln((UnicodeString)"format(" + dateToString(currentTime_1) + ") = " + dateString);
785 if (0 != dateString.compareBetween(0, exp.length(), exp, 0, exp.length())) errln((UnicodeString)"FAIL: Expected " + exp);
786 delete formatter;
787 if (U_FAILURE(status)) errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
788 }
789
790 // -------------------------------------
791
792 /**
793 * Verify the correct behavior when handling invalid input strings.
794 */
795 void
796 DateFormatTest::TestBadInput135()
797 {
798 UErrorCode status = U_ZERO_ERROR;
799 DateFormat::EStyle looks[] = {
800 DateFormat::SHORT, DateFormat::MEDIUM, DateFormat::LONG, DateFormat::FULL
801 };
802 int32_t looks_length = (int32_t)(sizeof(looks) / sizeof(looks[0]));
803 const char* strings[] = {
804 "Mar 15", "Mar 15 1997", "asdf", "3/1/97 1:23:", "3/1/00 1:23:45 AM"
805 };
806 int32_t strings_length = (int32_t)(sizeof(strings) / sizeof(strings[0]));
807 DateFormat *full = DateFormat::createDateTimeInstance(DateFormat::LONG, DateFormat::LONG);
808 if(full==NULL) {
809 dataerrln("could not create date time instance");
810 return;
811 }
812 UnicodeString expected("March 1, 2000 1:23:45 AM ");
813 for (int32_t i = 0; i < strings_length;++i) {
814 const char* text = strings[i];
815 for (int32_t j = 0; j < looks_length;++j) {
816 DateFormat::EStyle dateLook = looks[j];
817 for (int32_t k = 0; k < looks_length;++k) {
818 DateFormat::EStyle timeLook = looks[k];
819 DateFormat *df = DateFormat::createDateTimeInstance(dateLook, timeLook);
820 if (df == NULL){
821 dataerrln("Error calling DateFormat::createDateTimeInstance()");
822 continue;
823 }
824 UnicodeString prefix = UnicodeString(text) + ", " + dateLook + "/" + timeLook + ": ";
825 //try {
826 UDate when = df->parse(text, status);
827 if (when == 0 && U_SUCCESS(status)) {
828 errln(prefix + "SHOULD NOT HAPPEN: parse returned 0.");
829 continue;
830 }
831 if (U_SUCCESS(status))
832 {
833 UnicodeString format;
834 UnicodeString pattern;
835 SimpleDateFormat* sdtfmt = dynamic_cast<SimpleDateFormat*>(df);
836 if (sdtfmt != NULL) {
837 sdtfmt->toPattern(pattern);
838 }
839 full->format(when, format);
840 logln(prefix + "OK: " + format);
841 if (0!=format.compareBetween(0, expected.length(), expected, 0, expected.length()))
842 errln((UnicodeString)"FAIL: Parse \"" + text + "\", pattern \"" + pattern + "\", expected " + expected + " got " + format);
843 }
844 //}
845 //catch(ParseException e) {
846 else
847 status = U_ZERO_ERROR;
848 //}
849 //catch(StringIndexOutOfBoundsException e) {
850 // errln(prefix + "SHOULD NOT HAPPEN: " + (int)status);
851 //}
852 delete df;
853 }
854 }
855 }
856 delete full;
857 if (U_FAILURE(status))
858 errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
859 }
860
861 static const char* const parseFormats[] = {
862 "MMMM d, yyyy",
863 "MMMM d yyyy",
864 "M/d/yy",
865 "d MMMM, yyyy",
866 "d MMMM yyyy",
867 "d MMMM",
868 "MMMM d",
869 "yyyy",
870 "h:mm a MMMM d, yyyy"
871 };
872
873 #if 0
874 // strict inputStrings
875 static const char* const inputStrings[] = {
876 "bogus string", 0, 0, 0, 0, 0, 0, 0, 0, 0,
877 "April 1, 1997", "April 1, 1997", 0, 0, 0, 0, 0, "April 1", 0, 0,
878 "Jan 1, 1970", "January 1, 1970", 0, 0, 0, 0, 0, "January 1", 0, 0,
879 "Jan 1 2037", 0, "January 1 2037", 0, 0, 0, 0, "January 1", 0, 0,
880 "1/1/70", 0, 0, "1/1/70", 0, 0, 0, 0, "0001", 0,
881 "5 May 1997", 0, 0, 0, 0, "5 May 1997", "5 May", 0, "0005", 0,
882 "16 May", 0, 0, 0, 0, 0, "16 May", 0, "0016", 0,
883 "April 30", 0, 0, 0, 0, 0, 0, "April 30", 0, 0,
884 "1998", 0, 0, 0, 0, 0, 0, 0, "1998", 0,
885 "1", 0, 0, 0, 0, 0, 0, 0, "0001", 0,
886 "3:00 pm Jan 1, 1997", 0, 0, 0, 0, 0, 0, 0, "0003", "3:00 PM January 1, 1997",
887 };
888 #else
889 // lenient inputStrings
890 static const char* const inputStrings[] = {
891 "bogus string", 0, 0, 0, 0, 0, 0, 0, 0, 0,
892 "April 1, 1997", "April 1, 1997", "April 1 1997", "4/1/97", 0, 0, 0, "April 1", 0, 0,
893 "Jan 1, 1970", "January 1, 1970", "January 1 1970", "1/1/70", 0, 0, 0, "January 1", 0, 0,
894 "Jan 1 2037", "January 1, 2037", "January 1 2037", "1/1/37", 0, 0, 0, "January 1", 0, 0,
895 "1/1/70", "January 1, 1970", "January 1 1970", "1/1/70", "1 January, 1970", "1 January 1970", "1 January", "January 1", "0001", 0,
896 "5 May 1997", 0, 0, 0, "5 May, 1997", "5 May 1997", "5 May", 0, "0005", 0,
897 "16 May", 0, 0, 0, 0, 0, "16 May", 0, "2016", 0,
898 "April 30", 0, 0, 0, 0, 0, 0, "April 30", 0, 0,
899 "1998", 0, 0, 0, 0, 0, 0, 0, "1998", 0,
900 "1", 0, 0, 0, 0, 0, 0, 0, "0001", 0,
901 "3:00 pm Jan 1, 1997", 0, 0, 0, 0, 0, 0, 0, "0003", "3:00 PM January 1, 1997",
902 };
903 #endif
904
905 // -------------------------------------
906
907 /**
908 * Verify the correct behavior when parsing an array of inputs against an
909 * array of patterns, with known results. The results are encoded after
910 * the input strings in each row.
911 */
912 void
913 DateFormatTest::TestBadInput135a()
914 {
915 UErrorCode status = U_ZERO_ERROR;
916 SimpleDateFormat* dateParse = new SimpleDateFormat(status);
917 if(U_FAILURE(status)) {
918 dataerrln("Failed creating SimpleDateFormat with %s. Quitting test", u_errorName(status));
919 delete dateParse;
920 return;
921 }
922 const char* s;
923 UDate date;
924 const uint32_t PF_LENGTH = (int32_t)(sizeof(parseFormats)/sizeof(parseFormats[0]));
925 const uint32_t INPUT_LENGTH = (int32_t)(sizeof(inputStrings)/sizeof(inputStrings[0]));
926
927 dateParse->applyPattern("d MMMM, yyyy");
928 dateParse->adoptTimeZone(TimeZone::createDefault());
929 s = "not parseable";
930 UnicodeString thePat;
931 logln(UnicodeString("Trying to parse \"") + s + "\" with " + dateParse->toPattern(thePat));
932 //try {
933 date = dateParse->parse(s, status);
934 if (U_SUCCESS(status))
935 errln((UnicodeString)"FAIL: Expected exception during parse");
936 //}
937 //catch(Exception ex) {
938 else
939 logln((UnicodeString)"Exception during parse: " + (int32_t)status);
940 status = U_ZERO_ERROR;
941 //}
942 for (uint32_t i = 0; i < INPUT_LENGTH; i += (PF_LENGTH + 1)) {
943 ParsePosition parsePosition(0);
944 UnicodeString s( inputStrings[i]);
945 for (uint32_t index = 0; index < PF_LENGTH;++index) {
946 const char* expected = inputStrings[i + 1 + index];
947 dateParse->applyPattern(parseFormats[index]);
948 dateParse->adoptTimeZone(TimeZone::createDefault());
949 //try {
950 parsePosition.setIndex(0);
951 date = dateParse->parse(s, parsePosition);
952 if (parsePosition.getIndex() != 0) {
953 UnicodeString s1, s2;
954 s.extract(0, parsePosition.getIndex(), s1);
955 s.extract(parsePosition.getIndex(), s.length(), s2);
956 if (date == 0) {
957 errln((UnicodeString)"ERROR: null result fmt=\"" +
958 parseFormats[index] +
959 "\" pos=" + parsePosition.getIndex() + " " +
960 s1 + "|" + s2);
961 }
962 else {
963 UnicodeString result;
964 ((DateFormat*)dateParse)->format(date, result);
965 logln((UnicodeString)"Parsed \"" + s + "\" using \"" + dateParse->toPattern(thePat) + "\" to: " + result);
966 if (expected == 0)
967 errln((UnicodeString)"FAIL: Expected parse failure, got " + result);
968 else if (!(result == expected))
969 errln(UnicodeString("FAIL: Parse \"") + s + UnicodeString("\", expected ") + expected + UnicodeString(", got ") + result);
970 }
971 }
972 else if (expected != 0) {
973 errln(UnicodeString("FAIL: Expected ") + expected + " from \"" +
974 s + "\" with \"" + dateParse->toPattern(thePat) + "\"");
975 }
976 //}
977 //catch(Exception ex) {
978 if (U_FAILURE(status))
979 errln((UnicodeString)"An exception was thrown during parse: " + (int32_t)status);
980 //}
981 }
982 }
983 delete dateParse;
984 if (U_FAILURE(status))
985 errln((UnicodeString)"FAIL: UErrorCode received during test: " + (int32_t)status);
986 }
987
988 // -------------------------------------
989
990 /**
991 * Test the parsing of two-digit years.
992 */
993 void
994 DateFormatTest::TestTwoDigitYear()
995 {
996 UErrorCode ec = U_ZERO_ERROR;
997 SimpleDateFormat fmt("dd/MM/yy", Locale::getUK(), ec);
998 if (U_FAILURE(ec)) {
999 dataerrln("FAIL: SimpleDateFormat constructor - %s", u_errorName(ec));
1000 return;
1001 }
1002 parse2DigitYear(fmt, "5/6/17", date(117, UCAL_JUNE, 5));
1003 parse2DigitYear(fmt, "4/6/34", date(34, UCAL_JUNE, 4));
1004 }
1005
1006 // -------------------------------------
1007
1008 void
1009 DateFormatTest::parse2DigitYear(DateFormat& fmt, const char* str, UDate expected)
1010 {
1011 UErrorCode status = U_ZERO_ERROR;
1012 //try {
1013 UDate d = fmt.parse(str, status);
1014 UnicodeString thePat;
1015 logln(UnicodeString("Parsing \"") + str + "\" with " + ((SimpleDateFormat*)&fmt)->toPattern(thePat) +
1016 " => " + dateToString(d));
1017 if (d != expected) errln((UnicodeString)"FAIL: Expected " + expected);
1018 //}
1019 //catch(ParseException e) {
1020 if (U_FAILURE(status))
1021 errln((UnicodeString)"FAIL: Got exception");
1022 //}
1023 }
1024
1025 // -------------------------------------
1026
1027 /**
1028 * Test the formatting of time zones.
1029 */
1030 void
1031 DateFormatTest::TestDateFormatZone061()
1032 {
1033 UErrorCode status = U_ZERO_ERROR;
1034 UDate date;
1035 DateFormat *formatter;
1036 date= 859248000000.0;
1037 logln((UnicodeString)"Date 1997/3/25 00:00 GMT: " + date);
1038 formatter = new SimpleDateFormat((UnicodeString)"dd-MMM-yyyyy HH:mm", Locale::getUK(), status);
1039 if(U_FAILURE(status)) {
1040 dataerrln("Failed creating SimpleDateFormat with %s. Quitting test", u_errorName(status));
1041 delete formatter;
1042 return;
1043 }
1044 formatter->adoptTimeZone(TimeZone::createTimeZone("GMT"));
1045 UnicodeString temp; formatter->format(date, temp);
1046 logln((UnicodeString)"Formatted in GMT to: " + temp);
1047 //try {
1048 UDate tempDate = formatter->parse(temp, status);
1049 logln((UnicodeString)"Parsed to: " + dateToString(tempDate));
1050 if (tempDate != date) errln((UnicodeString)"FAIL: Expected " + dateToString(date));
1051 //}
1052 //catch(Throwable t) {
1053 if (U_FAILURE(status))
1054 errln((UnicodeString)"Date Formatter throws: " + (int32_t)status);
1055 //}
1056 delete formatter;
1057 }
1058
1059 // -------------------------------------
1060
1061 /**
1062 * Test the formatting of time zones.
1063 */
1064 void
1065 DateFormatTest::TestDateFormatZone146()
1066 {
1067 TimeZone *saveDefault = TimeZone::createDefault();
1068
1069 //try {
1070 TimeZone *thedefault = TimeZone::createTimeZone("GMT");
1071 TimeZone::setDefault(*thedefault);
1072 // java.util.Locale.setDefault(new java.util.Locale("ar", "", ""));
1073
1074 // check to be sure... its GMT all right
1075 TimeZone *testdefault = TimeZone::createDefault();
1076 UnicodeString testtimezone;
1077 testdefault->getID(testtimezone);
1078 if (testtimezone == "GMT")
1079 logln("Test timezone = " + testtimezone);
1080 else
1081 dataerrln("Test timezone should be GMT, not " + testtimezone);
1082
1083 UErrorCode status = U_ZERO_ERROR;
1084 // now try to use the default GMT time zone
1085 GregorianCalendar *greenwichcalendar =
1086 new GregorianCalendar(1997, 3, 4, 23, 0, status);
1087 if (U_FAILURE(status)) {
1088 dataerrln("Fail new GregorianCalendar: %s", u_errorName(status));
1089 } else {
1090 //*****************************greenwichcalendar.setTimeZone(TimeZone.getDefault());
1091 //greenwichcalendar.set(1997, 3, 4, 23, 0);
1092 // try anything to set hour to 23:00 !!!
1093 greenwichcalendar->set(UCAL_HOUR_OF_DAY, 23);
1094 // get time
1095 UDate greenwichdate = greenwichcalendar->getTime(status);
1096 // format every way
1097 UnicodeString DATA [] = {
1098 UnicodeString("simple format: "), UnicodeString("04/04/97 23:00 GMT"),
1099 UnicodeString("MM/dd/yy HH:mm z"),
1100 UnicodeString("full format: "), UnicodeString("Friday, April 4, 1997 11:00:00 o'clock PM GMT"),
1101 UnicodeString("EEEE, MMMM d, yyyy h:mm:ss 'o''clock' a z"),
1102 UnicodeString("long format: "), UnicodeString("April 4, 1997 11:00:00 PM GMT"),
1103 UnicodeString("MMMM d, yyyy h:mm:ss a z"),
1104 UnicodeString("default format: "), UnicodeString("04-Apr-97 11:00:00 PM"),
1105 UnicodeString("dd-MMM-yy h:mm:ss a"),
1106 UnicodeString("short format: "), UnicodeString("4/4/97 11:00 PM"),
1107 UnicodeString("M/d/yy h:mm a")
1108 };
1109 int32_t DATA_length = (int32_t)(sizeof(DATA) / sizeof(DATA[0]));
1110
1111 for (int32_t i=0; i<DATA_length; i+=3) {
1112 DateFormat *fmt = new SimpleDateFormat(DATA[i+2], Locale::getEnglish(), status);
1113 if (U_FAILURE(status)) {
1114 dataerrln("Unable to create SimpleDateFormat - %s", u_errorName(status));
1115 break;
1116 }
1117 fmt->setCalendar(*greenwichcalendar);
1118 UnicodeString result;
1119 result = fmt->format(greenwichdate, result);
1120 logln(DATA[i] + result);
1121 if (result != DATA[i+1])
1122 errln("FAIL: Expected " + DATA[i+1] + ", got " + result);
1123 delete fmt;
1124 }
1125 }
1126 //}
1127 //finally {
1128 TimeZone::adoptDefault(saveDefault);
1129 //}
1130 delete testdefault;
1131 delete greenwichcalendar;
1132 delete thedefault;
1133
1134
1135 }
1136
1137 // -------------------------------------
1138
1139 /**
1140 * Test the formatting of dates in different locales.
1141 */
1142 void
1143 DateFormatTest::TestLocaleDateFormat() // Bug 495
1144 {
1145 UDate testDate = date(97, UCAL_SEPTEMBER, 15);
1146 DateFormat *dfFrench = DateFormat::createDateTimeInstance(DateFormat::FULL,
1147 DateFormat::FULL, Locale::getFrench());
1148 DateFormat *dfUS = DateFormat::createDateTimeInstance(DateFormat::FULL,
1149 DateFormat::FULL, Locale::getUS());
1150 UnicodeString expectedFRENCH ( "lundi 15 septembre 1997 00:00:00 heure avanc\\u00E9e du Pacifique", -1, US_INV );
1151 expectedFRENCH = expectedFRENCH.unescape();
1152 //UnicodeString expectedUS ( "Monday, September 15, 1997 12:00:00 o'clock AM PDT" );
1153 UnicodeString expectedUS ( "Monday, September 15, 1997 12:00:00 AM Pacific Daylight Time" );
1154 logln((UnicodeString)"Date set to : " + dateToString(testDate));
1155 UnicodeString out;
1156 if (dfUS == NULL || dfFrench == NULL){
1157 dataerrln("Error calling DateFormat::createDateTimeInstance)");
1158 delete dfUS;
1159 delete dfFrench;
1160 return;
1161 }
1162
1163 dfFrench->format(testDate, out);
1164 logln((UnicodeString)"Date Formated with French Locale " + out);
1165 if (!(out == expectedFRENCH))
1166 errln((UnicodeString)"FAIL: Expected " + expectedFRENCH);
1167 out.truncate(0);
1168 dfUS->format(testDate, out);
1169 logln((UnicodeString)"Date Formated with US Locale " + out);
1170 if (!(out == expectedUS))
1171 errln((UnicodeString)"FAIL: Expected " + expectedUS);
1172 delete dfUS;
1173 delete dfFrench;
1174 }
1175
1176 /**
1177 * Test DateFormat(Calendar) API
1178 */
1179 void DateFormatTest::TestDateFormatCalendar() {
1180 DateFormat *date=0, *time=0, *full=0;
1181 Calendar *cal=0;
1182 UnicodeString str;
1183 ParsePosition pos;
1184 UDate when;
1185 UErrorCode ec = U_ZERO_ERROR;
1186
1187 /* Create a formatter for date fields. */
1188 date = DateFormat::createDateInstance(DateFormat::kShort, Locale::getUS());
1189 if (date == NULL) {
1190 dataerrln("FAIL: createDateInstance failed");
1191 goto FAIL;
1192 }
1193
1194 /* Create a formatter for time fields. */
1195 time = DateFormat::createTimeInstance(DateFormat::kShort, Locale::getUS());
1196 if (time == NULL) {
1197 errln("FAIL: createTimeInstance failed");
1198 goto FAIL;
1199 }
1200
1201 /* Create a full format for output */
1202 full = DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull,
1203 Locale::getUS());
1204 if (full == NULL) {
1205 errln("FAIL: createInstance failed");
1206 goto FAIL;
1207 }
1208
1209 /* Create a calendar */
1210 cal = Calendar::createInstance(Locale::getUS(), ec);
1211 if (cal == NULL || U_FAILURE(ec)) {
1212 errln((UnicodeString)"FAIL: Calendar::createInstance failed with " +
1213 u_errorName(ec));
1214 goto FAIL;
1215 }
1216
1217 /* Parse the date */
1218 cal->clear();
1219 str = UnicodeString("4/5/2001", "");
1220 pos.setIndex(0);
1221 date->parse(str, *cal, pos);
1222 if (pos.getIndex() != str.length()) {
1223 errln((UnicodeString)"FAIL: DateFormat::parse(4/5/2001) failed at " +
1224 pos.getIndex());
1225 goto FAIL;
1226 }
1227
1228 /* Parse the time */
1229 str = UnicodeString("5:45 PM", "");
1230 pos.setIndex(0);
1231 time->parse(str, *cal, pos);
1232 if (pos.getIndex() != str.length()) {
1233 errln((UnicodeString)"FAIL: DateFormat::parse(17:45) failed at " +
1234 pos.getIndex());
1235 goto FAIL;
1236 }
1237
1238 /* Check result */
1239 when = cal->getTime(ec);
1240 if (U_FAILURE(ec)) {
1241 errln((UnicodeString)"FAIL: cal->getTime() failed with " + u_errorName(ec));
1242 goto FAIL;
1243 }
1244 str.truncate(0);
1245 full->format(when, str);
1246 // Thursday, April 5, 2001 5:45:00 PM PDT 986517900000
1247 if (when == 986517900000.0) {
1248 logln("Ok: Parsed result: " + str);
1249 } else {
1250 errln("FAIL: Parsed result: " + str + ", exp 4/5/2001 5:45 PM");
1251 }
1252
1253 FAIL:
1254 delete date;
1255 delete time;
1256 delete full;
1257 delete cal;
1258 }
1259
1260 /**
1261 * Test DateFormat's parsing of space characters. See jitterbug 1916.
1262 */
1263 void DateFormatTest::TestSpaceParsing() {
1264 const char* DATA[] = {
1265 "yyyy MM dd HH:mm:ss",
1266
1267 // pattern, input, expected parse or NULL if expect parse failure
1268 "MMMM d yy", " 04 05 06", "2006 04 05 00:00:00",
1269 NULL, "04 05 06", "2006 04 05 00:00:00",
1270
1271 "MM d yy", " 04 05 06", "2006 04 05 00:00:00",
1272 NULL, "04 05 06", "2006 04 05 00:00:00",
1273 NULL, "04/05/06", "2006 04 05 00:00:00",
1274 NULL, "04-05-06", "2006 04 05 00:00:00",
1275 NULL, "04.05.06", "2006 04 05 00:00:00",
1276 NULL, "04 / 05 / 06", "2006 04 05 00:00:00",
1277 NULL, "Apr / 05/ 06", "2006 04 05 00:00:00",
1278 NULL, "Apr-05-06", "2006 04 05 00:00:00",
1279 NULL, "Apr 05, 2006", "2006 04 05 00:00:00",
1280
1281 "MMMM d yy", " Apr 05 06", "2006 04 05 00:00:00",
1282 NULL, "Apr 05 06", "2006 04 05 00:00:00",
1283 NULL, "Apr05 06", "2006 04 05 00:00:00",
1284
1285 "hh:mm:ss a", "12:34:56 PM", "1970 01 01 12:34:56",
1286 NULL, "12:34:56PM", "1970 01 01 12:34:56",
1287 NULL, "12.34.56PM", "1970 01 01 12:34:56",
1288 NULL, "12-34-56 PM", "1970 01 01 12:34:56",
1289 NULL, "12 : 34 : 56 PM", "1970 01 01 12:34:56",
1290
1291 "MM d yy 'at' hh:mm:ss a", "04/05/06 12:34:56 PM", "2006 04 05 12:34:56",
1292
1293 "MMMM dd yyyy hh:mm a", "September 27, 1964 21:56 PM", "1964 09 28 09:56:00",
1294 NULL, "November 4, 2008 0:13 AM", "2008 11 04 00:13:00",
1295
1296 "HH'h'mm'min'ss's'", "12h34min56s", "1970 01 01 12:34:56",
1297 NULL, "12h34mi56s", "1970 01 01 12:34:56",
1298 NULL, "12h34m56s", "1970 01 01 12:34:56",
1299 NULL, "12:34:56", "1970 01 01 12:34:56"
1300 };
1301 const int32_t DATA_len = sizeof(DATA)/sizeof(DATA[0]);
1302
1303 expectParse(DATA, DATA_len, Locale("en"));
1304 }
1305
1306 /**
1307 * Test handling of "HHmmss" pattern.
1308 */
1309 void DateFormatTest::TestExactCountFormat() {
1310 const char* DATA[] = {
1311 "yyyy MM dd HH:mm:ss",
1312
1313 // pattern, input, expected parse or NULL if expect parse failure
1314 "HHmmss", "123456", "1970 01 01 12:34:56",
1315 NULL, "12345", "1970 01 01 01:23:45",
1316 NULL, "1234", NULL,
1317 NULL, "00-05", NULL,
1318 NULL, "12-34", NULL,
1319 NULL, "00+05", NULL,
1320 "ahhmm", "PM730", "1970 01 01 19:30:00",
1321 };
1322 const int32_t DATA_len = sizeof(DATA)/sizeof(DATA[0]);
1323
1324 expectParse(DATA, DATA_len, Locale("en"));
1325 }
1326
1327 /**
1328 * Test handling of white space.
1329 */
1330 void DateFormatTest::TestWhiteSpaceParsing() {
1331 const char* DATA[] = {
1332 "yyyy MM dd",
1333
1334 // pattern, input, expected parse or null if expect parse failure
1335
1336 // Pattern space run should parse input text space run
1337 "MM d yy", " 04 01 03", "2003 04 01",
1338 NULL, " 04 01 03 ", "2003 04 01",
1339 };
1340 const int32_t DATA_len = sizeof(DATA)/sizeof(DATA[0]);
1341
1342 expectParse(DATA, DATA_len, Locale("en"));
1343 }
1344
1345
1346 void DateFormatTest::TestInvalidPattern() {
1347 UErrorCode ec = U_ZERO_ERROR;
1348 SimpleDateFormat f(UnicodeString("Yesterday"), ec);
1349 if (U_FAILURE(ec)) {
1350 dataerrln("Fail construct SimpleDateFormat: %s", u_errorName(ec));
1351 return;
1352 }
1353 UnicodeString out;
1354 FieldPosition pos;
1355 f.format((UDate)0, out, pos);
1356 logln(out);
1357 // The bug is that the call to format() will crash. By not
1358 // crashing, the test passes.
1359 }
1360
1361 void DateFormatTest::TestGreekMay() {
1362 UErrorCode ec = U_ZERO_ERROR;
1363 UDate date = -9896080848000.0;
1364 SimpleDateFormat fmt("EEEE, dd MMMM yyyy h:mm:ss a", Locale("el", "", ""), ec);
1365 if (U_FAILURE(ec)) {
1366 dataerrln("Fail construct SimpleDateFormat: %s", u_errorName(ec));
1367 return;
1368 }
1369 UnicodeString str;
1370 fmt.format(date, str);
1371 ParsePosition pos(0);
1372 UDate d2 = fmt.parse(str, pos);
1373 if (date != d2) {
1374 errln("FAIL: unable to parse strings where case-folding changes length");
1375 }
1376 }
1377
1378 void DateFormatTest::TestStandAloneMonths()
1379 {
1380 const char *EN_DATA[] = {
1381 "yyyy MM dd HH:mm:ss",
1382
1383 "yyyy LLLL dd H:mm:ss", "fp", "2004 03 10 16:36:31", "2004 March 10 16:36:31", "2004 03 10 16:36:31",
1384 "yyyy LLL dd H:mm:ss", "fp", "2004 03 10 16:36:31", "2004 Mar 10 16:36:31", "2004 03 10 16:36:31",
1385 "yyyy LLLL dd H:mm:ss", "F", "2004 03 10 16:36:31", "2004 March 10 16:36:31",
1386 "yyyy LLL dd H:mm:ss", "pf", "2004 Mar 10 16:36:31", "2004 03 10 16:36:31", "2004 Mar 10 16:36:31",
1387
1388 "LLLL", "fp", "1970 01 01 0:00:00", "January", "1970 01 01 0:00:00",
1389 "LLLL", "fp", "1970 02 01 0:00:00", "February", "1970 02 01 0:00:00",
1390 "LLLL", "fp", "1970 03 01 0:00:00", "March", "1970 03 01 0:00:00",
1391 "LLLL", "fp", "1970 04 01 0:00:00", "April", "1970 04 01 0:00:00",
1392 "LLLL", "fp", "1970 05 01 0:00:00", "May", "1970 05 01 0:00:00",
1393 "LLLL", "fp", "1970 06 01 0:00:00", "June", "1970 06 01 0:00:00",
1394 "LLLL", "fp", "1970 07 01 0:00:00", "July", "1970 07 01 0:00:00",
1395 "LLLL", "fp", "1970 08 01 0:00:00", "August", "1970 08 01 0:00:00",
1396 "LLLL", "fp", "1970 09 01 0:00:00", "September", "1970 09 01 0:00:00",
1397 "LLLL", "fp", "1970 10 01 0:00:00", "October", "1970 10 01 0:00:00",
1398 "LLLL", "fp", "1970 11 01 0:00:00", "November", "1970 11 01 0:00:00",
1399 "LLLL", "fp", "1970 12 01 0:00:00", "December", "1970 12 01 0:00:00",
1400
1401 "LLL", "fp", "1970 01 01 0:00:00", "Jan", "1970 01 01 0:00:00",
1402 "LLL", "fp", "1970 02 01 0:00:00", "Feb", "1970 02 01 0:00:00",
1403 "LLL", "fp", "1970 03 01 0:00:00", "Mar", "1970 03 01 0:00:00",
1404 "LLL", "fp", "1970 04 01 0:00:00", "Apr", "1970 04 01 0:00:00",
1405 "LLL", "fp", "1970 05 01 0:00:00", "May", "1970 05 01 0:00:00",
1406 "LLL", "fp", "1970 06 01 0:00:00", "Jun", "1970 06 01 0:00:00",
1407 "LLL", "fp", "1970 07 01 0:00:00", "Jul", "1970 07 01 0:00:00",
1408 "LLL", "fp", "1970 08 01 0:00:00", "Aug", "1970 08 01 0:00:00",
1409 "LLL", "fp", "1970 09 01 0:00:00", "Sep", "1970 09 01 0:00:00",
1410 "LLL", "fp", "1970 10 01 0:00:00", "Oct", "1970 10 01 0:00:00",
1411 "LLL", "fp", "1970 11 01 0:00:00", "Nov", "1970 11 01 0:00:00",
1412 "LLL", "fp", "1970 12 01 0:00:00", "Dec", "1970 12 01 0:00:00",
1413 };
1414
1415 const char *CS_DATA[] = {
1416 "yyyy MM dd HH:mm:ss",
1417
1418 "yyyy LLLL dd H:mm:ss", "fp", "2004 04 10 16:36:31", "2004 duben 10 16:36:31", "2004 04 10 16:36:31",
1419 "yyyy MMMM dd H:mm:ss", "fp", "2004 04 10 16:36:31", "2004 dubna 10 16:36:31", "2004 04 10 16:36:31",
1420 "yyyy LLL dd H:mm:ss", "fp", "2004 04 10 16:36:31", "2004 4. 10 16:36:31", "2004 04 10 16:36:31",
1421 "yyyy LLLL dd H:mm:ss", "F", "2004 04 10 16:36:31", "2004 duben 10 16:36:31",
1422 "yyyy MMMM dd H:mm:ss", "F", "2004 04 10 16:36:31", "2004 dubna 10 16:36:31",
1423 "yyyy LLLL dd H:mm:ss", "pf", "2004 duben 10 16:36:31", "2004 04 10 16:36:31", "2004 duben 10 16:36:31",
1424 "yyyy MMMM dd H:mm:ss", "pf", "2004 dubna 10 16:36:31", "2004 04 10 16:36:31", "2004 dubna 10 16:36:31",
1425
1426 "LLLL", "fp", "1970 01 01 0:00:00", "leden", "1970 01 01 0:00:00",
1427 "LLLL", "fp", "1970 02 01 0:00:00", "\\u00FAnor", "1970 02 01 0:00:00",
1428 "LLLL", "fp", "1970 03 01 0:00:00", "b\\u0159ezen", "1970 03 01 0:00:00",
1429 "LLLL", "fp", "1970 04 01 0:00:00", "duben", "1970 04 01 0:00:00",
1430 "LLLL", "fp", "1970 05 01 0:00:00", "kv\\u011Bten", "1970 05 01 0:00:00",
1431 "LLLL", "fp", "1970 06 01 0:00:00", "\\u010Derven", "1970 06 01 0:00:00",
1432 "LLLL", "fp", "1970 07 01 0:00:00", "\\u010Dervenec", "1970 07 01 0:00:00",
1433 "LLLL", "fp", "1970 08 01 0:00:00", "srpen", "1970 08 01 0:00:00",
1434 "LLLL", "fp", "1970 09 01 0:00:00", "z\\u00E1\\u0159\\u00ED", "1970 09 01 0:00:00",
1435 "LLLL", "fp", "1970 10 01 0:00:00", "\\u0159\\u00EDjen", "1970 10 01 0:00:00",
1436 "LLLL", "fp", "1970 11 01 0:00:00", "listopad", "1970 11 01 0:00:00",
1437 "LLLL", "fp", "1970 12 01 0:00:00", "prosinec", "1970 12 01 0:00:00",
1438
1439 "LLL", "fp", "1970 01 01 0:00:00", "1.", "1970 01 01 0:00:00",
1440 "LLL", "fp", "1970 02 01 0:00:00", "2.", "1970 02 01 0:00:00",
1441 "LLL", "fp", "1970 03 01 0:00:00", "3.", "1970 03 01 0:00:00",
1442 "LLL", "fp", "1970 04 01 0:00:00", "4.", "1970 04 01 0:00:00",
1443 "LLL", "fp", "1970 05 01 0:00:00", "5.", "1970 05 01 0:00:00",
1444 "LLL", "fp", "1970 06 01 0:00:00", "6.", "1970 06 01 0:00:00",
1445 "LLL", "fp", "1970 07 01 0:00:00", "7.", "1970 07 01 0:00:00",
1446 "LLL", "fp", "1970 08 01 0:00:00", "8.", "1970 08 01 0:00:00",
1447 "LLL", "fp", "1970 09 01 0:00:00", "9.", "1970 09 01 0:00:00",
1448 "LLL", "fp", "1970 10 01 0:00:00", "10.", "1970 10 01 0:00:00",
1449 "LLL", "fp", "1970 11 01 0:00:00", "11.", "1970 11 01 0:00:00",
1450 "LLL", "fp", "1970 12 01 0:00:00", "12.", "1970 12 01 0:00:00",
1451 };
1452
1453 expect(EN_DATA, ARRAY_SIZE(EN_DATA), Locale("en", "", ""));
1454 expect(CS_DATA, ARRAY_SIZE(CS_DATA), Locale("cs", "", ""));
1455 }
1456
1457 void DateFormatTest::TestStandAloneDays()
1458 {
1459 const char *EN_DATA[] = {
1460 "yyyy MM dd HH:mm:ss",
1461
1462 "cccc", "fp", "1970 01 04 0:00:00", "Sunday", "1970 01 04 0:00:00",
1463 "cccc", "fp", "1970 01 05 0:00:00", "Monday", "1970 01 05 0:00:00",
1464 "cccc", "fp", "1970 01 06 0:00:00", "Tuesday", "1970 01 06 0:00:00",
1465 "cccc", "fp", "1970 01 07 0:00:00", "Wednesday", "1970 01 07 0:00:00",
1466 "cccc", "fp", "1970 01 01 0:00:00", "Thursday", "1970 01 01 0:00:00",
1467 "cccc", "fp", "1970 01 02 0:00:00", "Friday", "1970 01 02 0:00:00",
1468 "cccc", "fp", "1970 01 03 0:00:00", "Saturday", "1970 01 03 0:00:00",
1469
1470 "ccc", "fp", "1970 01 04 0:00:00", "Sun", "1970 01 04 0:00:00",
1471 "ccc", "fp", "1970 01 05 0:00:00", "Mon", "1970 01 05 0:00:00",
1472 "ccc", "fp", "1970 01 06 0:00:00", "Tue", "1970 01 06 0:00:00",
1473 "ccc", "fp", "1970 01 07 0:00:00", "Wed", "1970 01 07 0:00:00",
1474 "ccc", "fp", "1970 01 01 0:00:00", "Thu", "1970 01 01 0:00:00",
1475 "ccc", "fp", "1970 01 02 0:00:00", "Fri", "1970 01 02 0:00:00",
1476 "ccc", "fp", "1970 01 03 0:00:00", "Sat", "1970 01 03 0:00:00",
1477 };
1478
1479 const char *CS_DATA[] = {
1480 "yyyy MM dd HH:mm:ss",
1481
1482 "cccc", "fp", "1970 01 04 0:00:00", "ned\\u011Ble", "1970 01 04 0:00:00",
1483 "cccc", "fp", "1970 01 05 0:00:00", "pond\\u011Bl\\u00ED", "1970 01 05 0:00:00",
1484 "cccc", "fp", "1970 01 06 0:00:00", "\\u00FAter\\u00FD", "1970 01 06 0:00:00",
1485 "cccc", "fp", "1970 01 07 0:00:00", "st\\u0159eda", "1970 01 07 0:00:00",
1486 "cccc", "fp", "1970 01 01 0:00:00", "\\u010Dtvrtek", "1970 01 01 0:00:00",
1487 "cccc", "fp", "1970 01 02 0:00:00", "p\\u00E1tek", "1970 01 02 0:00:00",
1488 "cccc", "fp", "1970 01 03 0:00:00", "sobota", "1970 01 03 0:00:00",
1489
1490 "ccc", "fp", "1970 01 04 0:00:00", "ne", "1970 01 04 0:00:00",
1491 "ccc", "fp", "1970 01 05 0:00:00", "po", "1970 01 05 0:00:00",
1492 "ccc", "fp", "1970 01 06 0:00:00", "\\u00FAt", "1970 01 06 0:00:00",
1493 "ccc", "fp", "1970 01 07 0:00:00", "st", "1970 01 07 0:00:00",
1494 "ccc", "fp", "1970 01 01 0:00:00", "\\u010Dt", "1970 01 01 0:00:00",
1495 "ccc", "fp", "1970 01 02 0:00:00", "p\\u00E1", "1970 01 02 0:00:00",
1496 "ccc", "fp", "1970 01 03 0:00:00", "so", "1970 01 03 0:00:00",
1497 };
1498
1499 expect(EN_DATA, ARRAY_SIZE(EN_DATA), Locale("en", "", ""));
1500 expect(CS_DATA, ARRAY_SIZE(CS_DATA), Locale("cs", "", ""));
1501 }
1502
1503 void DateFormatTest::TestNarrowNames()
1504 {
1505 const char *EN_DATA[] = {
1506 "yyyy MM dd HH:mm:ss",
1507
1508 "yyyy MMMMM dd H:mm:ss", "2004 03 10 16:36:31", "2004 M 10 16:36:31",
1509 "yyyy LLLLL dd H:mm:ss", "2004 03 10 16:36:31", "2004 M 10 16:36:31",
1510
1511 "MMMMM", "1970 01 01 0:00:00", "J",
1512 "MMMMM", "1970 02 01 0:00:00", "F",
1513 "MMMMM", "1970 03 01 0:00:00", "M",
1514 "MMMMM", "1970 04 01 0:00:00", "A",
1515 "MMMMM", "1970 05 01 0:00:00", "M",
1516 "MMMMM", "1970 06 01 0:00:00", "J",
1517 "MMMMM", "1970 07 01 0:00:00", "J",
1518 "MMMMM", "1970 08 01 0:00:00", "A",
1519 "MMMMM", "1970 09 01 0:00:00", "S",
1520 "MMMMM", "1970 10 01 0:00:00", "O",
1521 "MMMMM", "1970 11 01 0:00:00", "N",
1522 "MMMMM", "1970 12 01 0:00:00", "D",
1523
1524 "LLLLL", "1970 01 01 0:00:00", "J",
1525 "LLLLL", "1970 02 01 0:00:00", "F",
1526 "LLLLL", "1970 03 01 0:00:00", "M",
1527 "LLLLL", "1970 04 01 0:00:00", "A",
1528 "LLLLL", "1970 05 01 0:00:00", "M",
1529 "LLLLL", "1970 06 01 0:00:00", "J",
1530 "LLLLL", "1970 07 01 0:00:00", "J",
1531 "LLLLL", "1970 08 01 0:00:00", "A",
1532 "LLLLL", "1970 09 01 0:00:00", "S",
1533 "LLLLL", "1970 10 01 0:00:00", "O",
1534 "LLLLL", "1970 11 01 0:00:00", "N",
1535 "LLLLL", "1970 12 01 0:00:00", "D",
1536
1537 "EEEEE", "1970 01 04 0:00:00", "S",
1538 "EEEEE", "1970 01 05 0:00:00", "M",
1539 "EEEEE", "1970 01 06 0:00:00", "T",
1540 "EEEEE", "1970 01 07 0:00:00", "W",
1541 "EEEEE", "1970 01 01 0:00:00", "T",
1542 "EEEEE", "1970 01 02 0:00:00", "F",
1543 "EEEEE", "1970 01 03 0:00:00", "S",
1544
1545 "ccccc", "1970 01 04 0:00:00", "S",
1546 "ccccc", "1970 01 05 0:00:00", "M",
1547 "ccccc", "1970 01 06 0:00:00", "T",
1548 "ccccc", "1970 01 07 0:00:00", "W",
1549 "ccccc", "1970 01 01 0:00:00", "T",
1550 "ccccc", "1970 01 02 0:00:00", "F",
1551 "ccccc", "1970 01 03 0:00:00", "S",
1552 };
1553
1554 const char *CS_DATA[] = {
1555 "yyyy MM dd HH:mm:ss",
1556
1557 "yyyy LLLLL dd H:mm:ss", "2004 04 10 16:36:31", "2004 d 10 16:36:31",
1558 "yyyy MMMMM dd H:mm:ss", "2004 04 10 16:36:31", "2004 4 10 16:36:31",
1559
1560 "MMMMM", "1970 01 01 0:00:00", "1",
1561 "MMMMM", "1970 02 01 0:00:00", "2",
1562 "MMMMM", "1970 03 01 0:00:00", "3",
1563 "MMMMM", "1970 04 01 0:00:00", "4",
1564 "MMMMM", "1970 05 01 0:00:00", "5",
1565 "MMMMM", "1970 06 01 0:00:00", "6",
1566 "MMMMM", "1970 07 01 0:00:00", "7",
1567 "MMMMM", "1970 08 01 0:00:00", "8",
1568 "MMMMM", "1970 09 01 0:00:00", "9",
1569 "MMMMM", "1970 10 01 0:00:00", "10",
1570 "MMMMM", "1970 11 01 0:00:00", "11",
1571 "MMMMM", "1970 12 01 0:00:00", "12",
1572
1573 "LLLLL", "1970 01 01 0:00:00", "l",
1574 "LLLLL", "1970 02 01 0:00:00", "\\u00FA",
1575 "LLLLL", "1970 03 01 0:00:00", "b",
1576 "LLLLL", "1970 04 01 0:00:00", "d",
1577 "LLLLL", "1970 05 01 0:00:00", "k",
1578 "LLLLL", "1970 06 01 0:00:00", "\\u010D",
1579 "LLLLL", "1970 07 01 0:00:00", "\\u010D",
1580 "LLLLL", "1970 08 01 0:00:00", "s",
1581 "LLLLL", "1970 09 01 0:00:00", "z",
1582 "LLLLL", "1970 10 01 0:00:00", "\\u0159",
1583 "LLLLL", "1970 11 01 0:00:00", "l",
1584 "LLLLL", "1970 12 01 0:00:00", "p",
1585
1586 "EEEEE", "1970 01 04 0:00:00", "N",
1587 "EEEEE", "1970 01 05 0:00:00", "P",
1588 "EEEEE", "1970 01 06 0:00:00", "\\u00DA",
1589 "EEEEE", "1970 01 07 0:00:00", "S",
1590 "EEEEE", "1970 01 01 0:00:00", "\\u010C",
1591 "EEEEE", "1970 01 02 0:00:00", "P",
1592 "EEEEE", "1970 01 03 0:00:00", "S",
1593
1594 "ccccc", "1970 01 04 0:00:00", "N",
1595 "ccccc", "1970 01 05 0:00:00", "P",
1596 "ccccc", "1970 01 06 0:00:00", "\\u00DA",
1597 "ccccc", "1970 01 07 0:00:00", "S",
1598 "ccccc", "1970 01 01 0:00:00", "\\u010C",
1599 "ccccc", "1970 01 02 0:00:00", "P",
1600 "ccccc", "1970 01 03 0:00:00", "S",
1601 };
1602
1603 expectFormat(EN_DATA, ARRAY_SIZE(EN_DATA), Locale("en", "", ""));
1604 expectFormat(CS_DATA, ARRAY_SIZE(CS_DATA), Locale("cs", "", ""));
1605 }
1606
1607 void DateFormatTest::TestEras()
1608 {
1609 const char *EN_DATA[] = {
1610 "yyyy MM dd",
1611
1612 "MMMM dd yyyy G", "fp", "1951 07 17", "July 17 1951 AD", "1951 07 17",
1613 "MMMM dd yyyy GG", "fp", "1951 07 17", "July 17 1951 AD", "1951 07 17",
1614 "MMMM dd yyyy GGG", "fp", "1951 07 17", "July 17 1951 AD", "1951 07 17",
1615 "MMMM dd yyyy GGGG", "fp", "1951 07 17", "July 17 1951 Anno Domini", "1951 07 17",
1616
1617 "MMMM dd yyyy G", "fp", "-438 07 17", "July 17 0439 BC", "-438 07 17",
1618 "MMMM dd yyyy GG", "fp", "-438 07 17", "July 17 0439 BC", "-438 07 17",
1619 "MMMM dd yyyy GGG", "fp", "-438 07 17", "July 17 0439 BC", "-438 07 17",
1620 "MMMM dd yyyy GGGG", "fp", "-438 07 17", "July 17 0439 Before Christ", "-438 07 17",
1621 };
1622
1623 expect(EN_DATA, ARRAY_SIZE(EN_DATA), Locale("en", "", ""));
1624 }
1625
1626 void DateFormatTest::TestQuarters()
1627 {
1628 const char *EN_DATA[] = {
1629 "yyyy MM dd",
1630
1631 "Q", "fp", "1970 01 01", "1", "1970 01 01",
1632 "QQ", "fp", "1970 04 01", "02", "1970 04 01",
1633 "QQQ", "fp", "1970 07 01", "Q3", "1970 07 01",
1634 "QQQQ", "fp", "1970 10 01", "4th quarter", "1970 10 01",
1635
1636 "q", "fp", "1970 01 01", "1", "1970 01 01",
1637 "qq", "fp", "1970 04 01", "02", "1970 04 01",
1638 "qqq", "fp", "1970 07 01", "Q3", "1970 07 01",
1639 "qqqq", "fp", "1970 10 01", "4th quarter", "1970 10 01",
1640 };
1641
1642 expect(EN_DATA, ARRAY_SIZE(EN_DATA), Locale("en", "", ""));
1643 }
1644
1645 /**
1646 * Test parsing. Input is an array that starts with the following
1647 * header:
1648 *
1649 * [0] = pattern string to parse [i+2] with
1650 *
1651 * followed by test cases, each of which is 3 array elements:
1652 *
1653 * [i] = pattern, or NULL to reuse prior pattern
1654 * [i+1] = input string
1655 * [i+2] = expected parse result (parsed with pattern [0])
1656 *
1657 * If expect parse failure, then [i+2] should be NULL.
1658 */
1659 void DateFormatTest::expectParse(const char** data, int32_t data_length,
1660 const Locale& loc) {
1661 const UDate FAIL = (UDate) -1;
1662 const UnicodeString FAIL_STR("parse failure");
1663 int32_t i = 0;
1664
1665 UErrorCode ec = U_ZERO_ERROR;
1666 SimpleDateFormat fmt("", loc, ec);
1667 SimpleDateFormat ref(data[i++], loc, ec);
1668 SimpleDateFormat gotfmt("G yyyy MM dd HH:mm:ss z", loc, ec);
1669 if (U_FAILURE(ec)) {
1670 dataerrln("FAIL: SimpleDateFormat constructor - %s", u_errorName(ec));
1671 return;
1672 }
1673
1674 const char* currentPat = NULL;
1675 while (i<data_length) {
1676 const char* pattern = data[i++];
1677 const char* input = data[i++];
1678 const char* expected = data[i++];
1679
1680 ec = U_ZERO_ERROR;
1681 if (pattern != NULL) {
1682 fmt.applyPattern(pattern);
1683 currentPat = pattern;
1684 }
1685 UDate got = fmt.parse(input, ec);
1686 UnicodeString gotstr(FAIL_STR);
1687 if (U_FAILURE(ec)) {
1688 got = FAIL;
1689 } else {
1690 gotstr.remove();
1691 gotfmt.format(got, gotstr);
1692 }
1693
1694 UErrorCode ec2 = U_ZERO_ERROR;
1695 UDate exp = FAIL;
1696 UnicodeString expstr(FAIL_STR);
1697 if (expected != NULL) {
1698 expstr = expected;
1699 exp = ref.parse(expstr, ec2);
1700 if (U_FAILURE(ec2)) {
1701 // This only happens if expected is in wrong format --
1702 // should never happen once test is debugged.
1703 errln("FAIL: Internal test error");
1704 return;
1705 }
1706 }
1707
1708 if (got == exp) {
1709 logln((UnicodeString)"Ok: " + input + " x " +
1710 currentPat + " => " + gotstr);
1711 } else {
1712 errln((UnicodeString)"FAIL: " + input + " x " +
1713 currentPat + " => " + gotstr + ", expected " +
1714 expstr);
1715 }
1716 }
1717 }
1718
1719 /**
1720 * Test formatting and parsing. Input is an array that starts
1721 * with the following header:
1722 *
1723 * [0] = pattern string to parse [i+2] with
1724 *
1725 * followed by test cases, each of which is 3 array elements:
1726 *
1727 * [i] = pattern, or null to reuse prior pattern
1728 * [i+1] = control string, either "fp", "pf", or "F".
1729 * [i+2..] = data strings
1730 *
1731 * The number of data strings depends on the control string.
1732 * Examples:
1733 * 1. "y/M/d H:mm:ss.SS", "fp", "2004 03 10 16:36:31.567", "2004/3/10 16:36:31.56", "2004 03 10 16:36:31.560",
1734 * 'f': Format date [i+2] (as parsed using pattern [0]) and expect string [i+3].
1735 * 'p': Parse string [i+3] and expect date [i+4].
1736 *
1737 * 2. "y/M/d H:mm:ss.SSS", "F", "2004 03 10 16:36:31.567", "2004/3/10 16:36:31.567"
1738 * 'F': Format date [i+2] and expect string [i+3],
1739 * then parse string [i+3] and expect date [i+2].
1740 *
1741 * 3. "y/M/d H:mm:ss.SSSS", "pf", "2004/3/10 16:36:31.5679", "2004 03 10 16:36:31.567", "2004/3/10 16:36:31.5670",
1742 * 'p': Parse string [i+2] and expect date [i+3].
1743 * 'f': Format date [i+3] and expect string [i+4].
1744 */
1745 void DateFormatTest::expect(const char** data, int32_t data_length,
1746 const Locale& loc) {
1747 int32_t i = 0;
1748 UErrorCode ec = U_ZERO_ERROR;
1749 UnicodeString str, str2;
1750 SimpleDateFormat fmt("", loc, ec);
1751 SimpleDateFormat ref(data[i++], loc, ec);
1752 SimpleDateFormat univ("EE G yyyy MM dd HH:mm:ss.SSS z", loc, ec);
1753 if (U_FAILURE(ec)) {
1754 dataerrln("Fail construct SimpleDateFormat: %s", u_errorName(ec));
1755 return;
1756 }
1757
1758 UnicodeString currentPat;
1759 while (i<data_length) {
1760 const char* pattern = data[i++];
1761 if (pattern != NULL) {
1762 fmt.applyPattern(pattern);
1763 currentPat = pattern;
1764 }
1765
1766 const char* control = data[i++];
1767
1768 if (uprv_strcmp(control, "fp") == 0) {
1769 // 'f'
1770 const char* datestr = data[i++];
1771 const char* string = data[i++];
1772 UDate date = ref.parse(ctou(datestr), ec);
1773 if (!assertSuccess("parse", ec)) return;
1774 assertEquals((UnicodeString)"\"" + currentPat + "\".format(" + datestr + ")",
1775 ctou(string),
1776 fmt.format(date, str.remove()));
1777 // 'p'
1778 datestr = data[i++];
1779 date = ref.parse(ctou(datestr), ec);
1780 if (!assertSuccess("parse", ec)) return;
1781 UDate parsedate = fmt.parse(ctou(string), ec);
1782 if (assertSuccess((UnicodeString)"\"" + currentPat + "\".parse(" + string + ")", ec)) {
1783 assertEquals((UnicodeString)"\"" + currentPat + "\".parse(" + string + ")",
1784 univ.format(date, str.remove()),
1785 univ.format(parsedate, str2.remove()));
1786 }
1787 }
1788
1789 else if (uprv_strcmp(control, "pf") == 0) {
1790 // 'p'
1791 const char* string = data[i++];
1792 const char* datestr = data[i++];
1793 UDate date = ref.parse(ctou(datestr), ec);
1794 if (!assertSuccess("parse", ec)) return;
1795 UDate parsedate = fmt.parse(ctou(string), ec);
1796 if (assertSuccess((UnicodeString)"\"" + currentPat + "\".parse(" + string + ")", ec)) {
1797 assertEquals((UnicodeString)"\"" + currentPat + "\".parse(" + string + ")",
1798 univ.format(date, str.remove()),
1799 univ.format(parsedate, str2.remove()));
1800 }
1801 // 'f'
1802 string = data[i++];
1803 assertEquals((UnicodeString)"\"" + currentPat + "\".format(" + datestr + ")",
1804 ctou(string),
1805 fmt.format(date, str.remove()));
1806 }
1807
1808 else if (uprv_strcmp(control, "F") == 0) {
1809 const char* datestr = data[i++];
1810 const char* string = data[i++];
1811 UDate date = ref.parse(ctou(datestr), ec);
1812 if (!assertSuccess("parse", ec)) return;
1813 assertEquals((UnicodeString)"\"" + currentPat + "\".format(" + datestr + ")",
1814 ctou(string),
1815 fmt.format(date, str.remove()));
1816
1817 UDate parsedate = fmt.parse(string, ec);
1818 if (assertSuccess((UnicodeString)"\"" + currentPat + "\".parse(" + string + ")", ec)) {
1819 assertEquals((UnicodeString)"\"" + currentPat + "\".parse(" + string + ")",
1820 univ.format(date, str.remove()),
1821 univ.format(parsedate, str2.remove()));
1822 }
1823 }
1824
1825 else {
1826 errln((UnicodeString)"FAIL: Invalid control string " + control);
1827 return;
1828 }
1829 }
1830 }
1831
1832 /**
1833 * Test formatting. Input is an array that starts
1834 * with the following header:
1835 *
1836 * [0] = pattern string to parse [i+2] with
1837 *
1838 * followed by test cases, each of which is 3 array elements:
1839 *
1840 * [i] = pattern, or null to reuse prior pattern
1841 * [i+1] = data string a
1842 * [i+2] = data string b
1843 *
1844 * Examples:
1845 * Format date [i+1] and expect string [i+2].
1846 *
1847 * "y/M/d H:mm:ss.SSSS", "2004/3/10 16:36:31.5679", "2004 03 10 16:36:31.567"
1848 */
1849 void DateFormatTest::expectFormat(const char** data, int32_t data_length,
1850 const Locale& loc) {
1851 int32_t i = 0;
1852 UErrorCode ec = U_ZERO_ERROR;
1853 UnicodeString str, str2;
1854 SimpleDateFormat fmt("", loc, ec);
1855 SimpleDateFormat ref(data[i++], loc, ec);
1856 SimpleDateFormat univ("EE G yyyy MM dd HH:mm:ss.SSS z", loc, ec);
1857 if (U_FAILURE(ec)) {
1858 dataerrln("Fail construct SimpleDateFormat: %s", u_errorName(ec));
1859 return;
1860 }
1861
1862 UnicodeString currentPat;
1863
1864 while (i<data_length) {
1865 const char* pattern = data[i++];
1866 if (pattern != NULL) {
1867 fmt.applyPattern(pattern);
1868 currentPat = pattern;
1869 }
1870
1871 const char* datestr = data[i++];
1872 const char* string = data[i++];
1873 UDate date = ref.parse(ctou(datestr), ec);
1874 if (!assertSuccess("parse", ec)) return;
1875 assertEquals((UnicodeString)"\"" + currentPat + "\".format(" + datestr + ")",
1876 ctou(string),
1877 fmt.format(date, str.remove()));
1878 }
1879 }
1880
1881 void DateFormatTest::TestGenericTime() {
1882 const Locale en("en");
1883 // Note: We no longer parse strings in different styles.
1884 /*
1885 const char* ZDATA[] = {
1886 "yyyy MM dd HH:mm zzz",
1887 // round trip
1888 "y/M/d H:mm zzzz", "F", "2004 01 01 01:00 PST", "2004/1/1 1:00 Pacific Standard Time",
1889 "y/M/d H:mm zzz", "F", "2004 01 01 01:00 PST", "2004/1/1 1:00 PST",
1890 "y/M/d H:mm vvvv", "F", "2004 01 01 01:00 PST", "2004/1/1 1:00 Pacific Time",
1891 "y/M/d H:mm v", "F", "2004 01 01 01:00 PST", "2004/1/1 1:00 PT",
1892 // non-generic timezone string influences dst offset even if wrong for date/time
1893 "y/M/d H:mm zzz", "pf", "2004/1/1 1:00 PDT", "2004 01 01 01:00 PDT", "2004/1/1 0:00 PST",
1894 "y/M/d H:mm vvvv", "pf", "2004/1/1 1:00 PDT", "2004 01 01 01:00 PDT", "2004/1/1 0:00 Pacific Time",
1895 "y/M/d H:mm zzz", "pf", "2004/7/1 1:00 PST", "2004 07 01 02:00 PDT", "2004/7/1 2:00 PDT",
1896 "y/M/d H:mm vvvv", "pf", "2004/7/1 1:00 PST", "2004 07 01 02:00 PDT", "2004/7/1 2:00 Pacific Time",
1897 // generic timezone generates dst offset appropriate for local time
1898 "y/M/d H:mm zzz", "pf", "2004/1/1 1:00 PT", "2004 01 01 01:00 PST", "2004/1/1 1:00 PST",
1899 "y/M/d H:mm vvvv", "pf", "2004/1/1 1:00 PT", "2004 01 01 01:00 PST", "2004/1/1 1:00 Pacific Time",
1900 "y/M/d H:mm zzz", "pf", "2004/7/1 1:00 PT", "2004 07 01 01:00 PDT", "2004/7/1 1:00 PDT",
1901 "y/M/d H:mm vvvv", "pf", "2004/7/1 1:00 PT", "2004 07 01 01:00 PDT", "2004/7/1 1:00 Pacific Time",
1902 // daylight savings time transition edge cases.
1903 // time to parse does not really exist, PT interpreted as earlier time
1904 "y/M/d H:mm zzz", "pf", "2005/4/3 2:30 PT", "2005 04 03 03:30 PDT", "2005/4/3 3:30 PDT",
1905 "y/M/d H:mm zzz", "pf", "2005/4/3 2:30 PST", "2005 04 03 03:30 PDT", "2005/4/3 3:30 PDT",
1906 "y/M/d H:mm zzz", "pf", "2005/4/3 2:30 PDT", "2005 04 03 01:30 PST", "2005/4/3 1:30 PST",
1907 "y/M/d H:mm v", "pf", "2005/4/3 2:30 PT", "2005 04 03 03:30 PDT", "2005/4/3 3:30 PT",
1908 "y/M/d H:mm v", "pf", "2005/4/3 2:30 PST", "2005 04 03 03:30 PDT", "2005/4/3 3:30 PT",
1909 "y/M/d H:mm v", "pf", "2005/4/3 2:30 PDT", "2005 04 03 01:30 PST", "2005/4/3 1:30 PT",
1910 "y/M/d H:mm", "pf", "2005/4/3 2:30", "2005 04 03 03:30 PDT", "2005/4/3 3:30",
1911 // time to parse is ambiguous, PT interpreted as later time
1912 "y/M/d H:mm zzz", "pf", "2005/10/30 1:30 PT", "2005 10 30 01:30 PST", "2005/10/30 1:30 PST",
1913 "y/M/d H:mm v", "pf", "2005/10/30 1:30 PT", "2005 10 30 01:30 PST", "2005/10/30 1:30 PT",
1914 "y/M/d H:mm", "pf", "2005/10/30 1:30 PT", "2005 10 30 01:30 PST", "2005/10/30 1:30",
1915
1916 "y/M/d H:mm zzz", "pf", "2004/10/31 1:30 PT", "2004 10 31 01:30 PST", "2004/10/31 1:30 PST",
1917 "y/M/d H:mm zzz", "pf", "2004/10/31 1:30 PST", "2004 10 31 01:30 PST", "2004/10/31 1:30 PST",
1918 "y/M/d H:mm zzz", "pf", "2004/10/31 1:30 PDT", "2004 10 31 01:30 PDT", "2004/10/31 1:30 PDT",
1919 "y/M/d H:mm v", "pf", "2004/10/31 1:30 PT", "2004 10 31 01:30 PST", "2004/10/31 1:30 PT",
1920 "y/M/d H:mm v", "pf", "2004/10/31 1:30 PST", "2004 10 31 01:30 PST", "2004/10/31 1:30 PT",
1921 "y/M/d H:mm v", "pf", "2004/10/31 1:30 PDT", "2004 10 31 01:30 PDT", "2004/10/31 1:30 PT",
1922 "y/M/d H:mm", "pf", "2004/10/31 1:30", "2004 10 31 01:30 PST", "2004/10/31 1:30",
1923 };
1924 */
1925 const char* ZDATA[] = {
1926 "yyyy MM dd HH:mm zzz",
1927 // round trip
1928 "y/M/d H:mm zzzz", "F", "2004 01 01 01:00 PST", "2004/1/1 1:00 Pacific Standard Time",
1929 "y/M/d H:mm zzz", "F", "2004 01 01 01:00 PST", "2004/1/1 1:00 PST",
1930 "y/M/d H:mm vvvv", "F", "2004 01 01 01:00 PST", "2004/1/1 1:00 Pacific Time",
1931 "y/M/d H:mm v", "F", "2004 01 01 01:00 PST", "2004/1/1 1:00 PT",
1932 // non-generic timezone string influences dst offset even if wrong for date/time
1933 "y/M/d H:mm zzz", "pf", "2004/1/1 1:00 PDT", "2004 01 01 01:00 PDT", "2004/1/1 0:00 PST",
1934 "y/M/d H:mm zzz", "pf", "2004/7/1 1:00 PST", "2004 07 01 02:00 PDT", "2004/7/1 2:00 PDT",
1935 // generic timezone generates dst offset appropriate for local time
1936 "y/M/d H:mm zzz", "pf", "2004/1/1 1:00 PST", "2004 01 01 01:00 PST", "2004/1/1 1:00 PST",
1937 "y/M/d H:mm vvvv", "pf", "2004/1/1 1:00 Pacific Time", "2004 01 01 01:00 PST", "2004/1/1 1:00 Pacific Time",
1938 "y/M/d H:mm zzz", "pf", "2004/7/1 1:00 PDT", "2004 07 01 01:00 PDT", "2004/7/1 1:00 PDT",
1939 "y/M/d H:mm vvvv", "pf", "2004/7/1 1:00 Pacific Time", "2004 07 01 01:00 PDT", "2004/7/1 1:00 Pacific Time",
1940 // daylight savings time transition edge cases.
1941 // time to parse does not really exist, PT interpreted as earlier time
1942 "y/M/d H:mm zzz", "pf", "2005/4/3 2:30 PST", "2005 04 03 03:30 PDT", "2005/4/3 3:30 PDT",
1943 "y/M/d H:mm zzz", "pf", "2005/4/3 2:30 PDT", "2005 04 03 01:30 PST", "2005/4/3 1:30 PST",
1944 "y/M/d H:mm v", "pf", "2005/4/3 2:30 PT", "2005 04 03 03:30 PDT", "2005/4/3 3:30 PT",
1945 "y/M/d H:mm", "pf", "2005/4/3 2:30", "2005 04 03 03:30 PDT", "2005/4/3 3:30",
1946 // time to parse is ambiguous, PT interpreted as later time
1947 "y/M/d H:mm v", "pf", "2005/10/30 1:30 PT", "2005 10 30 01:30 PST", "2005/10/30 1:30 PT",
1948 "y/M/d H:mm", "pf", "2005/10/30 1:30 PT", "2005 10 30 01:30 PST", "2005/10/30 1:30",
1949
1950 "y/M/d H:mm zzz", "pf", "2004/10/31 1:30 PST", "2004 10 31 01:30 PST", "2004/10/31 1:30 PST",
1951 "y/M/d H:mm zzz", "pf", "2004/10/31 1:30 PDT", "2004 10 31 01:30 PDT", "2004/10/31 1:30 PDT",
1952 "y/M/d H:mm v", "pf", "2004/10/31 1:30 PT", "2004 10 31 01:30 PST", "2004/10/31 1:30 PT",
1953 "y/M/d H:mm", "pf", "2004/10/31 1:30", "2004 10 31 01:30 PST", "2004/10/31 1:30",
1954 };
1955
1956 const int32_t ZDATA_length = sizeof(ZDATA)/ sizeof(ZDATA[0]);
1957 expect(ZDATA, ZDATA_length, en);
1958
1959 UErrorCode status = U_ZERO_ERROR;
1960
1961 logln("cross format/parse tests"); // Note: We no longer support cross format/parse
1962 UnicodeString basepat("yy/MM/dd H:mm ");
1963 SimpleDateFormat formats[] = {
1964 SimpleDateFormat(basepat + "vvv", en, status),
1965 SimpleDateFormat(basepat + "vvvv", en, status),
1966 SimpleDateFormat(basepat + "zzz", en, status),
1967 SimpleDateFormat(basepat + "zzzz", en, status)
1968 };
1969 if (U_FAILURE(status)) {
1970 dataerrln("Fail construct SimpleDateFormat: %s", u_errorName(status));
1971 return;
1972 }
1973 const int32_t formats_length = sizeof(formats)/sizeof(formats[0]);
1974
1975 UnicodeString test;
1976 SimpleDateFormat univ("yyyy MM dd HH:mm zzz", en, status);
1977 ASSERT_OK(status);
1978 const UnicodeString times[] = {
1979 "2004 01 02 03:04 PST",
1980 "2004 07 08 09:10 PDT"
1981 };
1982 int32_t times_length = sizeof(times)/sizeof(times[0]);
1983 for (int i = 0; i < times_length; ++i) {
1984 UDate d = univ.parse(times[i], status);
1985 logln(UnicodeString("\ntime: ") + d);
1986 for (int j = 0; j < formats_length; ++j) {
1987 test.remove();
1988 formats[j].format(d, test);
1989 logln("\ntest: '" + test + "'");
1990 for (int k = 0; k < formats_length; ++k) {
1991 UDate t = formats[k].parse(test, status);
1992 if (U_SUCCESS(status)) {
1993 if (d != t) {
1994 errln((UnicodeString)"FAIL: format " + k +
1995 " incorrectly parsed output of format " + j +
1996 " (" + test + "), returned " +
1997 dateToString(t) + " instead of " + dateToString(d));
1998 } else {
1999 logln((UnicodeString)"OK: format " + k + " parsed ok");
2000 }
2001 } else if (status == U_PARSE_ERROR) {
2002 errln((UnicodeString)"FAIL: format " + k +
2003 " could not parse output of format " + j +
2004 " (" + test + ")");
2005 }
2006 }
2007 }
2008 }
2009 }
2010
2011 void DateFormatTest::TestGenericTimeZoneOrder() {
2012 // generic times should parse the same no matter what the placement of the time zone string
2013
2014 // Note: We no longer support cross style format/parse
2015
2016 //const char* XDATA[] = {
2017 // "yyyy MM dd HH:mm zzz",
2018 // // standard time, explicit daylight/standard
2019 // "y/M/d H:mm zzz", "pf", "2004/1/1 1:00 PT", "2004 01 01 01:00 PST", "2004/1/1 1:00 PST",
2020 // "y/M/d zzz H:mm", "pf", "2004/1/1 PT 1:00", "2004 01 01 01:00 PST", "2004/1/1 PST 1:00",
2021 // "zzz y/M/d H:mm", "pf", "PT 2004/1/1 1:00", "2004 01 01 01:00 PST", "PST 2004/1/1 1:00",
2022
2023 // // standard time, generic
2024 // "y/M/d H:mm vvvv", "pf", "2004/1/1 1:00 PT", "2004 01 01 01:00 PST", "2004/1/1 1:00 Pacific Time",
2025 // "y/M/d vvvv H:mm", "pf", "2004/1/1 PT 1:00", "2004 01 01 01:00 PST", "2004/1/1 Pacific Time 1:00",
2026 // "vvvv y/M/d H:mm", "pf", "PT 2004/1/1 1:00", "2004 01 01 01:00 PST", "Pacific Time 2004/1/1 1:00",
2027
2028 // // dahylight time, explicit daylight/standard
2029 // "y/M/d H:mm zzz", "pf", "2004/7/1 1:00 PT", "2004 07 01 01:00 PDT", "2004/7/1 1:00 PDT",
2030 // "y/M/d zzz H:mm", "pf", "2004/7/1 PT 1:00", "2004 07 01 01:00 PDT", "2004/7/1 PDT 1:00",
2031 // "zzz y/M/d H:mm", "pf", "PT 2004/7/1 1:00", "2004 07 01 01:00 PDT", "PDT 2004/7/1 1:00",
2032
2033 // // daylight time, generic
2034 // "y/M/d H:mm vvvv", "pf", "2004/7/1 1:00 PT", "2004 07 01 01:00 PDT", "2004/7/1 1:00 Pacific Time",
2035 // "y/M/d vvvv H:mm", "pf", "2004/7/1 PT 1:00", "2004 07 01 01:00 PDT", "2004/7/1 Pacific Time 1:00",
2036 // "vvvv y/M/d H:mm", "pf", "PT 2004/7/1 1:00", "2004 07 01 01:00 PDT", "Pacific Time 2004/7/1 1:00",
2037 //};
2038 const char* XDATA[] = {
2039 "yyyy MM dd HH:mm zzz",
2040 // standard time, explicit daylight/standard
2041 "y/M/d H:mm zzz", "pf", "2004/1/1 1:00 PST", "2004 01 01 01:00 PST", "2004/1/1 1:00 PST",
2042 "y/M/d zzz H:mm", "pf", "2004/1/1 PST 1:00", "2004 01 01 01:00 PST", "2004/1/1 PST 1:00",
2043 "zzz y/M/d H:mm", "pf", "PST 2004/1/1 1:00", "2004 01 01 01:00 PST", "PST 2004/1/1 1:00",
2044
2045 // standard time, generic
2046 "y/M/d H:mm vvvv", "pf", "2004/1/1 1:00 Pacific Time", "2004 01 01 01:00 PST", "2004/1/1 1:00 Pacific Time",
2047 "y/M/d vvvv H:mm", "pf", "2004/1/1 Pacific Time 1:00", "2004 01 01 01:00 PST", "2004/1/1 Pacific Time 1:00",
2048 "vvvv y/M/d H:mm", "pf", "Pacific Time 2004/1/1 1:00", "2004 01 01 01:00 PST", "Pacific Time 2004/1/1 1:00",
2049
2050 // dahylight time, explicit daylight/standard
2051 "y/M/d H:mm zzz", "pf", "2004/7/1 1:00 PDT", "2004 07 01 01:00 PDT", "2004/7/1 1:00 PDT",
2052 "y/M/d zzz H:mm", "pf", "2004/7/1 PDT 1:00", "2004 07 01 01:00 PDT", "2004/7/1 PDT 1:00",
2053 "zzz y/M/d H:mm", "pf", "PDT 2004/7/1 1:00", "2004 07 01 01:00 PDT", "PDT 2004/7/1 1:00",
2054
2055 // daylight time, generic
2056 "y/M/d H:mm v", "pf", "2004/7/1 1:00 PT", "2004 07 01 01:00 PDT", "2004/7/1 1:00 PT",
2057 "y/M/d v H:mm", "pf", "2004/7/1 PT 1:00", "2004 07 01 01:00 PDT", "2004/7/1 PT 1:00",
2058 "v y/M/d H:mm", "pf", "PT 2004/7/1 1:00", "2004 07 01 01:00 PDT", "PT 2004/7/1 1:00",
2059 };
2060 const int32_t XDATA_length = sizeof(XDATA)/sizeof(XDATA[0]);
2061 Locale en("en");
2062 expect(XDATA, XDATA_length, en);
2063 }
2064
2065 void DateFormatTest::TestZTimeZoneParsing(void) {
2066 UErrorCode status = U_ZERO_ERROR;
2067 const Locale en("en");
2068 UnicodeString test;
2069 //SimpleDateFormat univ("yyyy-MM-dd'T'HH:mm Z", en, status);
2070 SimpleDateFormat univ("HH:mm Z", en, status);
2071 if (failure(status, "construct SimpleDateFormat", TRUE)) return;
2072 const TimeZone *t = TimeZone::getGMT();
2073 univ.setTimeZone(*t);
2074
2075 univ.setLenient(false);
2076 ParsePosition pp(0);
2077 struct {
2078 UnicodeString input;
2079 UnicodeString expected_result;
2080 } tests[] = {
2081 { "11:00 -0200", "13:00 +0000" },
2082 { "11:00 +0200", "09:00 +0000" },
2083 { "11:00 +0400", "07:00 +0000" },
2084 { "11:00 +0530", "05:30 +0000" }
2085 };
2086
2087 UnicodeString result;
2088 int32_t tests_length = sizeof(tests)/sizeof(tests[0]);
2089 for (int i = 0; i < tests_length; ++i) {
2090 pp.setIndex(0);
2091 UDate d = univ.parse(tests[i].input, pp);
2092 if(pp.getIndex() != tests[i].input.length()){
2093 errln("Test %i: setZoneString() did not succeed. Consumed: %i instead of %i",
2094 i, pp.getIndex(), tests[i].input.length());
2095 return;
2096 }
2097 result.remove();
2098 univ.format(d, result);
2099 if(result != tests[i].expected_result) {
2100 errln("Expected " + tests[i].expected_result
2101 + " got " + result);
2102 return;
2103 }
2104 logln("SUCCESS: Parsed " + tests[i].input
2105 + " got " + result
2106 + " expected " + tests[i].expected_result);
2107 }
2108 }
2109
2110 void DateFormatTest::TestHost(void)
2111 {
2112 #if U_PLATFORM_HAS_WIN32_API
2113 Win32DateTimeTest::testLocales(this);
2114 #endif
2115 }
2116
2117 // Relative Date Tests
2118
2119 void DateFormatTest::TestRelative(int daysdelta,
2120 const Locale& loc,
2121 const char *expectChars) {
2122 char banner[25];
2123 sprintf(banner, "%d", daysdelta);
2124 UnicodeString bannerStr(banner, "");
2125
2126 UErrorCode status = U_ZERO_ERROR;
2127
2128 FieldPosition pos(0);
2129 UnicodeString test;
2130 Locale en("en");
2131 DateFormat *fullrelative = DateFormat::createDateInstance(DateFormat::kFullRelative, loc);
2132
2133 if (fullrelative == NULL) {
2134 dataerrln("DateFormat::createDateInstance(DateFormat::kFullRelative, %s) returned NULL", loc.getName());
2135 return;
2136 }
2137
2138 DateFormat *full = DateFormat::createDateInstance(DateFormat::kFull , loc);
2139
2140 if (full == NULL) {
2141 errln("DateFormat::createDateInstance(DateFormat::kFull, %s) returned NULL", loc.getName());
2142 return;
2143 }
2144
2145 DateFormat *en_full = DateFormat::createDateInstance(DateFormat::kFull, en);
2146
2147 if (en_full == NULL) {
2148 errln("DateFormat::createDateInstance(DateFormat::kFull, en) returned NULL");
2149 return;
2150 }
2151
2152 DateFormat *en_fulltime = DateFormat::createDateTimeInstance(DateFormat::kFull,DateFormat::kFull,en);
2153
2154 if (en_fulltime == NULL) {
2155 errln("DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull, en) returned NULL");
2156 return;
2157 }
2158
2159 UnicodeString result;
2160 UnicodeString normalResult;
2161 UnicodeString expect;
2162 UnicodeString parseResult;
2163
2164 Calendar *c = Calendar::createInstance(status);
2165
2166 // Today = Today
2167 c->setTime(Calendar::getNow(), status);
2168 if(daysdelta != 0) {
2169 c->add(Calendar::DATE,daysdelta,status);
2170 }
2171 ASSERT_OK(status);
2172
2173 // calculate the expected string
2174 if(expectChars != NULL) {
2175 expect = expectChars;
2176 } else {
2177 full->format(*c, expect, pos); // expected = normal full
2178 }
2179
2180 fullrelative ->format(*c, result, pos);
2181 en_full ->format(*c, normalResult, pos);
2182
2183 if(result != expect) {
2184 errln("FAIL: Relative Format ["+bannerStr+"] of "+normalResult+" failed, expected "+expect+" but got " + result);
2185 } else {
2186 logln("PASS: Relative Format ["+bannerStr+"] of "+normalResult+" got " + result);
2187 }
2188
2189
2190 //verify
2191 UDate d = fullrelative->parse(result, status);
2192 ASSERT_OK(status);
2193
2194 UnicodeString parseFormat; // parse rel->format full
2195 en_full->format(d, parseFormat, status);
2196
2197 UnicodeString origFormat;
2198 en_full->format(*c, origFormat, pos);
2199
2200 if(parseFormat!=origFormat) {
2201 errln("FAIL: Relative Parse ["+bannerStr+"] of "+result+" failed, expected "+parseFormat+" but got "+origFormat);
2202 } else {
2203 logln("PASS: Relative Parse ["+bannerStr+"] of "+result+" passed, got "+parseFormat);
2204 }
2205
2206 delete full;
2207 delete fullrelative;
2208 delete en_fulltime;
2209 delete en_full;
2210 delete c;
2211 }
2212
2213
2214 void DateFormatTest::TestRelative(void)
2215 {
2216 Locale en("en");
2217 TestRelative( 0, en, "Today");
2218 TestRelative(-1, en, "Yesterday");
2219 TestRelative( 1, en, "Tomorrow");
2220 TestRelative( 2, en, NULL);
2221 TestRelative( -2, en, NULL);
2222 TestRelative( 3, en, NULL);
2223 TestRelative( -3, en, NULL);
2224 TestRelative( 300, en, NULL);
2225 TestRelative( -300, en, NULL);
2226 }
2227
2228 void DateFormatTest::TestRelativeClone(void)
2229 {
2230 /*
2231 Verify that a cloned formatter gives the same results
2232 and is useable after the original has been deleted.
2233 */
2234 UErrorCode status = U_ZERO_ERROR;
2235 Locale loc("en");
2236 UDate now = Calendar::getNow();
2237 DateFormat *full = DateFormat::createDateInstance(DateFormat::kFullRelative, loc);
2238 if (full == NULL) {
2239 dataerrln("FAIL: Can't create Relative date instance");
2240 return;
2241 }
2242 UnicodeString result1;
2243 full->format(now, result1, status);
2244 Format *fullClone = full->clone();
2245 delete full;
2246 full = NULL;
2247
2248 UnicodeString result2;
2249 fullClone->format(now, result2, status);
2250 ASSERT_OK(status);
2251 if (result1 != result2) {
2252 errln("FAIL: Clone returned different result from non-clone.");
2253 }
2254 delete fullClone;
2255 }
2256
2257 void DateFormatTest::TestHostClone(void)
2258 {
2259 /*
2260 Verify that a cloned formatter gives the same results
2261 and is useable after the original has been deleted.
2262 */
2263 // This is mainly important on Windows.
2264 UErrorCode status = U_ZERO_ERROR;
2265 Locale loc("en_US@compat=host");
2266 UDate now = Calendar::getNow();
2267 DateFormat *full = DateFormat::createDateInstance(DateFormat::kFull, loc);
2268 if (full == NULL) {
2269 dataerrln("FAIL: Can't create Relative date instance");
2270 return;
2271 }
2272 UnicodeString result1;
2273 full->format(now, result1, status);
2274 Format *fullClone = full->clone();
2275 delete full;
2276 full = NULL;
2277
2278 UnicodeString result2;
2279 fullClone->format(now, result2, status);
2280 ASSERT_OK(status);
2281 if (result1 != result2) {
2282 errln("FAIL: Clone returned different result from non-clone.");
2283 }
2284 delete fullClone;
2285 }
2286
2287 void DateFormatTest::TestTimeZoneDisplayName()
2288 {
2289 // This test data was ported from ICU4J. Don't know why the 6th column in there because it's not being
2290 // used currently.
2291 const char *fallbackTests[][6] = {
2292 { "en", "America/Los_Angeles", "2004-01-15T00:00:00Z", "Z", "-0800", "-8:00" },
2293 { "en", "America/Los_Angeles", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-08:00", "-8:00" },
2294 { "en", "America/Los_Angeles", "2004-01-15T00:00:00Z", "ZZZZZ", "-08:00", "-8:00" },
2295 { "en", "America/Los_Angeles", "2004-01-15T00:00:00Z", "z", "PST", "America/Los_Angeles" },
2296 { "en", "America/Los_Angeles", "2004-01-15T00:00:00Z", "V", "PST", "America/Los_Angeles" },
2297 { "en", "America/Los_Angeles", "2004-01-15T00:00:00Z", "zzzz", "Pacific Standard Time", "America/Los_Angeles" },
2298 { "en", "America/Los_Angeles", "2004-07-15T00:00:00Z", "Z", "-0700", "-7:00" },
2299 { "en", "America/Los_Angeles", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-07:00", "-7:00" },
2300 { "en", "America/Los_Angeles", "2004-07-15T00:00:00Z", "z", "PDT", "America/Los_Angeles" },
2301 { "en", "America/Los_Angeles", "2004-07-15T00:00:00Z", "V", "PDT", "America/Los_Angeles" },
2302 { "en", "America/Los_Angeles", "2004-07-15T00:00:00Z", "zzzz", "Pacific Daylight Time", "America/Los_Angeles" },
2303 { "en", "America/Los_Angeles", "2004-07-15T00:00:00Z", "v", "PT", "America/Los_Angeles" },
2304 { "en", "America/Los_Angeles", "2004-07-15T00:00:00Z", "vvvv", "Pacific Time", "America/Los_Angeles" },
2305 { "en", "America/Los_Angeles", "2004-07-15T00:00:00Z", "VVVV", "United States Time (Los Angeles)", "America/Los_Angeles" },
2306 { "en_GB", "America/Los_Angeles", "2004-01-15T12:00:00Z", "z", "PST", "America/Los_Angeles" },
2307 { "en", "America/Phoenix", "2004-01-15T00:00:00Z", "Z", "-0700", "-7:00" },
2308 { "en", "America/Phoenix", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-07:00", "-7:00" },
2309 { "en", "America/Phoenix", "2004-01-15T00:00:00Z", "z", "MST", "America/Phoenix" },
2310 { "en", "America/Phoenix", "2004-01-15T00:00:00Z", "V", "MST", "America/Phoenix" },
2311 { "en", "America/Phoenix", "2004-01-15T00:00:00Z", "zzzz", "Mountain Standard Time", "America/Phoenix" },
2312 { "en", "America/Phoenix", "2004-07-15T00:00:00Z", "Z", "-0700", "-7:00" },
2313 { "en", "America/Phoenix", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-07:00", "-7:00" },
2314 { "en", "America/Phoenix", "2004-07-15T00:00:00Z", "z", "MST", "America/Phoenix" },
2315 { "en", "America/Phoenix", "2004-07-15T00:00:00Z", "V", "MST", "America/Phoenix" },
2316 { "en", "America/Phoenix", "2004-07-15T00:00:00Z", "zzzz", "Mountain Standard Time", "America/Phoenix" },
2317 { "en", "America/Phoenix", "2004-07-15T00:00:00Z", "v", "MST", "America/Phoenix" },
2318 { "en", "America/Phoenix", "2004-07-15T00:00:00Z", "vvvv", "Mountain Standard Time", "America/Phoenix" },
2319 { "en", "America/Phoenix", "2004-07-15T00:00:00Z", "VVVV", "United States Time (Phoenix)", "America/Phoenix" },
2320
2321 { "en", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2322 { "en", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2323 { "en", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2324 { "en", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "V", "GMT-03:00", "-3:00" },
2325 { "en", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "Argentina Standard Time", "-3:00" },
2326 { "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2327 { "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2328 { "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2329 { "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "V", "GMT-03:00", "-3:00" },
2330 { "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "Argentina Standard Time", "-3:00" },
2331 { "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "Argentina Time (Buenos Aires)", "America/Buenos_Aires" },
2332 { "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "Argentina Standard Time", "America/Buenos_Aires" },
2333 { "en", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "VVVV", "Argentina Time (Buenos Aires)", "America/Buenos_Aires" },
2334
2335 { "en", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2336 { "en", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2337 { "en", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2338 { "en", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "V", "GMT-03:00", "-3:00" },
2339 { "en", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "Argentina Standard Time", "-3:00" },
2340 { "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2341 { "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2342 { "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2343 { "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "V", "GMT-03:00", "-3:00" },
2344 { "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "Argentina Standard Time", "-3:00" },
2345 { "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "Argentina Time (Buenos Aires)", "America/Buenos_Aires" },
2346 { "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "Argentina Standard Time", "America/Buenos_Aires" },
2347 { "en", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "VVVV", "Argentina Time (Buenos Aires)", "America/Buenos_Aires" },
2348
2349 { "en", "America/Havana", "2004-01-15T00:00:00Z", "Z", "-0500", "-5:00" },
2350 { "en", "America/Havana", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-05:00", "-5:00" },
2351 { "en", "America/Havana", "2004-01-15T00:00:00Z", "z", "GMT-05:00", "-5:00" },
2352 { "en", "America/Havana", "2004-01-15T00:00:00Z", "V", "GMT-05:00", "-5:00" },
2353 { "en", "America/Havana", "2004-01-15T00:00:00Z", "zzzz", "Cuba Standard Time", "-5:00" },
2354 { "en", "America/Havana", "2004-07-15T00:00:00Z", "Z", "-0400", "-4:00" },
2355 { "en", "America/Havana", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-04:00", "-4:00" },
2356 { "en", "America/Havana", "2004-07-15T00:00:00Z", "z", "GMT-04:00", "-4:00" },
2357 { "en", "America/Havana", "2004-07-15T00:00:00Z", "V", "GMT-04:00", "-4:00" },
2358 { "en", "America/Havana", "2004-07-15T00:00:00Z", "zzzz", "Cuba Daylight Time", "-4:00" },
2359 { "en", "America/Havana", "2004-07-15T00:00:00Z", "v", "Cuba Time", "America/Havana" },
2360 { "en", "America/Havana", "2004-07-15T00:00:00Z", "vvvv", "Cuba Time", "America/Havana" },
2361 { "en", "America/Havana", "2004-07-15T00:00:00Z", "VVVV", "Cuba Time", "America/Havana" },
2362
2363 { "en", "Australia/ACT", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2364 { "en", "Australia/ACT", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+11:00", "+11:00" },
2365 { "en", "Australia/ACT", "2004-01-15T00:00:00Z", "z", "GMT+11:00", "+11:00" },
2366 { "en", "Australia/ACT", "2004-01-15T00:00:00Z", "V", "GMT+11:00", "+11:00" },
2367 { "en", "Australia/ACT", "2004-01-15T00:00:00Z", "zzzz", "Australian Eastern Daylight Time", "+11:00" },
2368 { "en", "Australia/ACT", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2369 { "en", "Australia/ACT", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+10:00", "+10:00" },
2370 { "en", "Australia/ACT", "2004-07-15T00:00:00Z", "z", "GMT+10:00", "+10:00" },
2371 { "en", "Australia/ACT", "2004-07-15T00:00:00Z", "V", "GMT+10:00", "+10:00" },
2372 { "en", "Australia/ACT", "2004-07-15T00:00:00Z", "zzzz", "Australian Eastern Standard Time", "+10:00" },
2373 { "en", "Australia/ACT", "2004-07-15T00:00:00Z", "v", "Australia Time (Sydney)", "Australia/Sydney" },
2374 { "en", "Australia/ACT", "2004-07-15T00:00:00Z", "vvvv", "Eastern Australia Time", "Australia/Sydney" },
2375 { "en", "Australia/ACT", "2004-07-15T00:00:00Z", "VVVV", "Australia Time (Sydney)", "Australia/Sydney" },
2376
2377 { "en", "Australia/Sydney", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2378 { "en", "Australia/Sydney", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+11:00", "+11:00" },
2379 { "en", "Australia/Sydney", "2004-01-15T00:00:00Z", "z", "GMT+11:00", "+11:00" },
2380 { "en", "Australia/Sydney", "2004-01-15T00:00:00Z", "V", "GMT+11:00", "+11:00" },
2381 { "en", "Australia/Sydney", "2004-01-15T00:00:00Z", "zzzz", "Australian Eastern Daylight Time", "+11:00" },
2382 { "en", "Australia/Sydney", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2383 { "en", "Australia/Sydney", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+10:00", "+10:00" },
2384 { "en", "Australia/Sydney", "2004-07-15T00:00:00Z", "z", "GMT+10:00", "+10:00" },
2385 { "en", "Australia/Sydney", "2004-07-15T00:00:00Z", "V", "GMT+10:00", "+10:00" },
2386 { "en", "Australia/Sydney", "2004-07-15T00:00:00Z", "zzzz", "Australian Eastern Standard Time", "+10:00" },
2387 { "en", "Australia/Sydney", "2004-07-15T00:00:00Z", "v", "Australia Time (Sydney)", "Australia/Sydney" },
2388 { "en", "Australia/Sydney", "2004-07-15T00:00:00Z", "vvvv", "Eastern Australia Time", "Australia/Sydney" },
2389 { "en", "Australia/Sydney", "2004-07-15T00:00:00Z", "VVVV", "Australia Time (Sydney)", "Australia/Sydney" },
2390
2391 { "en", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
2392 { "en", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT", "+0:00" },
2393 { "en", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
2394 { "en", "Europe/London", "2004-01-15T00:00:00Z", "V", "GMT", "+0:00" },
2395 { "en", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "Greenwich Mean Time", "+0:00" },
2396 { "en", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
2397 { "en", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
2398 { "en", "Europe/London", "2004-07-15T00:00:00Z", "z", "GMT+01:00", "Europe/London" },
2399 { "en", "Europe/London", "2004-07-15T00:00:00Z", "V", "GMT+01:00", "Europe/London" },
2400 { "en", "Europe/London", "2004-07-15T00:00:00Z", "zzzz", "British Summer Time", "Europe/London" },
2401 // icu en.txt has exemplar city for this time zone
2402 { "en", "Europe/London", "2004-07-15T00:00:00Z", "v", "United Kingdom Time", "Europe/London" },
2403 { "en", "Europe/London", "2004-07-15T00:00:00Z", "vvvv", "United Kingdom Time", "Europe/London" },
2404 { "en", "Europe/London", "2004-07-15T00:00:00Z", "VVVV", "United Kingdom Time", "Europe/London" },
2405
2406 { "en", "Etc/GMT+3", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2407 { "en", "Etc/GMT+3", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2408 { "en", "Etc/GMT+3", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2409 { "en", "Etc/GMT+3", "2004-01-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2410 { "en", "Etc/GMT+3", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2411 { "en", "Etc/GMT+3", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2412 { "en", "Etc/GMT+3", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2413 { "en", "Etc/GMT+3", "2004-07-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2414 { "en", "Etc/GMT+3", "2004-07-15T00:00:00Z", "v", "GMT-03:00", "-3:00" },
2415 { "en", "Etc/GMT+3", "2004-07-15T00:00:00Z", "vvvv", "GMT-03:00", "-3:00" },
2416
2417 // JB#5150
2418 { "en", "Asia/Calcutta", "2004-01-15T00:00:00Z", "Z", "+0530", "+5:30" },
2419 { "en", "Asia/Calcutta", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
2420 { "en", "Asia/Calcutta", "2004-01-15T00:00:00Z", "z", "GMT+05:30", "+5:30" },
2421 { "en", "Asia/Calcutta", "2004-01-15T00:00:00Z", "V", "GMT+05:30", "+5:30" },
2422 { "en", "Asia/Calcutta", "2004-01-15T00:00:00Z", "zzzz", "India Standard Time", "+5:30" },
2423 { "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "Z", "+0530", "+5:30" },
2424 { "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
2425 { "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "z", "GMT+05:30", "+05:30" },
2426 { "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "V", "GMT+05:30", "+05:30" },
2427 { "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "zzzz", "India Standard Time", "+5:30" },
2428 { "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "India Time", "Asia/Calcutta" },
2429 { "en", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "India Standard Time", "Asia/Calcutta" },
2430
2431 // ==========
2432
2433 { "de", "America/Los_Angeles", "2004-01-15T00:00:00Z", "Z", "-0800", "-8:00" },
2434 { "de", "America/Los_Angeles", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-08:00", "-8:00" },
2435 { "de", "America/Los_Angeles", "2004-01-15T00:00:00Z", "z", "GMT-08:00", "-8:00" },
2436 { "de", "America/Los_Angeles", "2004-01-15T00:00:00Z", "zzzz", "Nordamerikanische Westk\\u00fcsten-Winterzeit", "-8:00" },
2437 { "de", "America/Los_Angeles", "2004-07-15T00:00:00Z", "Z", "-0700", "-7:00" },
2438 { "de", "America/Los_Angeles", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-07:00", "-7:00" },
2439 { "de", "America/Los_Angeles", "2004-07-15T00:00:00Z", "z", "GMT-07:00", "-7:00" },
2440 { "de", "America/Los_Angeles", "2004-07-15T00:00:00Z", "zzzz", "Nordamerikanische Westk\\u00fcsten-Sommerzeit", "-7:00" },
2441 { "de", "America/Los_Angeles", "2004-07-15T00:00:00Z", "v", "Vereinigte Staaten Zeit (Los Angeles)", "America/Los_Angeles" },
2442 { "de", "America/Los_Angeles", "2004-07-15T00:00:00Z", "vvvv", "Nordamerikanische Westk\\u00fcstenzeit", "America/Los_Angeles" },
2443
2444 { "de", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2445 { "de", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2446 { "de", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2447 { "de", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "Argentinische Winterzeit", "-3:00" },
2448 { "de", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2449 { "de", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2450 { "de", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2451 { "de", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "Argentinische Winterzeit", "-3:00" },
2452 { "de", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "Argentinien Zeit (Buenos Aires)", "America/Buenos_Aires" },
2453 { "de", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "Argentinische Winterzeit", "America/Buenos_Aires" },
2454
2455 { "de", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2456 { "de", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2457 { "de", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2458 { "de", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "Argentinische Winterzeit", "-3:00" },
2459 { "de", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2460 { "de", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2461 { "de", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2462 { "de", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "Argentinische Winterzeit", "-3:00" },
2463 { "de", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "Argentinien Zeit (Buenos Aires)", "America/Buenos_Aires" },
2464 { "de", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "Argentinische Winterzeit", "America/Buenos_Aires" },
2465
2466 { "de", "America/Havana", "2004-01-15T00:00:00Z", "Z", "-0500", "-5:00" },
2467 { "de", "America/Havana", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-05:00", "-5:00" },
2468 { "de", "America/Havana", "2004-01-15T00:00:00Z", "z", "GMT-05:00", "-5:00" },
2469 { "de", "America/Havana", "2004-01-15T00:00:00Z", "zzzz", "GMT-05:00", "-5:00" },
2470 { "de", "America/Havana", "2004-07-15T00:00:00Z", "Z", "-0400", "-4:00" },
2471 { "de", "America/Havana", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-04:00", "-4:00" },
2472 { "de", "America/Havana", "2004-07-15T00:00:00Z", "z", "GMT-04:00", "-4:00" },
2473 { "de", "America/Havana", "2004-07-15T00:00:00Z", "zzzz", "GMT-04:00", "-4:00" },
2474 { "de", "America/Havana", "2004-07-15T00:00:00Z", "v", "Kuba Zeit", "America/Havana" },
2475 { "de", "America/Havana", "2004-07-15T00:00:00Z", "vvvv", "Kuba Zeit", "America/Havana" },
2476 // added to test proper fallback of country name
2477 { "de_CH", "America/Havana", "2004-07-15T00:00:00Z", "v", "Kuba Zeit", "America/Havana" },
2478 { "de_CH", "America/Havana", "2004-07-15T00:00:00Z", "vvvv", "Kuba Zeit", "America/Havana" },
2479
2480 { "de", "Australia/ACT", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2481 { "de", "Australia/ACT", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+11:00", "+11:00" },
2482 { "de", "Australia/ACT", "2004-01-15T00:00:00Z", "z", "GMT+11:00", "+11:00" },
2483 { "de", "Australia/ACT", "2004-01-15T00:00:00Z", "zzzz", "Ostaustralische Sommerzeit", "+11:00" },
2484 { "de", "Australia/ACT", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2485 { "de", "Australia/ACT", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+10:00", "+10:00" },
2486 { "de", "Australia/ACT", "2004-07-15T00:00:00Z", "z", "GMT+10:00", "+10:00" },
2487 { "de", "Australia/ACT", "2004-07-15T00:00:00Z", "zzzz", "Ostaustralische Winterzeit", "+10:00" },
2488 { "de", "Australia/ACT", "2004-07-15T00:00:00Z", "v", "Australien Zeit (Sydney)", "Australia/Sydney" },
2489 { "de", "Australia/ACT", "2004-07-15T00:00:00Z", "vvvv", "Ostaustralische Zeit", "Australia/Sydney" },
2490
2491 { "de", "Australia/Sydney", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2492 { "de", "Australia/Sydney", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+11:00", "+11:00" },
2493 { "de", "Australia/Sydney", "2004-01-15T00:00:00Z", "z", "GMT+11:00", "+11:00" },
2494 { "de", "Australia/Sydney", "2004-01-15T00:00:00Z", "zzzz", "Ostaustralische Sommerzeit", "+11:00" },
2495 { "de", "Australia/Sydney", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2496 { "de", "Australia/Sydney", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+10:00", "+10:00" },
2497 { "de", "Australia/Sydney", "2004-07-15T00:00:00Z", "z", "GMT+10:00", "+10:00" },
2498 { "de", "Australia/Sydney", "2004-07-15T00:00:00Z", "zzzz", "Ostaustralische Winterzeit", "+10:00" },
2499 { "de", "Australia/Sydney", "2004-07-15T00:00:00Z", "v", "Australien Zeit (Sydney)", "Australia/Sydney" },
2500 { "de", "Australia/Sydney", "2004-07-15T00:00:00Z", "vvvv", "Ostaustralische Zeit", "Australia/Sydney" },
2501
2502 { "de", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
2503 { "de", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT", "+0:00" },
2504 { "de", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
2505 { "de", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "Mittlere Greenwich-Zeit", "+0:00" },
2506 { "de", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
2507 { "de", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
2508 { "de", "Europe/London", "2004-07-15T00:00:00Z", "z", "GMT+01:00", "+1:00" },
2509 { "de", "Europe/London", "2004-07-15T00:00:00Z", "zzzz", "GMT+01:00", "+1:00" },
2510 { "de", "Europe/London", "2004-07-15T00:00:00Z", "v", "Vereinigtes K\\u00f6nigreich Zeit", "Europe/London" },
2511 { "de", "Europe/London", "2004-07-15T00:00:00Z", "vvvv", "Vereinigtes K\\u00f6nigreich Zeit", "Europe/London" },
2512
2513 { "de", "Etc/GMT+3", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2514 { "de", "Etc/GMT+3", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2515 { "de", "Etc/GMT+3", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2516 { "de", "Etc/GMT+3", "2004-01-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2517 { "de", "Etc/GMT+3", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2518 { "de", "Etc/GMT+3", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2519 { "de", "Etc/GMT+3", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2520 { "de", "Etc/GMT+3", "2004-07-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2521 { "de", "Etc/GMT+3", "2004-07-15T00:00:00Z", "v", "GMT-03:00", "-3:00" },
2522 { "de", "Etc/GMT+3", "2004-07-15T00:00:00Z", "vvvv", "GMT-03:00", "-3:00" },
2523
2524 // JB#5150
2525 { "de", "Asia/Calcutta", "2004-01-15T00:00:00Z", "Z", "+0530", "+5:30" },
2526 { "de", "Asia/Calcutta", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
2527 { "de", "Asia/Calcutta", "2004-01-15T00:00:00Z", "z", "GMT+05:30", "+5:30" },
2528 { "de", "Asia/Calcutta", "2004-01-15T00:00:00Z", "zzzz", "Indische Zeit", "+5:30" },
2529 { "de", "Asia/Calcutta", "2004-07-15T00:00:00Z", "Z", "+0530", "+5:30" },
2530 { "de", "Asia/Calcutta", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
2531 { "de", "Asia/Calcutta", "2004-07-15T00:00:00Z", "z", "GMT+05:30", "+05:30" },
2532 { "de", "Asia/Calcutta", "2004-07-15T00:00:00Z", "zzzz", "Indische Zeit", "+5:30" },
2533 { "de", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "Indien Zeit", "Asia/Calcutta" },
2534 { "de", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "Indische Zeit", "Asia/Calcutta" },
2535
2536 // ==========
2537
2538 { "zh", "America/Los_Angeles", "2004-01-15T00:00:00Z", "Z", "-0800", "-8:00" },
2539 { "zh", "America/Los_Angeles", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-0800", "-8:00" },
2540 { "zh", "America/Los_Angeles", "2004-01-15T00:00:00Z", "z", "GMT-0800", "America/Los_Angeles" },
2541 { "zh", "America/Los_Angeles", "2004-01-15T00:00:00Z", "zzzz", "\\u592a\\u5e73\\u6d0b\\u6807\\u51c6\\u65f6\\u95f4", "America/Los_Angeles" },
2542 { "zh", "America/Los_Angeles", "2004-07-15T00:00:00Z", "Z", "-0700", "-7:00" },
2543 { "zh", "America/Los_Angeles", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-0700", "-7:00" },
2544 { "zh", "America/Los_Angeles", "2004-07-15T00:00:00Z", "z", "GMT-0700", "America/Los_Angeles" },
2545 { "zh", "America/Los_Angeles", "2004-07-15T00:00:00Z", "zzzz", "\\u592a\\u5e73\\u6d0b\\u590f\\u4ee4\\u65f6\\u95f4", "America/Los_Angeles" },
2546 // icu zh.txt has exemplar city for this time zone
2547 { "zh", "America/Los_Angeles", "2004-07-15T00:00:00Z", "v", "\\u7f8e\\u56fd\\u65F6\\u95F4\\uff08\\u6d1b\\u6749\\u77f6\\uff09", "America/Los_Angeles" },
2548 { "zh", "America/Los_Angeles", "2004-07-15T00:00:00Z", "vvvv", "\\u7f8e\\u56fd\\u592a\\u5e73\\u6d0b\\u65f6\\u95f4", "America/Los_Angeles" },
2549
2550 { "zh", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2551 { "zh", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-0300", "-3:00" },
2552 { "zh", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-0300", "-3:00" },
2553 { "zh", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "\\u963f\\u6839\\u5ef7\\u6807\\u51c6\\u65f6\\u95f4", "-3:00" },
2554 { "zh", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2555 { "zh", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-0300", "-3:00" },
2556 { "zh", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-0300", "-3:00" },
2557 { "zh", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "\\u963f\\u6839\\u5ef7\\u6807\\u51c6\\u65f6\\u95f4", "-3:00" },
2558 { "zh", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "\\u963f\\u6839\\u5ef7\\u65F6\\u95F4\\uff08\\u5e03\\u5b9c\\u8bfa\\u65af\\u827e\\u5229\\u65af\\uff09", "America/Buenos_Aires" },
2559 { "zh", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "\\u963f\\u6839\\u5ef7\\u6807\\u51c6\\u65f6\\u95f4", "America/Buenos_Aires" },
2560
2561 { "zh", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2562 { "zh", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-0300", "-3:00" },
2563 { "zh", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-0300", "-3:00" },
2564 { "zh", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "\\u963f\\u6839\\u5ef7\\u6807\\u51c6\\u65f6\\u95f4", "-3:00" },
2565 { "zh", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2566 { "zh", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-0300", "-3:00" },
2567 { "zh", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-0300", "-3:00" },
2568 { "zh", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "\\u963f\\u6839\\u5ef7\\u6807\\u51c6\\u65f6\\u95f4", "-3:00" },
2569 { "zh", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "\\u963f\\u6839\\u5ef7\\u65F6\\u95F4\\uff08\\u5e03\\u5b9c\\u8bfa\\u65af\\u827e\\u5229\\u65af\\uff09", "America/Buenos_Aires" },
2570 { "zh", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "\\u963f\\u6839\\u5ef7\\u6807\\u51c6\\u65f6\\u95f4", "America/Buenos_Aires" },
2571
2572 { "zh", "America/Havana", "2004-01-15T00:00:00Z", "Z", "-0500", "-5:00" },
2573 { "zh", "America/Havana", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-0500", "-5:00" },
2574 { "zh", "America/Havana", "2004-01-15T00:00:00Z", "z", "GMT-0500", "-5:00" },
2575 { "zh", "America/Havana", "2004-01-15T00:00:00Z", "zzzz", "\\u53e4\\u5df4\\u6807\\u51c6\\u65f6\\u95f4", "-5:00" },
2576 { "zh", "America/Havana", "2004-07-15T00:00:00Z", "Z", "-0400", "-4:00" },
2577 { "zh", "America/Havana", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-0400", "-4:00" },
2578 { "zh", "America/Havana", "2004-07-15T00:00:00Z", "z", "GMT-0400", "-4:00" },
2579 { "zh", "America/Havana", "2004-07-15T00:00:00Z", "zzzz", "\\u53e4\\u5df4\\u590f\\u4ee4\\u65f6\\u95f4", "-4:00" },
2580 { "zh", "America/Havana", "2004-07-15T00:00:00Z", "v", "\\u53e4\\u5df4\\u65f6\\u95f4", "America/Havana" },
2581 { "zh", "America/Havana", "2004-07-15T00:00:00Z", "vvvv", "\\u53e4\\u5df4\\u65f6\\u95f4", "America/Havana" },
2582
2583 { "zh", "Australia/ACT", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2584 { "zh", "Australia/ACT", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+1100", "+11:00" },
2585 { "zh", "Australia/ACT", "2004-01-15T00:00:00Z", "z", "GMT+1100", "+11:00" },
2586 { "zh", "Australia/ACT", "2004-01-15T00:00:00Z", "zzzz", "\\u6fb3\\u5927\\u5229\\u4e9a\\u4e1c\\u90e8\\u590f\\u4ee4\\u65f6\\u95f4", "+11:00" },
2587 { "zh", "Australia/ACT", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2588 { "zh", "Australia/ACT", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+1000", "+10:00" },
2589 { "zh", "Australia/ACT", "2004-07-15T00:00:00Z", "z", "GMT+1000", "+10:00" },
2590 { "zh", "Australia/ACT", "2004-07-15T00:00:00Z", "zzzz", "\\u6fb3\\u5927\\u5229\\u4e9a\\u4e1c\\u90e8\\u6807\\u51c6\\u65f6\\u95f4", "+10:00" },
2591 // icu zh.txt does not have info for this time zone
2592 { "zh", "Australia/ACT", "2004-07-15T00:00:00Z", "v", "\\u6fb3\\u5927\\u5229\\u4e9a\\u65F6\\u95F4\\uff08\\u6089\\u5c3c\\uff09", "Australia/Sydney" },
2593 { "zh", "Australia/ACT", "2004-07-15T00:00:00Z", "vvvv", "\\u6fb3\\u5927\\u5229\\u4e9a\\u4e1c\\u90e8\\u65f6\\u95f4", "Australia/Sydney" },
2594
2595 { "zh", "Australia/Sydney", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2596 { "zh", "Australia/Sydney", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+1100", "+11:00" },
2597 { "zh", "Australia/Sydney", "2004-01-15T00:00:00Z", "z", "GMT+1100", "+11:00" },
2598 { "zh", "Australia/Sydney", "2004-01-15T00:00:00Z", "zzzz", "\\u6fb3\\u5927\\u5229\\u4e9a\\u4e1c\\u90e8\\u590f\\u4ee4\\u65f6\\u95f4", "+11:00" },
2599 { "zh", "Australia/Sydney", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2600 { "zh", "Australia/Sydney", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+1000", "+10:00" },
2601 { "zh", "Australia/Sydney", "2004-07-15T00:00:00Z", "z", "GMT+1000", "+10:00" },
2602 { "zh", "Australia/Sydney", "2004-07-15T00:00:00Z", "zzzz", "\\u6fb3\\u5927\\u5229\\u4e9a\\u4e1c\\u90e8\\u6807\\u51c6\\u65f6\\u95f4", "+10:00" },
2603 { "zh", "Australia/Sydney", "2004-07-15T00:00:00Z", "v", "\\u6fb3\\u5927\\u5229\\u4e9a\\u65F6\\u95F4\\uff08\\u6089\\u5c3c\\uff09", "Australia/Sydney" },
2604 { "zh", "Australia/Sydney", "2004-07-15T00:00:00Z", "vvvv", "\\u6fb3\\u5927\\u5229\\u4e9a\\u4e1c\\u90e8\\u65f6\\u95f4", "Australia/Sydney" },
2605
2606 { "zh", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
2607 { "zh", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT", "+0:00" },
2608 { "zh", "Europe/London", "2004-01-15T00:00:00Z", "z", "\\u683C\\u6797\\u5C3C\\u6CBB\\u6807\\u51C6\\u65F6\\u95F4", "+0:00" },
2609 { "zh", "Europe/London", "2004-01-15T00:00:00Z", "V", "\\u683C\\u6797\\u5C3C\\u6CBB\\u6807\\u51C6\\u65F6\\u95F4", "+0:00" },
2610 { "zh", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT", "+0:00" },
2611 { "zh", "Europe/London", "2004-01-15T00:00:00Z", "z", "\\u683C\\u6797\\u5C3C\\u6CBB\\u6807\\u51C6\\u65F6\\u95F4", "+0:00" },
2612 { "zh", "Europe/London", "2004-01-15T00:00:00Z", "V", "\\u683C\\u6797\\u5C3C\\u6CBB\\u6807\\u51C6\\u65F6\\u95F4", "+0:00" },
2613 { "zh", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\\u683C\\u6797\\u5C3C\\u6CBB\\u6807\\u51C6\\u65F6\\u95F4", "+0:00" },
2614 { "zh", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
2615 { "zh", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+0100", "+1:00" },
2616 { "zh", "Europe/London", "2004-07-15T00:00:00Z", "z", "GMT+0100", "+1:00" },
2617 { "zh", "Europe/London", "2004-07-15T00:00:00Z", "V", "GMT+0100", "+1:00" },
2618 { "zh", "Europe/London", "2004-07-15T00:00:00Z", "zzzz", "GMT+0100", "+1:00" },
2619 { "zh", "Europe/London", "2004-07-15T00:00:00Z", "v", "\\u82f1\\u56fd\\u65f6\\u95f4", "Europe/London" },
2620 { "zh", "Europe/London", "2004-07-15T00:00:00Z", "vvvv", "\\u82f1\\u56fd\\u65f6\\u95f4", "Europe/London" },
2621 { "zh", "Europe/London", "2004-07-15T00:00:00Z", "VVVV", "\\u82f1\\u56fd\\u65f6\\u95f4", "Europe/London" },
2622
2623 { "zh", "Etc/GMT+3", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2624 { "zh", "Etc/GMT+3", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-0300", "-3:00" },
2625 { "zh", "Etc/GMT+3", "2004-01-15T00:00:00Z", "z", "GMT-0300", "-3:00" },
2626 { "zh", "Etc/GMT+3", "2004-01-15T00:00:00Z", "zzzz", "GMT-0300", "-3:00" },
2627 { "zh", "Etc/GMT+3", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2628 { "zh", "Etc/GMT+3", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-0300", "-3:00" },
2629 { "zh", "Etc/GMT+3", "2004-07-15T00:00:00Z", "z", "GMT-0300", "-3:00" },
2630 { "zh", "Etc/GMT+3", "2004-07-15T00:00:00Z", "zzzz", "GMT-0300", "-3:00" },
2631 { "zh", "Etc/GMT+3", "2004-07-15T00:00:00Z", "v", "GMT-0300", "-3:00" },
2632 { "zh", "Etc/GMT+3", "2004-07-15T00:00:00Z", "vvvv", "GMT-0300", "-3:00" },
2633
2634 // JB#5150
2635 { "zh", "Asia/Calcutta", "2004-01-15T00:00:00Z", "Z", "+0530", "+5:30" },
2636 { "zh", "Asia/Calcutta", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+0530", "+5:30" },
2637 { "zh", "Asia/Calcutta", "2004-01-15T00:00:00Z", "z", "GMT+0530", "+5:30" },
2638 { "zh", "Asia/Calcutta", "2004-01-15T00:00:00Z", "zzzz", "\\u5370\\u5ea6\\u6807\\u51c6\\u65f6\\u95f4", "+5:30" },
2639 { "zh", "Asia/Calcutta", "2004-07-15T00:00:00Z", "Z", "+0530", "+5:30" },
2640 { "zh", "Asia/Calcutta", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+0530", "+5:30" },
2641 { "zh", "Asia/Calcutta", "2004-07-15T00:00:00Z", "z", "GMT+0530", "+05:30" },
2642 { "zh", "Asia/Calcutta", "2004-07-15T00:00:00Z", "zzzz", "\\u5370\\u5ea6\\u6807\\u51c6\\u65f6\\u95f4", "+5:30" },
2643 { "zh", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "\\u5370\\u5ea6\\u65f6\\u95f4", "Asia/Calcutta" },
2644 { "zh", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "\\u5370\\u5ea6\\u6807\\u51c6\\u65f6\\u95f4", "Asia/Calcutta" },
2645
2646 // ==========
2647
2648 { "hi", "America/Los_Angeles", "2004-01-15T00:00:00Z", "Z", "-0800", "-8:00" },
2649 { "hi", "America/Los_Angeles", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-08:00", "-8:00" },
2650 { "hi", "America/Los_Angeles", "2004-01-15T00:00:00Z", "z", "GMT-08:00", "-8:00" },
2651 { "hi", "America/Los_Angeles", "2004-01-15T00:00:00Z", "zzzz", "\\u092a\\u094d\\u0930\\u0936\\u093e\\u0902\\u0924\\u0020\\u092e\\u093e\\u0928\\u0915\\u0020\\u0938\\u092e\\u092f", "-8:00" },
2652 { "hi", "America/Los_Angeles", "2004-07-15T00:00:00Z", "Z", "-0700", "-7:00" },
2653 { "hi", "America/Los_Angeles", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-07:00", "-7:00" },
2654 { "hi", "America/Los_Angeles", "2004-07-15T00:00:00Z", "z", "GMT-07:00", "-7:00" },
2655 { "hi", "America/Los_Angeles", "2004-07-15T00:00:00Z", "zzzz", "\\u092A\\u094D\\u0930\\u0936\\u093E\\u0902\\u0924 \\u0926\\u093F\\u0935\\u093E\\u0935\\u0932\\u094B\\u0915 \\u0938\\u092E\\u092F", "-7:00" },
2656 { "hi", "America/Los_Angeles", "2004-07-15T00:00:00Z", "v", "\\u0938\\u0902\\u092f\\u0941\\u0915\\u094d\\u0924 \\u0930\\u093e\\u091c\\u094d\\u092f \\u0905\\u092e\\u0947\\u0930\\u093f\\u0915\\u093e \\u0938\\u092E\\u092F (\\u0932\\u094b\\u0938 \\u090f\\u0902\\u091c\\u093f\\u0932\\u0947\\u0938)", "America/Los_Angeles" },
2657 { "hi", "America/Los_Angeles", "2004-07-15T00:00:00Z", "vvvv", "\\u092A\\u094D\\u0930\\u0936\\u093E\\u0902\\u0924 \\u0938\\u092E\\u092F", "America/Los_Angeles" },
2658
2659 { "hi", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2660 { "hi", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2661 { "hi", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2662 { "hi", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "\\u0905\\u0930\\u094D\\u091C\\u0947\\u0902\\u091F\\u0940\\u0928\\u093E \\u092E\\u093E\\u0928\\u0915 \\u0938\\u092E\\u092F", "-3:00" },
2663 { "hi", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2664 { "hi", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2665 { "hi", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2666 { "hi", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "\\u0905\\u0930\\u094D\\u091C\\u0947\\u0902\\u091F\\u0940\\u0928\\u093E \\u092E\\u093E\\u0928\\u0915 \\u0938\\u092E\\u092F", "-3:00" },
2667 { "hi", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "\\u0905\\u0930\\u094d\\u091c\\u0947\\u0928\\u094d\\u091f\\u0940\\u0928\\u093e \\u0938\\u092E\\u092F (\\u092c\\u094d\\u092f\\u0942\\u0928\\u0938 \\u0906\\u092f\\u0930\\u0938)", "America/Buenos_Aires" },
2668 { "hi", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "\\u0905\\u0930\\u094D\\u091C\\u0947\\u0902\\u091F\\u0940\\u0928\\u093E \\u092E\\u093E\\u0928\\u0915 \\u0938\\u092E\\u092F", "America/Buenos_Aires" },
2669
2670 { "hi", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2671 { "hi", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2672 { "hi", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2673 { "hi", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "\\u0905\\u0930\\u094D\\u091C\\u0947\\u0902\\u091F\\u0940\\u0928\\u093E \\u092E\\u093E\\u0928\\u0915 \\u0938\\u092E\\u092F", "-3:00" },
2674 { "hi", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2675 { "hi", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2676 { "hi", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2677 { "hi", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "\\u0905\\u0930\\u094D\\u091C\\u0947\\u0902\\u091F\\u0940\\u0928\\u093E \\u092E\\u093E\\u0928\\u0915 \\u0938\\u092E\\u092F", "-3:00" },
2678 { "hi", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "\\u0905\\u0930\\u094d\\u091c\\u0947\\u0928\\u094d\\u091f\\u0940\\u0928\\u093e \\u0938\\u092E\\u092F (\\u092c\\u094d\\u092f\\u0942\\u0928\\u0938 \\u0906\\u092f\\u0930\\u0938)", "America/Buenos_Aires" },
2679 { "hi", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "\\u0905\\u0930\\u094D\\u091C\\u0947\\u0902\\u091F\\u0940\\u0928\\u093E \\u092E\\u093E\\u0928\\u0915 \\u0938\\u092E\\u092F", "America/Buenos_Aires" },
2680
2681 { "hi", "America/Havana", "2004-01-15T00:00:00Z", "Z", "-0500", "-5:00" },
2682 { "hi", "America/Havana", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-05:00", "-5:00" },
2683 { "hi", "America/Havana", "2004-01-15T00:00:00Z", "z", "GMT-05:00", "-5:00" },
2684 { "hi", "America/Havana", "2004-01-15T00:00:00Z", "zzzz", "GMT-05:00", "-5:00" },
2685 { "hi", "America/Havana", "2004-07-15T00:00:00Z", "Z", "-0400", "-4:00" },
2686 { "hi", "America/Havana", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-04:00", "-4:00" },
2687 { "hi", "America/Havana", "2004-07-15T00:00:00Z", "z", "GMT-04:00", "-4:00" },
2688 { "hi", "America/Havana", "2004-07-15T00:00:00Z", "zzzz", "GMT-04:00", "-4:00" },
2689 { "hi", "America/Havana", "2004-07-15T00:00:00Z", "v", "\\u0915\\u094d\\u092f\\u0942\\u092c\\u093e \\u0938\\u092E\\u092F", "America/Havana" },
2690 { "hi", "America/Havana", "2004-07-15T00:00:00Z", "vvvv", "\\u0915\\u094d\\u092f\\u0942\\u092c\\u093e \\u0938\\u092E\\u092F", "America/Havana" },
2691
2692 { "hi", "Australia/ACT", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2693 { "hi", "Australia/ACT", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+11:00", "+11:00" },
2694 { "hi", "Australia/ACT", "2004-01-15T00:00:00Z", "z", "GMT+11:00", "+11:00" },
2695 { "hi", "Australia/ACT", "2004-01-15T00:00:00Z", "zzzz", "\\u0911\\u0938\\u094D\\u200D\\u091F\\u094D\\u0930\\u0947\\u0932\\u093F\\u092F\\u093E\\u0908 \\u092A\\u0942\\u0930\\u094D\\u0935\\u0940 \\u0926\\u093F\\u0935\\u093E\\u0935\\u0932\\u094B\\u0915 \\u0938\\u092E\\u092F", "+11:00" },
2696 { "hi", "Australia/ACT", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2697 { "hi", "Australia/ACT", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+10:00", "+10:00" },
2698 { "hi", "Australia/ACT", "2004-07-15T00:00:00Z", "z", "GMT+10:00", "+10:00" },
2699 { "hi", "Australia/ACT", "2004-07-15T00:00:00Z", "zzzz", "\\u0911\\u0938\\u094D\\u200D\\u091F\\u094D\\u0930\\u0947\\u0932\\u093F\\u092F\\u093E\\u0908 \\u092A\\u0942\\u0930\\u094D\\u0935\\u0940 \\u092E\\u093E\\u0928\\u0915 \\u0938\\u092E\\u092F", "+10:00" },
2700 { "hi", "Australia/ACT", "2004-07-15T00:00:00Z", "v", "\\u0911\\u0938\\u094d\\u091f\\u094d\\u0930\\u0947\\u0932\\u093f\\u092f\\u093e \\u0938\\u092E\\u092F (\\u0938\\u093f\\u0921\\u0928\\u0940)", "Australia/Sydney" },
2701 { "hi", "Australia/ACT", "2004-07-15T00:00:00Z", "vvvv", "\\u092A\\u0942\\u0930\\u094D\\u0935\\u0940 \\u0911\\u0938\\u094D\\u091F\\u094D\\u0930\\u0947\\u0932\\u093F\\u092F\\u093E\\u0908 \\u0938\\u092E\\u092F", "Australia/Sydney" },
2702
2703 { "hi", "Australia/Sydney", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2704 { "hi", "Australia/Sydney", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+11:00", "+11:00" },
2705 { "hi", "Australia/Sydney", "2004-01-15T00:00:00Z", "z", "GMT+11:00", "+11:00" },
2706 { "hi", "Australia/Sydney", "2004-01-15T00:00:00Z", "zzzz", "\\u0911\\u0938\\u094D\\u200D\\u091F\\u094D\\u0930\\u0947\\u0932\\u093F\\u092F\\u093E\\u0908 \\u092A\\u0942\\u0930\\u094D\\u0935\\u0940 \\u0926\\u093F\\u0935\\u093E\\u0935\\u0932\\u094B\\u0915 \\u0938\\u092E\\u092F", "+11:00" },
2707 { "hi", "Australia/Sydney", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2708 { "hi", "Australia/Sydney", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+10:00", "+10:00" },
2709 { "hi", "Australia/Sydney", "2004-07-15T00:00:00Z", "z", "GMT+10:00", "+10:00" },
2710 { "hi", "Australia/Sydney", "2004-07-15T00:00:00Z", "zzzz", "\\u0911\\u0938\\u094D\\u200D\\u091F\\u094D\\u0930\\u0947\\u0932\\u093F\\u092F\\u093E\\u0908 \\u092A\\u0942\\u0930\\u094D\\u0935\\u0940 \\u092E\\u093E\\u0928\\u0915 \\u0938\\u092E\\u092F", "+10:00" },
2711 { "hi", "Australia/Sydney", "2004-07-15T00:00:00Z", "v", "\\u0911\\u0938\\u094d\\u091f\\u094d\\u0930\\u0947\\u0932\\u093f\\u092f\\u093e \\u0938\\u092E\\u092F (\\u0938\\u093f\\u0921\\u0928\\u0940)", "Australia/Sydney" },
2712 { "hi", "Australia/Sydney", "2004-07-15T00:00:00Z", "vvvv", "\\u092A\\u0942\\u0930\\u094D\\u0935\\u0940 \\u0911\\u0938\\u094D\\u091F\\u094D\\u0930\\u0947\\u0932\\u093F\\u092F\\u093E\\u0908 \\u0938\\u092E\\u092F", "Australia/Sydney" },
2713
2714 { "hi", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
2715 { "hi", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT", "+0:00" },
2716 { "hi", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
2717 { "hi", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "GMT", "+0:00" },
2718 { "hi", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
2719 { "hi", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
2720 { "hi", "Europe/London", "2004-07-15T00:00:00Z", "z", "GMT+01:00", "+1:00" },
2721 { "hi", "Europe/London", "2004-07-15T00:00:00Z", "zzzz", "GMT+01:00", "+1:00" },
2722 { "hi", "Europe/London", "2004-07-15T00:00:00Z", "v", "\\u092C\\u094D\\u0930\\u093F\\u0924\\u0928 \\u0938\\u092E\\u092F", "Europe/London" },
2723 { "hi", "Europe/London", "2004-07-15T00:00:00Z", "vvvv", "\\u092C\\u094D\\u0930\\u093F\\u0924\\u0928 \\u0938\\u092E\\u092F", "Europe/London" },
2724
2725 { "hi", "Etc/GMT+3", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2726 { "hi", "Etc/GMT+3", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2727 { "hi", "Etc/GMT+3", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2728 { "hi", "Etc/GMT+3", "2004-01-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2729 { "hi", "Etc/GMT+3", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2730 { "hi", "Etc/GMT+3", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2731 { "hi", "Etc/GMT+3", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2732 { "hi", "Etc/GMT+3", "2004-07-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2733 { "hi", "Etc/GMT+3", "2004-07-15T00:00:00Z", "v", "GMT-03:00", "-3:00" },
2734 { "hi", "Etc/GMT+3", "2004-07-15T00:00:00Z", "vvvv", "GMT-03:00", "-3:00" },
2735
2736 { "hi", "Asia/Calcutta", "2004-01-15T00:00:00Z", "Z", "+0530", "+5:30" },
2737 { "hi", "Asia/Calcutta", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
2738 { "hi", "Asia/Calcutta", "2004-01-15T00:00:00Z", "z", "IST", "+5:30" },
2739 { "hi", "Asia/Calcutta", "2004-01-15T00:00:00Z", "zzzz", "\\u092D\\u093E\\u0930\\u0924\\u0940\\u092F \\u0938\\u092E\\u092F", "+5:30" },
2740 { "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "Z", "+0530", "+5:30" },
2741 { "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
2742 { "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "z", "IST", "+05:30" },
2743 { "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "zzzz", "\\u092D\\u093E\\u0930\\u0924\\u0940\\u092F \\u0938\\u092E\\u092F", "+5:30" },
2744 { "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "IST", "Asia/Calcutta" },
2745 { "hi", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "\\u092D\\u093E\\u0930\\u0924\\u0940\\u092F \\u0938\\u092E\\u092F", "Asia/Calcutta" },
2746
2747 // ==========
2748
2749 { "bg", "America/Los_Angeles", "2004-01-15T00:00:00Z", "Z", "-0800", "-8:00" },
2750 { "bg", "America/Los_Angeles", "2004-01-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0800", "-8:00" },
2751 { "bg", "America/Los_Angeles", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0800", "America/Los_Angeles" },
2752 { "bg", "America/Los_Angeles", "2004-01-15T00:00:00Z", "V", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0800", "America/Los_Angeles" },
2753 { "bg", "America/Los_Angeles", "2004-01-15T00:00:00Z", "zzzz", "\\u0422\\u0438\\u0445\\u043E\\u043E\\u043A\\u0435\\u0430\\u043D\\u0441\\u043A\\u0430 \\u0447\\u0430\\u0441\\u043E\\u0432\\u0430 \\u0437\\u043E\\u043D\\u0430", "America/Los_Angeles" },
2754 { "bg", "America/Los_Angeles", "2004-07-15T00:00:00Z", "Z", "-0700", "-7:00" },
2755 { "bg", "America/Los_Angeles", "2004-07-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0700", "-7:00" },
2756 { "bg", "America/Los_Angeles", "2004-07-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0700", "America/Los_Angeles" },
2757 { "bg", "America/Los_Angeles", "2004-07-15T00:00:00Z", "V", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0700", "America/Los_Angeles" },
2758 { "bg", "America/Los_Angeles", "2004-07-15T00:00:00Z", "zzzz", "\\u0422\\u0438\\u0445\\u043E\\u043E\\u043A\\u0435\\u0430\\u043D\\u0441\\u043A\\u0430 \\u043B\\u044F\\u0442\\u043D\\u0430 \\u0447\\u0430\\u0441\\u043E\\u0432\\u0430 \\u0437\\u043E\\u043D\\u0430", "America/Los_Angeles" },
2759 // icu bg.txt has exemplar city for this time zone
2760 { "bg", "America/Los_Angeles", "2004-07-15T00:00:00Z", "v", "\\u0421\\u0410\\u0429 \\u0432\\u0440\\u0435\\u043C\\u0435 (\\u041b\\u043e\\u0441 \\u0410\\u043d\\u0436\\u0435\\u043b\\u0438\\u0441)", "America/Los_Angeles" },
2761 { "bg", "America/Los_Angeles", "2004-07-15T00:00:00Z", "vvvv", "\\u0422\\u0438\\u0445\\u043E\\u043E\\u043A\\u0435\\u0430\\u043D\\u0441\\u043A\\u043E \\u0432\\u0440\\u0435\\u043C\\u0435", "America/Los_Angeles" },
2762 { "bg", "America/Los_Angeles", "2004-07-15T00:00:00Z", "VVVV", "\\u0421\\u0410\\u0429 \\u0432\\u0440\\u0435\\u043C\\u0435 (\\u041b\\u043e\\u0441 \\u0410\\u043d\\u0436\\u0435\\u043b\\u0438\\u0441)", "America/Los_Angeles" },
2763
2764 { "bg", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2765 { "bg", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2766 { "bg", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2767 { "bg", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "\\u0410\\u0440\\u0436\\u0435\\u043D\\u0442\\u0438\\u043D\\u0430", "-3:00" },
2768 { "bg", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2769 { "bg", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2770 { "bg", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2771 { "bg", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "\\u0410\\u0440\\u0436\\u0435\\u043D\\u0442\\u0438\\u043D\\u0430", "-3:00" },
2772 { "bg", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "\\u0410\\u0440\\u0436\\u0435\\u043d\\u0442\\u0438\\u043d\\u0430 \\u0432\\u0440\\u0435\\u043C\\u0435 (\\u0411\\u0443\\u0435\\u043D\\u043E\\u0441 \\u0410\\u0439\\u0440\\u0435\\u0441)", "America/Buenos_Aires" },
2773 { "bg", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "\\u0410\\u0440\\u0436\\u0435\\u043D\\u0442\\u0438\\u043D\\u0430", "America/Buenos_Aires" },
2774
2775 { "bg", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2776 { "bg", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2777 { "bg", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2778 { "bg", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "\\u0410\\u0440\\u0436\\u0435\\u043D\\u0442\\u0438\\u043D\\u0430", "-3:00" },
2779 { "bg", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2780 { "bg", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2781 { "bg", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2782 { "bg", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "\\u0410\\u0440\\u0436\\u0435\\u043D\\u0442\\u0438\\u043D\\u0430", "-3:00" },
2783 // icu bg.txt does not have info for this time zone
2784 { "bg", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "\\u0410\\u0440\\u0436\\u0435\\u043d\\u0442\\u0438\\u043d\\u0430 \\u0432\\u0440\\u0435\\u043C\\u0435 (\\u0411\\u0443\\u0435\\u043D\\u043E\\u0441 \\u0410\\u0439\\u0440\\u0435\\u0441)", "America/Buenos_Aires" },
2785 { "bg", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "\\u0410\\u0440\\u0436\\u0435\\u043D\\u0442\\u0438\\u043D\\u0430", "America/Buenos_Aires" },
2786
2787 { "bg", "America/Havana", "2004-01-15T00:00:00Z", "Z", "-0500", "-5:00" },
2788 { "bg", "America/Havana", "2004-01-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0500", "-5:00" },
2789 { "bg", "America/Havana", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0500", "-5:00" },
2790 { "bg", "America/Havana", "2004-01-15T00:00:00Z", "zzzz", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0500", "-5:00" },
2791 { "bg", "America/Havana", "2004-07-15T00:00:00Z", "Z", "-0400", "-4:00" },
2792 { "bg", "America/Havana", "2004-07-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0400", "-4:00" },
2793 { "bg", "America/Havana", "2004-07-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0400", "-4:00" },
2794 { "bg", "America/Havana", "2004-07-15T00:00:00Z", "zzzz", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0400", "-4:00" },
2795 { "bg", "America/Havana", "2004-07-15T00:00:00Z", "v", "\\u041a\\u0443\\u0431\\u0430 \\u0432\\u0440\\u0435\\u043C\\u0435", "America/Havana" },
2796 { "bg", "America/Havana", "2004-07-15T00:00:00Z", "vvvv", "\\u041a\\u0443\\u0431\\u0430 \\u0432\\u0440\\u0435\\u043C\\u0435", "America/Havana" },
2797
2798 { "bg", "Australia/ACT", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2799 { "bg", "Australia/ACT", "2004-01-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+1100", "+11:00" },
2800 { "bg", "Australia/ACT", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+1100", "+11:00" },
2801 { "bg", "Australia/ACT", "2004-01-15T00:00:00Z", "zzzz", "\\u0410\\u0432\\u0441\\u0442\\u0440\\u0430\\u043B\\u0438\\u044F \\u2013 \\u0438\\u0437\\u0442\\u043E\\u0447\\u043D\\u043E \\u043B\\u044F\\u0442\\u043D\\u043E \\u0447\\u0430\\u0441\\u043E\\u0432\\u043E \\u0432\\u0440\\u0435\\u043C\\u0435", "+11:00" },
2802 { "bg", "Australia/ACT", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2803 { "bg", "Australia/ACT", "2004-07-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+1000", "+10:00" },
2804 { "bg", "Australia/ACT", "2004-07-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+1000", "+10:00" },
2805 { "bg", "Australia/ACT", "2004-07-15T00:00:00Z", "zzzz", "\\u0410\\u0432\\u0441\\u0442\\u0440\\u0430\\u043B\\u0438\\u044F \\u2013 \\u0438\\u0437\\u0442\\u043E\\u0447\\u043D\\u043E \\u0441\\u0442\\u0430\\u043D\\u0434\\u0430\\u0440\\u0442\\u043D\\u043E \\u0432\\u0440\\u0435\\u043C\\u0435", "+10:00" },
2806 { "bg", "Australia/ACT", "2004-07-15T00:00:00Z", "v", "\\u0410\\u0432\\u0441\\u0442\\u0440\\u0430\\u043b\\u0438\\u044f \\u0432\\u0440\\u0435\\u043C\\u0435 (\\u0421\\u0438\\u0434\\u043D\\u0438)", "Australia/Sydney" },
2807 { "bg", "Australia/ACT", "2004-07-15T00:00:00Z", "vvvv", "\\u0410\\u0432\\u0441\\u0442\\u0440\\u0430\\u043B\\u0438\\u044F \\u2013 \\u0438\\u0437\\u0442\\u043E\\u0447\\u043D\\u043E \\u0432\\u0440\\u0435\\u043C\\u0435", "Australia/Sydney" },
2808
2809 { "bg", "Australia/Sydney", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2810 { "bg", "Australia/Sydney", "2004-01-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+1100", "+11:00" },
2811 { "bg", "Australia/Sydney", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+1100", "+11:00" },
2812 { "bg", "Australia/Sydney", "2004-01-15T00:00:00Z", "zzzz", "\\u0410\\u0432\\u0441\\u0442\\u0440\\u0430\\u043B\\u0438\\u044F \\u2013 \\u0438\\u0437\\u0442\\u043E\\u0447\\u043D\\u043E \\u043B\\u044F\\u0442\\u043D\\u043E \\u0447\\u0430\\u0441\\u043E\\u0432\\u043E \\u0432\\u0440\\u0435\\u043C\\u0435", "+11:00" },
2813 { "bg", "Australia/Sydney", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2814 { "bg", "Australia/Sydney", "2004-07-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+1000", "+10:00" },
2815 { "bg", "Australia/Sydney", "2004-07-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+1000", "+10:00" },
2816 { "bg", "Australia/Sydney", "2004-07-15T00:00:00Z", "zzzz", "\\u0410\\u0432\\u0441\\u0442\\u0440\\u0430\\u043B\\u0438\\u044F \\u2013 \\u0438\\u0437\\u0442\\u043E\\u0447\\u043D\\u043E \\u0441\\u0442\\u0430\\u043D\\u0434\\u0430\\u0440\\u0442\\u043D\\u043E \\u0432\\u0440\\u0435\\u043C\\u0435", "+10:00" },
2817 { "bg", "Australia/Sydney", "2004-07-15T00:00:00Z", "v", "\\u0410\\u0432\\u0441\\u0442\\u0440\\u0430\\u043b\\u0438\\u044f \\u0432\\u0440\\u0435\\u043C\\u0435 (\\u0421\\u0438\\u0434\\u043D\\u0438)", "Australia/Sydney" },
2818 { "bg", "Australia/Sydney", "2004-07-15T00:00:00Z", "vvvv", "\\u0410\\u0432\\u0441\\u0442\\u0440\\u0430\\u043B\\u0438\\u044F \\u2013 \\u0438\\u0437\\u0442\\u043E\\u0447\\u043D\\u043E \\u0432\\u0440\\u0435\\u043C\\u0435", "Australia/Sydney" },
2819
2820 { "bg", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
2821 { "bg", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447", "+0:00" },
2822 { "bg", "Europe/London", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447", "+0:00" },
2823 { "bg", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\\u0427\\u0430\\u0441\\u043E\\u0432\\u0430 \\u0437\\u043E\\u043D\\u0430 \\u0413\\u0440\\u0438\\u043D\\u0443\\u0438\\u0447", "+0:00" },
2824 { "bg", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
2825 { "bg", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+0100", "+1:00" },
2826 { "bg", "Europe/London", "2004-07-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+0100", "+1:00" },
2827 { "bg", "Europe/London", "2004-07-15T00:00:00Z", "zzzz", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+0100", "+1:00" },
2828 { "bg", "Europe/London", "2004-07-15T00:00:00Z", "v", "\\u041e\\u0431\\u0435\\u0434\\u0438\\u043d\\u0435\\u043d\\u043e \\u043a\\u0440\\u0430\\u043b\\u0441\\u0442\\u0432\\u043e \\u0432\\u0440\\u0435\\u043C\\u0435", "Europe/London" },
2829 { "bg", "Europe/London", "2004-07-15T00:00:00Z", "vvvv", "\\u041e\\u0431\\u0435\\u0434\\u0438\\u043d\\u0435\\u043d\\u043e \\u043a\\u0440\\u0430\\u043b\\u0441\\u0442\\u0432\\u043e \\u0432\\u0440\\u0435\\u043C\\u0435", "Europe/London" },
2830
2831 { "bg", "Etc/GMT+3", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2832 { "bg", "Etc/GMT+3", "2004-01-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2833 { "bg", "Etc/GMT+3", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2834 { "bg", "Etc/GMT+3", "2004-01-15T00:00:00Z", "zzzz", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2835 { "bg", "Etc/GMT+3", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2836 { "bg", "Etc/GMT+3", "2004-07-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2837 { "bg", "Etc/GMT+3", "2004-07-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2838 { "bg", "Etc/GMT+3", "2004-07-15T00:00:00Z", "zzzz", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2839 { "bg", "Etc/GMT+3", "2004-07-15T00:00:00Z", "v", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2840 { "bg", "Etc/GMT+3", "2004-07-15T00:00:00Z", "vvvv", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447-0300", "-3:00" },
2841
2842 // JB#5150
2843 { "bg", "Asia/Calcutta", "2004-01-15T00:00:00Z", "Z", "+0530", "+5:30" },
2844 { "bg", "Asia/Calcutta", "2004-01-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+0530", "+5:30" },
2845 { "bg", "Asia/Calcutta", "2004-01-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+0530", "+5:30" },
2846 { "bg", "Asia/Calcutta", "2004-01-15T00:00:00Z", "zzzz", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+0530", "+5:30" },
2847 { "bg", "Asia/Calcutta", "2004-07-15T00:00:00Z", "Z", "+0530", "+5:30" },
2848 { "bg", "Asia/Calcutta", "2004-07-15T00:00:00Z", "ZZZZ", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+0530", "+5:30" },
2849 { "bg", "Asia/Calcutta", "2004-07-15T00:00:00Z", "z", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+0530", "+05:30" },
2850 { "bg", "Asia/Calcutta", "2004-07-15T00:00:00Z", "zzzz", "\\u0413\\u0440\\u0438\\u0438\\u043D\\u0443\\u0438\\u0447+0530", "+5:30" },
2851 { "bg", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "\\u0418\\u043D\\u0434\\u0438\\u044F \\u0432\\u0440\\u0435\\u043C\\u0435", "Asia/Calcutta" },
2852 { "bg", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "\\u0418\\u043D\\u0434\\u0438\\u044F \\u0432\\u0440\\u0435\\u043C\\u0435", "Asia/Calcutta" },
2853 // ==========
2854
2855 { "ja", "America/Los_Angeles", "2004-01-15T00:00:00Z", "Z", "-0800", "-8:00" },
2856 { "ja", "America/Los_Angeles", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-08:00", "-8:00" },
2857 { "ja", "America/Los_Angeles", "2004-01-15T00:00:00Z", "z", "GMT-08:00", "America/Los_Angeles" },
2858 { "ja", "America/Los_Angeles", "2004-01-15T00:00:00Z", "V", "GMT-08:00", "America/Los_Angeles" },
2859 { "ja", "America/Los_Angeles", "2004-01-15T00:00:00Z", "zzzz", "\\u30a2\\u30e1\\u30ea\\u30ab\\u592a\\u5e73\\u6d0b\\u6a19\\u6e96\\u6642", "America/Los_Angeles" },
2860 { "ja", "America/Los_Angeles", "2004-07-15T00:00:00Z", "Z", "-0700", "-700" },
2861 { "ja", "America/Los_Angeles", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-07:00", "-7:00" },
2862 { "ja", "America/Los_Angeles", "2004-07-15T00:00:00Z", "z", "GMT-07:00", "America/Los_Angeles" },
2863 { "ja", "America/Los_Angeles", "2004-07-15T00:00:00Z", "V", "GMT-07:00", "America/Los_Angeles" },
2864 { "ja", "America/Los_Angeles", "2004-07-15T00:00:00Z", "zzzz", "\\u30a2\\u30e1\\u30ea\\u30ab\\u592a\\u5e73\\u6d0b\\u590f\\u6642\\u9593", "America/Los_Angeles" },
2865 // icu ja.txt has exemplar city for this time zone
2866 { "ja", "America/Los_Angeles", "2004-07-15T00:00:00Z", "v", "\\u30A2\\u30E1\\u30EA\\u30AB\\u5408\\u8846\\u56FD\\u6642\\u9593\\uFF08\\u30ed\\u30b5\\u30f3\\u30bc\\u30eb\\u30b9\\uFF09", "America/Los_Angeles" },
2867 { "ja", "America/Los_Angeles", "2004-07-15T00:00:00Z", "vvvv", "\\u30A2\\u30E1\\u30EA\\u30AB\\u592A\\u5e73\\u6D0B\\u6642\\u9593", "America/Los_Angeles" },
2868 { "ja", "America/Los_Angeles", "2004-07-15T00:00:00Z", "VVVV", "\\u30A2\\u30E1\\u30EA\\u30AB\\u5408\\u8846\\u56FD\\u6642\\u9593\\uFF08\\u30ed\\u30b5\\u30f3\\u30bc\\u30eb\\u30b9\\uFF09", "America/Los_Angeles" },
2869
2870 { "ja", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2871 { "ja", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2872 { "ja", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2873 { "ja", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "\\u30A2\\u30EB\\u30BC\\u30F3\\u30C1\\u30F3\\u6A19\\u6E96\\u6642", "-3:00" },
2874 { "ja", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2875 { "ja", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2876 { "ja", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2877 { "ja", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "\\u30A2\\u30EB\\u30BC\\u30F3\\u30C1\\u30F3\\u6A19\\u6E96\\u6642", "-3:00" },
2878 // icu ja.txt does not have info for this time zone
2879 { "ja", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "\\u30a2\\u30eb\\u30bc\\u30f3\\u30c1\\u30f3\\u6642\\u9593\\uFF08\\u30D6\\u30A8\\u30CE\\u30B9\\u30A2\\u30A4\\u30EC\\u30B9\\uFF09", "America/Buenos_Aires" },
2880 { "ja", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "\\u30A2\\u30EB\\u30BC\\u30F3\\u30C1\\u30F3\\u6A19\\u6E96\\u6642", "America/Buenos_Aires" },
2881
2882 { "ja", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2883 { "ja", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2884 { "ja", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2885 { "ja", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "\\u30A2\\u30EB\\u30BC\\u30F3\\u30C1\\u30F3\\u6A19\\u6E96\\u6642", "-3:00" },
2886 { "ja", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2887 { "ja", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2888 { "ja", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2889 { "ja", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "\\u30A2\\u30EB\\u30BC\\u30F3\\u30C1\\u30F3\\u6A19\\u6E96\\u6642", "-3:00" },
2890 { "ja", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "\\u30a2\\u30eb\\u30bc\\u30f3\\u30c1\\u30f3\\u6642\\u9593\\uFF08\\u30D6\\u30A8\\u30CE\\u30B9\\u30A2\\u30A4\\u30EC\\u30B9\\uFF09", "America/Buenos_Aires" },
2891 { "ja", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "\\u30A2\\u30EB\\u30BC\\u30F3\\u30C1\\u30F3\\u6A19\\u6E96\\u6642", "America/Buenos_Aires" },
2892
2893 { "ja", "America/Havana", "2004-01-15T00:00:00Z", "Z", "-0500", "-5:00" },
2894 { "ja", "America/Havana", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-05:00", "-5:00" },
2895 { "ja", "America/Havana", "2004-01-15T00:00:00Z", "z", "GMT-05:00", "-5:00" },
2896 { "ja", "America/Havana", "2004-01-15T00:00:00Z", "zzzz", "\\u30AD\\u30E5\\u30FC\\u30D0\\u6A19\\u6E96\\u6642", "-5:00" },
2897 { "ja", "America/Havana", "2004-07-15T00:00:00Z", "Z", "-0400", "-4:00" },
2898 { "ja", "America/Havana", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-04:00", "-4:00" },
2899 { "ja", "America/Havana", "2004-07-15T00:00:00Z", "z", "GMT-04:00", "-4:00" },
2900 { "ja", "America/Havana", "2004-07-15T00:00:00Z", "zzzz", "\\u30AD\\u30E5\\u30FC\\u30D0\\u590F\\u6642\\u9593", "-4:00" },
2901 { "ja", "America/Havana", "2004-07-15T00:00:00Z", "v", "\\u30ad\\u30e5\\u30fc\\u30d0\\u6642\\u9593", "America/Havana" },
2902 { "ja", "America/Havana", "2004-07-15T00:00:00Z", "vvvv", "\\u30ad\\u30e5\\u30fc\\u30d0\\u6642\\u9593", "America/Havana" },
2903
2904 { "ja", "Australia/ACT", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2905 { "ja", "Australia/ACT", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+11:00", "+11:00" },
2906 { "ja", "Australia/ACT", "2004-01-15T00:00:00Z", "z", "GMT+11:00", "+11:00" },
2907 { "ja", "Australia/ACT", "2004-01-15T00:00:00Z", "zzzz", "\\u30AA\\u30FC\\u30B9\\u30C8\\u30E9\\u30EA\\u30A2\\u6771\\u90E8\\u590F\\u6642\\u9593", "+11:00" },
2908 { "ja", "Australia/ACT", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2909 { "ja", "Australia/ACT", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+10:00", "+10:00" },
2910 { "ja", "Australia/ACT", "2004-07-15T00:00:00Z", "z", "GMT+10:00", "+10:00" },
2911 { "ja", "Australia/ACT", "2004-07-15T00:00:00Z", "zzzz", "\\u30AA\\u30FC\\u30B9\\u30C8\\u30E9\\u30EA\\u30A2\\u6771\\u90E8\\u6A19\\u6E96\\u6642", "+10:00" },
2912 // icu ja.txt does not have info for this time zone
2913 { "ja", "Australia/ACT", "2004-07-15T00:00:00Z", "v", "\\u30aa\\u30fc\\u30b9\\u30c8\\u30e9\\u30ea\\u30a2\\u6642\\u9593\\uFF08\\u30b7\\u30c9\\u30cb\\u30fc\\uFF09", "Australia/Sydney" },
2914 { "ja", "Australia/ACT", "2004-07-15T00:00:00Z", "vvvv", "\\u30AA\\u30FC\\u30B9\\u30C8\\u30E9\\u30EA\\u30A2\\u6771\\u90E8\\u6642\\u9593", "Australia/Sydney" },
2915
2916 { "ja", "Australia/Sydney", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
2917 { "ja", "Australia/Sydney", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+11:00", "+11:00" },
2918 { "ja", "Australia/Sydney", "2004-01-15T00:00:00Z", "z", "GMT+11:00", "+11:00" },
2919 { "ja", "Australia/Sydney", "2004-01-15T00:00:00Z", "zzzz", "\\u30AA\\u30FC\\u30B9\\u30C8\\u30E9\\u30EA\\u30A2\\u6771\\u90E8\\u590F\\u6642\\u9593", "+11:00" },
2920 { "ja", "Australia/Sydney", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
2921 { "ja", "Australia/Sydney", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+10:00", "+10:00" },
2922 { "ja", "Australia/Sydney", "2004-07-15T00:00:00Z", "z", "GMT+10:00", "+10:00" },
2923 { "ja", "Australia/Sydney", "2004-07-15T00:00:00Z", "zzzz", "\\u30AA\\u30FC\\u30B9\\u30C8\\u30E9\\u30EA\\u30A2\\u6771\\u90E8\\u6A19\\u6E96\\u6642", "+10:00" },
2924 { "ja", "Australia/Sydney", "2004-07-15T00:00:00Z", "v", "\\u30aa\\u30fc\\u30b9\\u30c8\\u30e9\\u30ea\\u30a2\\u6642\\u9593\\uFF08\\u30b7\\u30c9\\u30cb\\u30fc\\uFF09", "Australia/Sydney" },
2925 { "ja", "Australia/Sydney", "2004-07-15T00:00:00Z", "vvvv", "\\u30AA\\u30FC\\u30B9\\u30C8\\u30E9\\u30EA\\u30A2\\u6771\\u90E8\\u6642\\u9593", "Australia/Sydney" },
2926
2927 { "ja", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
2928 { "ja", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT", "+0:00" },
2929 { "ja", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
2930 { "ja", "Europe/London", "2004-01-15T00:00:00Z", "V", "GMT", "+0:00" },
2931 { "ja", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "\\u30B0\\u30EA\\u30CB\\u30C3\\u30B8\\u6A19\\u6E96\\u6642", "+0:00" },
2932 { "ja", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
2933 { "ja", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
2934 { "ja", "Europe/London", "2004-07-15T00:00:00Z", "z", "GMT+01:00", "+1:00" },
2935 { "ja", "Europe/London", "2004-07-15T00:00:00Z", "V", "GMT+01:00", "+1:00" },
2936 { "ja", "Europe/London", "2004-07-15T00:00:00Z", "zzzz", "GMT+01:00", "+1:00" },
2937 { "ja", "Europe/London", "2004-07-15T00:00:00Z", "v", "\\u30a4\\u30ae\\u30ea\\u30b9\\u6642\\u9593", "Europe/London" },
2938 { "ja", "Europe/London", "2004-07-15T00:00:00Z", "vvvv", "\\u30a4\\u30ae\\u30ea\\u30b9\\u6642\\u9593", "Europe/London" },
2939 { "ja", "Europe/London", "2004-07-15T00:00:00Z", "VVVV", "\\u30a4\\u30ae\\u30ea\\u30b9\\u6642\\u9593", "Europe/London" },
2940
2941 { "ja", "Etc/GMT+3", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2942 { "ja", "Etc/GMT+3", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2943 { "ja", "Etc/GMT+3", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2944 { "ja", "Etc/GMT+3", "2004-01-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2945 { "ja", "Etc/GMT+3", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2946 { "ja", "Etc/GMT+3", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2947 { "ja", "Etc/GMT+3", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2948 { "ja", "Etc/GMT+3", "2004-07-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2949 { "ja", "Etc/GMT+3", "2004-07-15T00:00:00Z", "v", "GMT-03:00", "-3:00" },
2950 { "ja", "Etc/GMT+3", "2004-07-15T00:00:00Z", "vvvv", "GMT-03:00", "-3:00" },
2951
2952 // JB#5150
2953 { "ja", "Asia/Calcutta", "2004-01-15T00:00:00Z", "Z", "+0530", "+5:30" },
2954 { "ja", "Asia/Calcutta", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
2955 { "ja", "Asia/Calcutta", "2004-01-15T00:00:00Z", "z", "GMT+05:30", "+5:30" },
2956 { "ja", "Asia/Calcutta", "2004-01-15T00:00:00Z", "zzzz", "\\u30A4\\u30F3\\u30C9\\u6A19\\u6E96\\u6642", "+5:30" },
2957 { "ja", "Asia/Calcutta", "2004-07-15T00:00:00Z", "Z", "+0530", "+5:30" },
2958 { "ja", "Asia/Calcutta", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
2959 { "ja", "Asia/Calcutta", "2004-07-15T00:00:00Z", "z", "GMT+05:30", "+05:30" },
2960 { "ja", "Asia/Calcutta", "2004-07-15T00:00:00Z", "zzzz", "\\u30A4\\u30F3\\u30C9\\u6A19\\u6E96\\u6642", "+5:30" },
2961 { "ja", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "\\u30A4\\u30F3\\u30C9\\u6642\\u9593", "Asia/Calcutta" },
2962 { "ja", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "\\u30A4\\u30F3\\u30C9\\u6A19\\u6E96\\u6642", "Asia/Calcutta" },
2963
2964 // ==========
2965
2966 { "ti", "America/Los_Angeles", "2004-01-15T00:00:00Z", "Z", "-0800", "-8:00" },
2967 { "ti", "America/Los_Angeles", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-08:00", "-8:00" },
2968 { "ti", "America/Los_Angeles", "2004-01-15T00:00:00Z", "z", "GMT-08:00", "-8:00" },
2969 { "ti", "America/Los_Angeles", "2004-01-15T00:00:00Z", "zzzz", "GMT-08:00", "-8:00" },
2970 { "ti", "America/Los_Angeles", "2004-07-15T00:00:00Z", "Z", "-0700", "-7:00" },
2971 { "ti", "America/Los_Angeles", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-07:00", "-7:00" },
2972 { "ti", "America/Los_Angeles", "2004-07-15T00:00:00Z", "z", "GMT-07:00", "-7:00" },
2973 { "ti", "America/Los_Angeles", "2004-07-15T00:00:00Z", "zzzz", "GMT-07:00", "-7:00" },
2974 { "ti", "America/Los_Angeles", "2004-07-15T00:00:00Z", "v", "US (Los Angeles)", "America/Los_Angeles" },
2975 { "ti", "America/Los_Angeles", "2004-07-15T00:00:00Z", "vvvv", "US (Los Angeles)", "America/Los_Angeles" },
2976
2977 { "ti", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2978 { "ti", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2979 { "ti", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2980 { "ti", "America/Argentina/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2981 { "ti", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2982 { "ti", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2983 { "ti", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2984 { "ti", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2985 { "ti", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "AR (Buenos Aires)", "America/Buenos_Aires" },
2986 { "ti", "America/Argentina/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "AR (Buenos Aires)", "America/Buenos_Aires" },
2987
2988 { "ti", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
2989 { "ti", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2990 { "ti", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2991 { "ti", "America/Buenos_Aires", "2004-01-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2992 { "ti", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
2993 { "ti", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
2994 { "ti", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
2995 { "ti", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
2996 { "ti", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "v", "AR (Buenos Aires)", "America/Buenos_Aires" },
2997 { "ti", "America/Buenos_Aires", "2004-07-15T00:00:00Z", "vvvv", "AR (Buenos Aires)", "America/Buenos_Aires" },
2998
2999 { "ti", "America/Havana", "2004-01-15T00:00:00Z", "Z", "-0500", "-5:00" },
3000 { "ti", "America/Havana", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-05:00", "-5:00" },
3001 { "ti", "America/Havana", "2004-01-15T00:00:00Z", "z", "GMT-05:00", "-5:00" },
3002 { "ti", "America/Havana", "2004-01-15T00:00:00Z", "zzzz", "GMT-05:00", "-5:00" },
3003 { "ti", "America/Havana", "2004-07-15T00:00:00Z", "Z", "-0400", "-4:00" },
3004 { "ti", "America/Havana", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-04:00", "-4:00" },
3005 { "ti", "America/Havana", "2004-07-15T00:00:00Z", "z", "GMT-04:00", "-4:00" },
3006 { "ti", "America/Havana", "2004-07-15T00:00:00Z", "zzzz", "GMT-04:00", "-4:00" },
3007 { "ti", "America/Havana", "2004-07-15T00:00:00Z", "v", "(CU)", "America/Havana" },
3008 { "ti", "America/Havana", "2004-07-15T00:00:00Z", "vvvv", "(CU)", "America/Havana" },
3009
3010 { "ti", "Australia/ACT", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
3011 { "ti", "Australia/ACT", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+11:00", "+11:00" },
3012 { "ti", "Australia/ACT", "2004-01-15T00:00:00Z", "z", "GMT+11:00", "+11:00" },
3013 { "ti", "Australia/ACT", "2004-01-15T00:00:00Z", "zzzz", "GMT+11:00", "+11:00" },
3014 { "ti", "Australia/ACT", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
3015 { "ti", "Australia/ACT", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+10:00", "+10:00" },
3016 { "ti", "Australia/ACT", "2004-07-15T00:00:00Z", "z", "GMT+10:00", "+10:00" },
3017 { "ti", "Australia/ACT", "2004-07-15T00:00:00Z", "zzzz", "GMT+10:00", "+10:00" },
3018 { "ti", "Australia/ACT", "2004-07-15T00:00:00Z", "v", "AU (Sydney)", "Australia/Sydney" },
3019 { "ti", "Australia/ACT", "2004-07-15T00:00:00Z", "vvvv", "AU (Sydney)", "Australia/Sydney" },
3020
3021 { "ti", "Australia/Sydney", "2004-01-15T00:00:00Z", "Z", "+1100", "+11:00" },
3022 { "ti", "Australia/Sydney", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+11:00", "+11:00" },
3023 { "ti", "Australia/Sydney", "2004-01-15T00:00:00Z", "z", "GMT+11:00", "+11:00" },
3024 { "ti", "Australia/Sydney", "2004-01-15T00:00:00Z", "zzzz", "GMT+11:00", "+11:00" },
3025 { "ti", "Australia/Sydney", "2004-07-15T00:00:00Z", "Z", "+1000", "+10:00" },
3026 { "ti", "Australia/Sydney", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+10:00", "+10:00" },
3027 { "ti", "Australia/Sydney", "2004-07-15T00:00:00Z", "z", "GMT+10:00", "+10:00" },
3028 { "ti", "Australia/Sydney", "2004-07-15T00:00:00Z", "zzzz", "GMT+10:00", "+10:00" },
3029 { "ti", "Australia/Sydney", "2004-07-15T00:00:00Z", "v", "AU (Sydney)", "Australia/Sydney" },
3030 { "ti", "Australia/Sydney", "2004-07-15T00:00:00Z", "vvvv", "AU (Sydney)", "Australia/Sydney" },
3031
3032 { "ti", "Europe/London", "2004-01-15T00:00:00Z", "Z", "+0000", "+0:00" },
3033 { "ti", "Europe/London", "2004-01-15T00:00:00Z", "ZZZZ", "GMT", "+0:00" },
3034 { "ti", "Europe/London", "2004-01-15T00:00:00Z", "z", "GMT", "+0:00" },
3035 { "ti", "Europe/London", "2004-01-15T00:00:00Z", "zzzz", "GMT", "+0:00" },
3036 { "ti", "Europe/London", "2004-07-15T00:00:00Z", "Z", "+0100", "+1:00" },
3037 { "ti", "Europe/London", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+01:00", "+1:00" },
3038 { "ti", "Europe/London", "2004-07-15T00:00:00Z", "z", "GMT+01:00", "+1:00" },
3039 { "ti", "Europe/London", "2004-07-15T00:00:00Z", "zzzz", "GMT+01:00", "+1:00" },
3040 { "ti", "Europe/London", "2004-07-15T00:00:00Z", "v", "(GB)", "Europe/London" },
3041 { "ti", "Europe/London", "2004-07-15T00:00:00Z", "vvvv", "(GB)", "Europe/London" },
3042
3043 { "ti", "Etc/GMT+3", "2004-01-15T00:00:00Z", "Z", "-0300", "-3:00" },
3044 { "ti", "Etc/GMT+3", "2004-01-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
3045 { "ti", "Etc/GMT+3", "2004-01-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
3046 { "ti", "Etc/GMT+3", "2004-01-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
3047 { "ti", "Etc/GMT+3", "2004-07-15T00:00:00Z", "Z", "-0300", "-3:00" },
3048 { "ti", "Etc/GMT+3", "2004-07-15T00:00:00Z", "ZZZZ", "GMT-03:00", "-3:00" },
3049 { "ti", "Etc/GMT+3", "2004-07-15T00:00:00Z", "z", "GMT-03:00", "-3:00" },
3050 { "ti", "Etc/GMT+3", "2004-07-15T00:00:00Z", "zzzz", "GMT-03:00", "-3:00" },
3051 { "ti", "Etc/GMT+3", "2004-07-15T00:00:00Z", "v", "GMT-03:00", "-3:00" },
3052 { "ti", "Etc/GMT+3", "2004-07-15T00:00:00Z", "vvvv", "GMT-03:00", "-3:00" },
3053
3054 // JB#5150
3055 { "ti", "Asia/Calcutta", "2004-01-15T00:00:00Z", "Z", "+0530", "+5:30" },
3056 { "ti", "Asia/Calcutta", "2004-01-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
3057 { "ti", "Asia/Calcutta", "2004-01-15T00:00:00Z", "z", "GMT+05:30", "+5:30" },
3058 { "ti", "Asia/Calcutta", "2004-01-15T00:00:00Z", "zzzz", "GMT+05:30", "+5:30" },
3059 { "ti", "Asia/Calcutta", "2004-07-15T00:00:00Z", "Z", "+0530", "+5:30" },
3060 { "ti", "Asia/Calcutta", "2004-07-15T00:00:00Z", "ZZZZ", "GMT+05:30", "+5:30" },
3061 { "ti", "Asia/Calcutta", "2004-07-15T00:00:00Z", "z", "GMT+05:30", "+05:30" },
3062 { "ti", "Asia/Calcutta", "2004-07-15T00:00:00Z", "zzzz", "GMT+05:30", "+5:30" },
3063 { "ti", "Asia/Calcutta", "2004-07-15T00:00:00Z", "v", "(IN)", "Alna/Calcutta" },
3064 { "ti", "Asia/Calcutta", "2004-07-15T00:00:00Z", "vvvv", "(IN)", "Asia/Calcutta" },
3065
3066 // Ticket#8589 Partial location name to use country name if the zone is the golden
3067 // zone for the time zone's country.
3068 { "en_MX", "America/Chicago", "1995-07-15T00:00:00Z", "vvvv", "Central Time (United States)", "America/Chicago"},
3069
3070 // Tests proper handling of time zones that should have empty sets when inherited from the parent.
3071 // For example, en_GB understands CET as Central European Time, but en_HK, which inherits from en_GB
3072 // does not
3073 { "en_GB", "Europe/Paris", "2004-01-15T00:00:00Z", "zzzz", "Central European Standard Time", "+1:00"},
3074 { "en_GB", "Europe/Paris", "2004-07-15T00:00:00Z", "zzzz", "Central European Summer Time", "+2:00"},
3075 { "en_GB", "Europe/Paris", "2004-01-15T00:00:00Z", "z", "CET", "+1:00"},
3076 { "en_GB", "Europe/Paris", "2004-07-15T00:00:00Z", "z", "CEST", "+2:00"},
3077 { "en_HK", "Europe/Paris", "2004-01-15T00:00:00Z", "zzzz", "Central European Standard Time", "+1:00"},
3078 { "en_HK", "Europe/Paris", "2004-07-15T00:00:00Z", "zzzz", "Central European Summer Time", "+2:00"},
3079 { "en_HK", "Europe/Paris", "2004-01-15T00:00:00Z", "z", "GMT+01:00", "+1:00"},
3080 { "en_HK", "Europe/Paris", "2004-07-15T00:00:00Z", "z", "GMT+02:00", "+2:00"},
3081
3082 { NULL, NULL, NULL, NULL, NULL, NULL },
3083 };
3084
3085 UErrorCode status = U_ZERO_ERROR;
3086 Calendar *cal = GregorianCalendar::createInstance(status);
3087 if (failure(status, "GregorianCalendar::createInstance", TRUE)) return;
3088 SimpleDateFormat testfmt(UnicodeString("yyyy-MM-dd'T'HH:mm:ss'Z'"), status);
3089 if (failure(status, "SimpleDateFormat constructor", TRUE)) return;
3090 testfmt.setTimeZone(*TimeZone::getGMT());
3091
3092 for (int i = 0; fallbackTests[i][0]; i++) {
3093 const char **testLine = fallbackTests[i];
3094 UnicodeString info[5];
3095 for ( int j = 0 ; j < 5 ; j++ ) {
3096 info[j] = UnicodeString(testLine[j], -1, US_INV);
3097 }
3098 info[4] = info[4].unescape();
3099 logln("%s;%s;%s;%s", testLine[0], testLine[1], testLine[2], testLine[3]);
3100
3101 TimeZone *tz = TimeZone::createTimeZone(info[1]);
3102
3103 UDate d = testfmt.parse(testLine[2], status);
3104 cal->setTime(d, status);
3105 if (U_FAILURE(status)) {
3106 errln(UnicodeString("Failed to set date: ") + testLine[2]);
3107 }
3108
3109 SimpleDateFormat fmt(info[3], Locale(testLine[0]),status);
3110 ASSERT_OK(status);
3111 cal->adoptTimeZone(tz);
3112 UnicodeString result;
3113 FieldPosition pos(0);
3114 fmt.format(*cal,result,pos);
3115 if (result != info[4]) {
3116 errln(info[0] + ";" + info[1] + ";" + info[2] + ";" + info[3] + " expected: '" +
3117 info[4] + "' but got: '" + result + "'");
3118 }
3119 }
3120 delete cal;
3121 }
3122
3123 void DateFormatTest::TestRoundtripWithCalendar(void) {
3124 UErrorCode status = U_ZERO_ERROR;
3125
3126 TimeZone *tz = TimeZone::createTimeZone("Europe/Paris");
3127 TimeZone *gmt = TimeZone::createTimeZone("Etc/GMT");
3128
3129 Calendar *calendars[] = {
3130 Calendar::createInstance(*tz, Locale("und@calendar=gregorian"), status),
3131 Calendar::createInstance(*tz, Locale("und@calendar=buddhist"), status),
3132 // Calendar::createInstance(*tz, Locale("und@calendar=hebrew"), status),
3133 Calendar::createInstance(*tz, Locale("und@calendar=islamic"), status),
3134 Calendar::createInstance(*tz, Locale("und@calendar=japanese"), status),
3135 NULL
3136 };
3137 if (U_FAILURE(status)) {
3138 dataerrln("Failed to initialize calendars: %s", u_errorName(status));
3139 for (int i = 0; calendars[i] != NULL; i++) {
3140 delete calendars[i];
3141 }
3142 return;
3143 }
3144
3145 //FIXME The formatters commented out below are currently failing because of
3146 // the calendar calculation problem reported by #6691
3147
3148 // The order of test formatters must match the order of calendars above.
3149 DateFormat *formatters[] = {
3150 DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull, Locale("en_US")), //calendar=gregorian
3151 DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull, Locale("th_TH")), //calendar=buddhist
3152 // DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull, Locale("he_IL@calendar=hebrew")),
3153 DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull, Locale("ar_EG@calendar=islamic")),
3154 // DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull, Locale("ja_JP@calendar=japanese")),
3155 NULL
3156 };
3157
3158 UDate d = Calendar::getNow();
3159 UnicodeString buf;
3160 FieldPosition fpos;
3161 ParsePosition ppos;
3162
3163 for (int i = 0; formatters[i] != NULL; i++) {
3164 buf.remove();
3165 fpos.setBeginIndex(0);
3166 fpos.setEndIndex(0);
3167 calendars[i]->setTime(d, status);
3168
3169 // Normal case output - the given calendar matches the calendar
3170 // used by the formatter
3171 formatters[i]->format(*calendars[i], buf, fpos);
3172 UnicodeString refStr(buf);
3173
3174 for (int j = 0; calendars[j] != NULL; j++) {
3175 if (j == i) {
3176 continue;
3177 }
3178 buf.remove();
3179 fpos.setBeginIndex(0);
3180 fpos.setEndIndex(0);
3181 calendars[j]->setTime(d, status);
3182
3183 // Even the different calendar type is specified,
3184 // we should get the same result.
3185 formatters[i]->format(*calendars[j], buf, fpos);
3186 if (refStr != buf) {
3187 errln((UnicodeString)"FAIL: Different format result with a different calendar for the same time -"
3188 + "\n Reference calendar type=" + calendars[i]->getType()
3189 + "\n Another calendar type=" + calendars[j]->getType()
3190 + "\n Expected result=" + refStr
3191 + "\n Actual result=" + buf);
3192 }
3193 }
3194
3195 calendars[i]->setTimeZone(*gmt);
3196 calendars[i]->clear();
3197 ppos.setErrorIndex(-1);
3198 ppos.setIndex(0);
3199
3200 // Normal case parse result - the given calendar matches the calendar
3201 // used by the formatter
3202 formatters[i]->parse(refStr, *calendars[i], ppos);
3203
3204 for (int j = 0; calendars[j] != NULL; j++) {
3205 if (j == i) {
3206 continue;
3207 }
3208 calendars[j]->setTimeZone(*gmt);
3209 calendars[j]->clear();
3210 ppos.setErrorIndex(-1);
3211 ppos.setIndex(0);
3212
3213 // Even the different calendar type is specified,
3214 // we should get the same time and time zone.
3215 formatters[i]->parse(refStr, *calendars[j], ppos);
3216 if (calendars[i]->getTime(status) != calendars[j]->getTime(status)
3217 || calendars[i]->getTimeZone() != calendars[j]->getTimeZone()) {
3218 UnicodeString tzid;
3219 errln((UnicodeString)"FAIL: Different parse result with a different calendar for the same string -"
3220 + "\n Reference calendar type=" + calendars[i]->getType()
3221 + "\n Another calendar type=" + calendars[j]->getType()
3222 + "\n Date string=" + refStr
3223 + "\n Expected time=" + calendars[i]->getTime(status)
3224 + "\n Expected time zone=" + calendars[i]->getTimeZone().getID(tzid)
3225 + "\n Actual time=" + calendars[j]->getTime(status)
3226 + "\n Actual time zone=" + calendars[j]->getTimeZone().getID(tzid));
3227 }
3228 }
3229 if (U_FAILURE(status)) {
3230 errln((UnicodeString)"FAIL: " + u_errorName(status));
3231 break;
3232 }
3233 }
3234
3235 delete tz;
3236 delete gmt;
3237 for (int i = 0; calendars[i] != NULL; i++) {
3238 delete calendars[i];
3239 }
3240 for (int i = 0; formatters[i] != NULL; i++) {
3241 delete formatters[i];
3242 }
3243 }
3244
3245 /*
3246 void DateFormatTest::TestRelativeError(void)
3247 {
3248 UErrorCode status;
3249 Locale en("en");
3250
3251 DateFormat *en_reltime_reldate = DateFormat::createDateTimeInstance(DateFormat::kFullRelative,DateFormat::kFullRelative,en);
3252 if(en_reltime_reldate == NULL) {
3253 logln("PASS: rel date/rel time failed");
3254 } else {
3255 errln("FAIL: rel date/rel time created, should have failed.");
3256 delete en_reltime_reldate;
3257 }
3258 }
3259
3260 void DateFormatTest::TestRelativeOther(void)
3261 {
3262 logln("Nothing in this test. When we get more data from CLDR, put in some tests of -2, +2, etc. ");
3263 }
3264 */
3265
3266 void DateFormatTest::Test6338(void)
3267 {
3268 UErrorCode status = U_ZERO_ERROR;
3269
3270 SimpleDateFormat *fmt1 = new SimpleDateFormat(UnicodeString("y-M-d"), Locale("ar"), status);
3271 if (failure(status, "new SimpleDateFormat", TRUE)) return;
3272
3273 UDate dt1 = date(2008-1900, UCAL_JUNE, 10, 12, 00);
3274 UnicodeString str1;
3275 str1 = fmt1->format(dt1, str1);
3276 logln(str1);
3277
3278 UDate dt11 = fmt1->parse(str1, status);
3279 failure(status, "fmt->parse");
3280
3281 UnicodeString str11;
3282 str11 = fmt1->format(dt11, str11);
3283 logln(str11);
3284
3285 if (str1 != str11) {
3286 errln((UnicodeString)"FAIL: Different dates str1:" + str1
3287 + " str2:" + str11);
3288 }
3289 delete fmt1;
3290
3291 /////////////////
3292
3293 status = U_ZERO_ERROR;
3294 SimpleDateFormat *fmt2 = new SimpleDateFormat(UnicodeString("y M d"), Locale("ar"), status);
3295 failure(status, "new SimpleDateFormat");
3296
3297 UDate dt2 = date(2008-1900, UCAL_JUNE, 10, 12, 00);
3298 UnicodeString str2;
3299 str2 = fmt2->format(dt2, str2);
3300 logln(str2);
3301
3302 UDate dt22 = fmt2->parse(str2, status);
3303 failure(status, "fmt->parse");
3304
3305 UnicodeString str22;
3306 str22 = fmt2->format(dt22, str22);
3307 logln(str22);
3308
3309 if (str2 != str22) {
3310 errln((UnicodeString)"FAIL: Different dates str1:" + str2
3311 + " str2:" + str22);
3312 }
3313 delete fmt2;
3314
3315 /////////////////
3316
3317 status = U_ZERO_ERROR;
3318 SimpleDateFormat *fmt3 = new SimpleDateFormat(UnicodeString("y-M-d"), Locale("en-us"), status);
3319 failure(status, "new SimpleDateFormat");
3320
3321 UDate dt3 = date(2008-1900, UCAL_JUNE, 10, 12, 00);
3322 UnicodeString str3;
3323 str3 = fmt3->format(dt3, str3);
3324 logln(str3);
3325
3326 UDate dt33 = fmt3->parse(str3, status);
3327 failure(status, "fmt->parse");
3328
3329 UnicodeString str33;
3330 str33 = fmt3->format(dt33, str33);
3331 logln(str33);
3332
3333 if (str3 != str33) {
3334 errln((UnicodeString)"FAIL: Different dates str1:" + str3
3335 + " str2:" + str33);
3336 }
3337 delete fmt3;
3338
3339 /////////////////
3340
3341 status = U_ZERO_ERROR;
3342 SimpleDateFormat *fmt4 = new SimpleDateFormat(UnicodeString("y M d"), Locale("en-us"), status);
3343 failure(status, "new SimpleDateFormat");
3344
3345 UDate dt4 = date(2008-1900, UCAL_JUNE, 10, 12, 00);
3346 UnicodeString str4;
3347 str4 = fmt4->format(dt4, str4);
3348 logln(str4);
3349
3350 UDate dt44 = fmt4->parse(str4, status);
3351 failure(status, "fmt->parse");
3352
3353 UnicodeString str44;
3354 str44 = fmt4->format(dt44, str44);
3355 logln(str44);
3356
3357 if (str4 != str44) {
3358 errln((UnicodeString)"FAIL: Different dates str1:" + str4
3359 + " str2:" + str44);
3360 }
3361 delete fmt4;
3362
3363 }
3364
3365 void DateFormatTest::Test6726(void)
3366 {
3367 // status
3368 // UErrorCode status = U_ZERO_ERROR;
3369
3370 // fmtf, fmtl, fmtm, fmts;
3371 UnicodeString strf, strl, strm, strs;
3372 UDate dt = date(2008-1900, UCAL_JUNE, 10, 12, 00);
3373
3374 Locale loc("ja");
3375 DateFormat* fmtf = DateFormat::createDateTimeInstance(DateFormat::FULL, DateFormat::FULL, loc);
3376 DateFormat* fmtl = DateFormat::createDateTimeInstance(DateFormat::LONG, DateFormat::FULL, loc);
3377 DateFormat* fmtm = DateFormat::createDateTimeInstance(DateFormat::MEDIUM, DateFormat::FULL, loc);
3378 DateFormat* fmts = DateFormat::createDateTimeInstance(DateFormat::SHORT, DateFormat::FULL, loc);
3379 if (fmtf == NULL || fmtl == NULL || fmtm == NULL || fmts == NULL) {
3380 dataerrln("Unable to create DateFormat. got NULL.");
3381 /* It may not be true that if one is NULL all is NULL. Just to be safe. */
3382 delete fmtf;
3383 delete fmtl;
3384 delete fmtm;
3385 delete fmts;
3386
3387 return;
3388 }
3389 strf = fmtf->format(dt, strf);
3390 strl = fmtl->format(dt, strl);
3391 strm = fmtm->format(dt, strm);
3392 strs = fmts->format(dt, strs);
3393
3394
3395 logln("strm.charAt(10)=%04X wanted 0x20\n", strm.charAt(10));
3396 if (strm.charAt(10) != UChar(0x0020)) {
3397 errln((UnicodeString)"FAIL: Improper formatted date: " + strm );
3398 }
3399 logln("strs.charAt(10)=%04X wanted 0x20\n", strs.charAt(8));
3400 if (strs.charAt(10) != UChar(0x0020)) {
3401 errln((UnicodeString)"FAIL: Improper formatted date: " + strs);
3402 }
3403
3404 delete fmtf;
3405 delete fmtl;
3406 delete fmtm;
3407 delete fmts;
3408
3409 return;
3410 }
3411
3412 /**
3413 * Test DateFormat's parsing of default GMT variants. See ticket#6135
3414 */
3415 void DateFormatTest::TestGMTParsing() {
3416 const char* DATA[] = {
3417 "HH:mm:ss Z",
3418
3419 // pattern, input, expected output (in quotes)
3420 "HH:mm:ss Z", "10:20:30 GMT+03:00", "10:20:30 +0300",
3421 "HH:mm:ss Z", "10:20:30 UT-02:00", "10:20:30 -0200",
3422 "HH:mm:ss Z", "10:20:30 GMT", "10:20:30 +0000",
3423 "HH:mm:ss vvvv", "10:20:30 UT+10:00", "10:20:30 +1000",
3424 "HH:mm:ss zzzz", "10:20:30 UTC", "10:20:30 +0000", // standalone "UTC"
3425 "ZZZZ HH:mm:ss", "UT 10:20:30", "10:20:30 +0000",
3426 "V HH:mm:ss", "UT+0130 10:20:30", "10:20:30 +0130",
3427 "V HH:mm:ss", "UTC+0130 10:20:30", "10:20:30 +0130",
3428 "HH mm Z ss", "10 20 GMT-1100 30", "10:20:30 -1100",
3429 "HH:mm:ssZZZZZ", "14:25:45Z", "14:25:45 +0000",
3430 "HH:mm:ssZZZZZ", "15:00:00-08:00", "15:00:00 -0800",
3431 };
3432 const int32_t DATA_len = sizeof(DATA)/sizeof(DATA[0]);
3433 expectParse(DATA, DATA_len, Locale("en"));
3434 }
3435
3436 // Test case for localized GMT format parsing
3437 // with no delimitters in offset format (Chinese locale)
3438 void DateFormatTest::Test6880() {
3439 UErrorCode status = U_ZERO_ERROR;
3440 UDate d1, d2, dp1, dp2, dexp1, dexp2;
3441 UnicodeString s1, s2;
3442
3443 TimeZone *tz = TimeZone::createTimeZone("Asia/Shanghai");
3444 GregorianCalendar gcal(*tz, status);
3445 if (failure(status, "construct GregorianCalendar", TRUE)) return;
3446
3447 gcal.clear();
3448 gcal.set(1910, UCAL_JULY, 1, 12, 00); // offset 8:05:52
3449 d1 = gcal.getTime(status);
3450
3451 gcal.clear();
3452 gcal.set(1950, UCAL_JULY, 1, 12, 00); // offset 8:00
3453 d2 = gcal.getTime(status);
3454
3455 gcal.clear();
3456 gcal.set(1970, UCAL_JANUARY, 1, 12, 00);
3457 dexp2 = gcal.getTime(status);
3458 dexp1 = dexp2 - (5*60 + 52)*1000; // subtract 5m52s
3459
3460 if (U_FAILURE(status)) {
3461 errln("FAIL: Gregorian calendar error");
3462 }
3463
3464 DateFormat *fmt = DateFormat::createTimeInstance(DateFormat::kFull, Locale("zh"));
3465 if (fmt == NULL) {
3466 dataerrln("Unable to create DateFormat. Got NULL.");
3467 return;
3468 }
3469 fmt->adoptTimeZone(tz);
3470
3471 fmt->format(d1, s1);
3472 fmt->format(d2, s2);
3473
3474 dp1 = fmt->parse(s1, status);
3475 dp2 = fmt->parse(s2, status);
3476
3477 if (U_FAILURE(status)) {
3478 errln("FAIL: Parse failure");
3479 }
3480
3481 if (dp1 != dexp1) {
3482 errln("FAIL: Failed to parse " + s1 + " parsed: " + dp1 + " expected: " + dexp1);
3483 }
3484 if (dp2 != dexp2) {
3485 errln("FAIL: Failed to parse " + s2 + " parsed: " + dp2 + " expected: " + dexp2);
3486 }
3487
3488 delete fmt;
3489 }
3490
3491 typedef struct {
3492 const char * localeStr;
3493 UBool lenient;
3494 UBool expectFail;
3495 UnicodeString datePattern;
3496 UnicodeString dateString;
3497 } NumAsStringItem;
3498
3499 void DateFormatTest::TestNumberAsStringParsing()
3500 {
3501 const NumAsStringItem items[] = {
3502 // loc lenient fail? datePattern dateString
3503 { "", FALSE, FALSE, UnicodeString("y MMMM d HH:mm:ss"), UnicodeString("2009 7 14 08:43:57") },
3504 { "", TRUE, FALSE, UnicodeString("y MMMM d HH:mm:ss"), UnicodeString("2009 7 14 08:43:57") },
3505 { "en", FALSE, FALSE, UnicodeString("MMM d, y"), UnicodeString("Jul 14, 2009") },
3506 { "en", TRUE, FALSE, UnicodeString("MMM d, y"), UnicodeString("Jul 14, 2009") },
3507 { "en", FALSE, TRUE, UnicodeString("MMM d, y"), UnicodeString("7 14, 2009") },
3508 { "en", TRUE, FALSE, UnicodeString("MMM d, y"), UnicodeString("7 14, 2009") },
3509 { "ja", FALSE, FALSE, UnicodeString("yyyy/MM/dd"), UnicodeString("2009/07/14") },
3510 { "ja", TRUE, FALSE, UnicodeString("yyyy/MM/dd"), UnicodeString("2009/07/14") },
3511 //{ "ja", FALSE, FALSE, UnicodeString("yyyy/MMMMM/d"), UnicodeString("2009/7/14") }, // #8860 covers test failure
3512 { "ja", TRUE, FALSE, UnicodeString("yyyy/MMMMM/d"), UnicodeString("2009/7/14") },
3513 { "ja", FALSE, FALSE, CharsToUnicodeString("y\\u5E74M\\u6708d\\u65E5"), CharsToUnicodeString("2009\\u5E747\\u670814\\u65E5") },
3514 { "ja", TRUE, FALSE, CharsToUnicodeString("y\\u5E74M\\u6708d\\u65E5"), CharsToUnicodeString("2009\\u5E747\\u670814\\u65E5") },
3515 { "ja", FALSE, FALSE, CharsToUnicodeString("y\\u5E74MMMd\\u65E5"), CharsToUnicodeString("2009\\u5E747\\u670814\\u65E5") },
3516 { "ja", TRUE, FALSE, CharsToUnicodeString("y\\u5E74MMMd\\u65E5"), CharsToUnicodeString("2009\\u5E747\\u670814\\u65E5") }, // #8820 fixes test failure
3517 { "ko", FALSE, FALSE, UnicodeString("yyyy. M. d."), UnicodeString("2009. 7. 14.") },
3518 { "ko", TRUE, FALSE, UnicodeString("yyyy. M. d."), UnicodeString("2009. 7. 14.") },
3519 { "ko", FALSE, FALSE, UnicodeString("yyyy. MMMMM d."), CharsToUnicodeString("2009. 7\\uC6D4 14.") },
3520 { "ko", TRUE, FALSE, UnicodeString("yyyy. MMMMM d."), CharsToUnicodeString("2009. 7\\uC6D4 14.") }, // #8820 fixes test failure
3521 { "ko", FALSE, FALSE, CharsToUnicodeString("y\\uB144 M\\uC6D4 d\\uC77C"), CharsToUnicodeString("2009\\uB144 7\\uC6D4 14\\uC77C") },
3522 { "ko", TRUE, FALSE, CharsToUnicodeString("y\\uB144 M\\uC6D4 d\\uC77C"), CharsToUnicodeString("2009\\uB144 7\\uC6D4 14\\uC77C") },
3523 { "ko", FALSE, FALSE, CharsToUnicodeString("y\\uB144 MMM d\\uC77C"), CharsToUnicodeString("2009\\uB144 7\\uC6D4 14\\uC77C") },
3524 { "ko", TRUE, FALSE, CharsToUnicodeString("y\\uB144 MMM d\\uC77C"), CharsToUnicodeString("2009\\uB144 7\\uC6D4 14\\uC77C") }, // #8820 fixes test failure
3525 { NULL, FALSE, FALSE, UnicodeString(""), UnicodeString("") }
3526 };
3527 const NumAsStringItem * itemPtr;
3528 for (itemPtr = items; itemPtr->localeStr != NULL; itemPtr++ ) {
3529 Locale locale = Locale::createFromName(itemPtr->localeStr);
3530 UErrorCode status = U_ZERO_ERROR;
3531 SimpleDateFormat *formatter = new SimpleDateFormat(itemPtr->datePattern, locale, status);
3532 if (formatter == NULL || U_FAILURE(status)) {
3533 dataerrln("Unable to create SimpleDateFormat - %s", u_errorName(status));
3534 return;
3535 }
3536
3537 formatter->setLenient(itemPtr->lenient);
3538 UDate date1 = formatter->parse(itemPtr->dateString, status);
3539 if (U_FAILURE(status)) {
3540 if (!itemPtr->expectFail) {
3541 errln("FAIL, err when expected success: Locale \"" + UnicodeString(itemPtr->localeStr) + "\", lenient " + itemPtr->lenient +
3542 ": using pattern \"" + itemPtr->datePattern + "\", could not parse \"" + itemPtr->dateString + "\"; err: " + u_errorName(status) );
3543 }
3544 } else if (itemPtr->expectFail) {
3545 errln("FAIL, expected err but got none: Locale \"" + UnicodeString(itemPtr->localeStr) + "\", lenient " + itemPtr->lenient +
3546 ": using pattern \"" + itemPtr->datePattern + "\", did parse \"" + itemPtr->dateString + "\"." );
3547 } else if (!itemPtr->lenient) {
3548 UnicodeString formatted;
3549 formatter->format(date1, formatted);
3550 if (formatted != itemPtr->dateString) {
3551 errln("FAIL, mismatch formatting parsed date: Locale \"" + UnicodeString(itemPtr->localeStr) + "\", lenient " + itemPtr->lenient +
3552 ": using pattern \"" + itemPtr->datePattern + "\", did parse \"" + itemPtr->dateString + "\", formatted result \"" + formatted + "\".");
3553 }
3554 }
3555
3556 delete formatter;
3557 }
3558 }
3559
3560 void DateFormatTest::TestISOEra() {
3561
3562 const char* data[] = {
3563 // input, output
3564 "BC 4004-10-23T07:00:00Z", "BC 4004-10-23T07:00:00Z",
3565 "AD 4004-10-23T07:00:00Z", "AD 4004-10-23T07:00:00Z",
3566 "-4004-10-23T07:00:00Z" , "BC 4005-10-23T07:00:00Z",
3567 "4004-10-23T07:00:00Z" , "AD 4004-10-23T07:00:00Z",
3568 };
3569
3570 int32_t numData = 8;
3571
3572 UErrorCode status = U_ZERO_ERROR;
3573
3574 // create formatter
3575 SimpleDateFormat *fmt1 = new SimpleDateFormat(UnicodeString("GGG yyyy-MM-dd'T'HH:mm:ss'Z"), status);
3576 failure(status, "new SimpleDateFormat", TRUE);
3577 if (status == U_MISSING_RESOURCE_ERROR) {
3578 if (fmt1 != NULL) {
3579 delete fmt1;
3580 }
3581 return;
3582 }
3583 for(int i=0; i < numData; i+=2) {
3584 // create input string
3585 UnicodeString in = data[i];
3586
3587 // parse string to date
3588 UDate dt1 = fmt1->parse(in, status);
3589 failure(status, "fmt->parse", TRUE);
3590
3591 // format date back to string
3592 UnicodeString out;
3593 out = fmt1->format(dt1, out);
3594 logln(out);
3595
3596 // check that roundtrip worked as expected
3597 UnicodeString expected = data[i+1];
3598 if (out != expected) {
3599 dataerrln((UnicodeString)"FAIL: " + in + " -> " + out + " expected -> " + expected);
3600 }
3601 }
3602
3603 delete fmt1;
3604 }
3605 void DateFormatTest::TestFormalChineseDate() {
3606
3607 UErrorCode status = U_ZERO_ERROR;
3608 UnicodeString pattern ("y\\u5e74M\\u6708d\\u65e5", -1, US_INV );
3609 pattern = pattern.unescape();
3610 UnicodeString override ("y=hanidec;M=hans;d=hans", -1, US_INV );
3611
3612 // create formatter
3613 SimpleDateFormat *sdf = new SimpleDateFormat(pattern,override,Locale::getChina(),status);
3614 failure(status, "new SimpleDateFormat with override", TRUE);
3615
3616 UDate thedate = date(2009-1900, UCAL_JULY, 28);
3617 FieldPosition pos(0);
3618 UnicodeString result;
3619 sdf->format(thedate,result,pos);
3620
3621 UnicodeString expected = "\\u4e8c\\u3007\\u3007\\u4e5d\\u5e74\\u4e03\\u6708\\u4e8c\\u5341\\u516b\\u65e5";
3622 expected = expected.unescape();
3623 if (result != expected) {
3624 dataerrln((UnicodeString)"FAIL: -> " + result + " expected -> " + expected);
3625 }
3626
3627 UDate parsedate = sdf->parse(expected,status);
3628 if ( parsedate != thedate ) {
3629 UnicodeString pat1 ("yyyy-MM-dd'T'HH:mm:ss'Z'", -1, US_INV );
3630 SimpleDateFormat *usf = new SimpleDateFormat(pat1,Locale::getEnglish(),status);
3631 UnicodeString parsedres,expres;
3632 usf->format(parsedate,parsedres,pos);
3633 usf->format(thedate,expres,pos);
3634 dataerrln((UnicodeString)"FAIL: parsed -> " + parsedres + " expected -> " + expres);
3635 delete usf;
3636 }
3637 delete sdf;
3638 }
3639
3640 // Test case for #8675
3641 // Incorrect parse offset with stand alone GMT string on 2nd or later iteration.
3642 void DateFormatTest::TestStandAloneGMTParse() {
3643 UErrorCode status = U_ZERO_ERROR;
3644 SimpleDateFormat *sdf = new SimpleDateFormat("ZZZZ", Locale(""), status);
3645
3646 if (U_SUCCESS(status)) {
3647
3648 UnicodeString inText("GMT$$$");
3649 for (int32_t i = 0; i < 10; i++) {
3650 ParsePosition pos(0);
3651 sdf->parse(inText, pos);
3652 if (pos.getIndex() != 3) {
3653 errln((UnicodeString)"FAIL: Incorrect output parse position: actual=" + pos.getIndex() + " expected=3");
3654 }
3655 }
3656
3657 delete sdf;
3658 } else {
3659 dataerrln("Unable to create SimpleDateFormat - %s", u_errorName(status));
3660 }
3661 }
3662
3663 void DateFormatTest::TestParsePosition() {
3664 const char* TestData[][4] = {
3665 // {<pattern>, <lead>, <date string>, <trail>}
3666 {"yyyy-MM-dd HH:mm:ssZ", "", "2010-01-10 12:30:00+0500", ""},
3667 {"yyyy-MM-dd HH:mm:ss ZZZZ", "", "2010-01-10 12:30:00 GMT+05:00", ""},
3668 {"Z HH:mm:ss", "", "-0100 13:20:30", ""},
3669 {"y-M-d Z", "", "2011-8-25 -0400", " Foo"},
3670 {"y/M/d H:mm:ss z", "", "2011/7/1 12:34:00 PDT", ""},
3671 {"y/M/d H:mm:ss z", "+123", "2011/7/1 12:34:00 PDT", " PST"},
3672 {"vvvv a h:mm:ss", "", "Pacific Time AM 10:21:45", ""},
3673 {"HH:mm v M/d", "111", "14:15 PT 8/10", " 12345"},
3674 {"'time zone:' VVVV 'date:' yyyy-MM-dd", "xxxx", "time zone: United States Time (Los Angeles) date: 2010-02-25", "xxxx"},
3675 {0, 0, 0, 0},
3676 };
3677
3678 for (int32_t i = 0; TestData[i][0]; i++) {
3679 UErrorCode status = U_ZERO_ERROR;
3680 SimpleDateFormat *sdf = new SimpleDateFormat(UnicodeString(TestData[i][0]), status);
3681 if (failure(status, "new SimpleDateFormat", TRUE)) return;
3682
3683 int32_t startPos, resPos;
3684
3685 // lead text
3686 UnicodeString input(TestData[i][1]);
3687 startPos = input.length();
3688
3689 // date string
3690 input += TestData[i][2];
3691 resPos = input.length();
3692
3693 // trail text
3694 input += TestData[i][3];
3695
3696 ParsePosition pos(startPos);
3697 //UDate d = sdf->parse(input, pos);
3698 (void)sdf->parse(input, pos);
3699
3700 if (pos.getIndex() != resPos) {
3701 errln(UnicodeString("FAIL: Parsing [") + input + "] with pattern [" + TestData[i][0] + "] returns position - "
3702 + pos.getIndex() + ", expected - " + resPos);
3703 }
3704
3705 delete sdf;
3706 }
3707 }
3708
3709
3710 typedef struct {
3711 int32_t era;
3712 int32_t year;
3713 int32_t month; // 1-based
3714 int32_t isLeapMonth;
3715 int32_t day;
3716 } ChineseCalTestDate;
3717
3718 #define NUM_TEST_DATES 3
3719
3720 typedef struct {
3721 const char * locale;
3722 int32_t style; // <0 => custom
3723 UnicodeString dateString[NUM_TEST_DATES];
3724 } MonthPatternItem;
3725
3726 void DateFormatTest::TestMonthPatterns()
3727 {
3728 const ChineseCalTestDate dates[NUM_TEST_DATES] = {
3729 // era yr mo lp da
3730 { 78, 29, 4, 0, 2 }, // (in chinese era 78) gregorian 2012-4-22
3731 { 78, 29, 4, 1, 2 }, // (in chinese era 78) gregorian 2012-5-22
3732 { 78, 29, 5, 0, 2 }, // (in chinese era 78) gregorian 2012-6-20
3733 };
3734
3735 const MonthPatternItem items[] = {
3736 // locale date style; expected formats for the 3 dates above
3737 { "root@calendar=chinese", DateFormat::kLong, { UnicodeString("ren-chen 4 2"), UnicodeString("ren-chen 4bis 2"), UnicodeString("ren-chen 5 2") } },
3738 { "root@calendar=chinese", DateFormat::kShort, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
3739 { "root@calendar=chinese", -1, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
3740 { "root@calendar=chinese", -2, { UnicodeString("78x29-4-2"), UnicodeString("78x29-4bis-2"), UnicodeString("78x29-5-2") } },
3741 { "root@calendar=chinese", -3, { UnicodeString("ren-chen-4-2"), UnicodeString("ren-chen-4bis-2"), UnicodeString("ren-chen-5-2") } },
3742 { "root@calendar=chinese", -4, { UnicodeString("ren-chen 4 2"), UnicodeString("ren-chen 4bis 2"), UnicodeString("ren-chen 5 2") } },
3743 { "en@calendar=gregorian", -3, { UnicodeString("2012-4-22"), UnicodeString("2012-5-22"), UnicodeString("2012-6-20") } },
3744 { "en@calendar=chinese", DateFormat::kLong, { UnicodeString("4 2, ren-chen"), UnicodeString("4bis 2, ren-chen"), UnicodeString("5 2, ren-chen") } },
3745 { "en@calendar=chinese", DateFormat::kShort, { UnicodeString("4/2/29"), UnicodeString("4bis/2/29"), UnicodeString("5/2/29") } },
3746 { "zh@calendar=chinese", DateFormat::kLong, { CharsToUnicodeString("\\u58EC\\u8FB0\\u5E74\\u56DB\\u6708\\u4E8C\\u65E5"),
3747 CharsToUnicodeString("\\u58EC\\u8FB0\\u5E74\\u95F0\\u56DB\\u6708\\u4E8C\\u65E5"),
3748 CharsToUnicodeString("\\u58EC\\u8FB0\\u5E74\\u4E94\\u6708\\u4E8C\\u65E5") } },
3749 { "zh@calendar=chinese", DateFormat::kShort, { CharsToUnicodeString("\\u58EC\\u8FB0-4-2"),
3750 CharsToUnicodeString("\\u58EC\\u8FB0-\\u95F04-2"),
3751 CharsToUnicodeString("\\u58EC\\u8FB0-5-2") } },
3752 { "zh@calendar=chinese", -3, { CharsToUnicodeString("\\u58EC\\u8FB0-4-2"),
3753 CharsToUnicodeString("\\u58EC\\u8FB0-\\u95F04-2"),
3754 CharsToUnicodeString("\\u58EC\\u8FB0-5-2") } },
3755 { "zh@calendar=chinese", -4, { CharsToUnicodeString("\\u58EC\\u8FB0 \\u56DB\\u6708 2"),
3756 CharsToUnicodeString("\\u58EC\\u8FB0 \\u95F0\\u56DB\\u6708 2"),
3757 CharsToUnicodeString("\\u58EC\\u8FB0 \\u4E94\\u6708 2") } },
3758 { "zh_Hant@calendar=chinese", DateFormat::kLong, { CharsToUnicodeString("\\u58EC\\u8FB0\\u5E74\\u56DB\\u6708\\u4E8C\\u65E5"),
3759 CharsToUnicodeString("\\u58EC\\u8FB0\\u5E74\\u958F\\u56DB\\u6708\\u4E8C\\u65E5"),
3760 CharsToUnicodeString("\\u58EC\\u8FB0\\u5E74\\u4E94\\u6708\\u4E8C\\u65E5") } },
3761 { "zh_Hant@calendar=chinese", DateFormat::kShort, { CharsToUnicodeString("\\u58EC\\u8FB0/4/2"),
3762 CharsToUnicodeString("\\u58EC\\u8FB0/\\u958F4/2"),
3763 CharsToUnicodeString("\\u58EC\\u8FB0/5/2") } },
3764 { "fr@calendar=chinese", DateFormat::kLong, { CharsToUnicodeString("2 s\\u00ECyu\\u00E8 ren-chen"),
3765 CharsToUnicodeString("2 s\\u00ECyu\\u00E8bis ren-chen"),
3766 CharsToUnicodeString("2 w\\u01D4yu\\u00E8 ren-chen") } },
3767 { "fr@calendar=chinese", DateFormat::kShort, { UnicodeString("2/4/29"), UnicodeString("2/4bis/29"), UnicodeString("2/5/29") } },
3768 // terminator
3769 { NULL, 0, { UnicodeString(""), UnicodeString(""), UnicodeString("") } }
3770 };
3771
3772 //. style: -1 -2 -3 -4
3773 const UnicodeString customPatterns[] = { "y-Ml-d", "G'x'y-Ml-d", "U-M-d", "U MMM d" }; // like old root pattern, using 'l'
3774
3775 UErrorCode status = U_ZERO_ERROR;
3776 Locale rootChineseCalLocale = Locale::createFromName("root@calendar=chinese");
3777 Calendar * rootChineseCalendar = Calendar::createInstance(rootChineseCalLocale, status);
3778 if (U_SUCCESS(status)) {
3779 const MonthPatternItem * itemPtr;
3780 for (itemPtr = items; itemPtr->locale != NULL; itemPtr++ ) {
3781 Locale locale = Locale::createFromName(itemPtr->locale);
3782 DateFormat * dmft = (itemPtr->style >= 0)?
3783 DateFormat::createDateInstance((DateFormat::EStyle)itemPtr->style, locale):
3784 new SimpleDateFormat(customPatterns[-itemPtr->style - 1], locale, status);
3785 if ( dmft != NULL ) {
3786 if (U_SUCCESS(status)) {
3787 const ChineseCalTestDate * datePtr = dates;
3788 int32_t idate;
3789 for (idate = 0; idate < NUM_TEST_DATES; idate++, datePtr++) {
3790 rootChineseCalendar->clear();
3791 rootChineseCalendar->set(UCAL_ERA, datePtr->era);
3792 rootChineseCalendar->set(datePtr->year, datePtr->month-1, datePtr->day);
3793 rootChineseCalendar->set(UCAL_IS_LEAP_MONTH, datePtr->isLeapMonth);
3794 UnicodeString result;
3795 FieldPosition fpos(0);
3796 dmft->format(*rootChineseCalendar, result, fpos);
3797 if ( result.compare(itemPtr->dateString[idate]) != 0 ) {
3798 errln( UnicodeString("FAIL: Chinese calendar format for locale ") + UnicodeString(itemPtr->locale) + ", style " + itemPtr->style +
3799 ", expected \"" + itemPtr->dateString[idate] + "\", got \"" + result + "\"");
3800 } else {
3801 // formatted OK, try parse
3802 ParsePosition ppos(0);
3803 // ensure we are really parsing the fields we should be
3804 rootChineseCalendar->set(UCAL_YEAR, 1);
3805 rootChineseCalendar->set(UCAL_MONTH, 0);
3806 rootChineseCalendar->set(UCAL_IS_LEAP_MONTH, 0);
3807 rootChineseCalendar->set(UCAL_DATE, 1);
3808 //
3809 dmft->parse(result, *rootChineseCalendar, ppos);
3810 int32_t year = rootChineseCalendar->get(UCAL_YEAR, status);
3811 int32_t month = rootChineseCalendar->get(UCAL_MONTH, status) + 1;
3812 int32_t isLeapMonth = rootChineseCalendar->get(UCAL_IS_LEAP_MONTH, status);
3813 int32_t day = rootChineseCalendar->get(UCAL_DATE, status);
3814 if ( ppos.getIndex() < result.length() || year != datePtr->year || month != datePtr->month || isLeapMonth != datePtr->isLeapMonth || day != datePtr->day ) {
3815 errln( UnicodeString("FAIL: Chinese calendar parse for locale ") + UnicodeString(itemPtr->locale) + ", style " + itemPtr->style +
3816 ", string \"" + result + "\", expected " + datePtr->year +"-"+datePtr->month+"("+datePtr->isLeapMonth+")-"+datePtr->day + ", got pos " +
3817 ppos.getIndex() + " " + year +"-"+month+"("+isLeapMonth+")-"+day);
3818 }
3819 }
3820 }
3821 } else {
3822 dataerrln("Error creating SimpleDateFormat for Chinese calendar- %s", u_errorName(status));
3823 }
3824 delete dmft;
3825 } else {
3826 dataerrln("FAIL: Unable to create DateFormat for Chinese calendar- %s", u_errorName(status));
3827 }
3828 }
3829 delete rootChineseCalendar;
3830 } else {
3831 errln(UnicodeString("FAIL: Unable to create Calendar for root@calendar=chinese"));
3832 }
3833 }
3834
3835 typedef struct {
3836 const char * locale;
3837 UnicodeString pattern;
3838 UDateFormatContextValue capitalizationContext;
3839 UnicodeString expectedFormat;
3840 } TestContextItem;
3841
3842 void DateFormatTest::TestContext()
3843 {
3844 const UDate july022008 = 1215000001979.0;
3845 const TestContextItem items[] = {
3846 //locale pattern capitalizationContext expected formatted date
3847 { "fr", UnicodeString("MMMM y"), UDAT_CONTEXT_UNKNOWN, UnicodeString("juillet 2008") },
3848 #if !UCONFIG_NO_BREAK_ITERATION
3849 { "fr", UnicodeString("MMMM y"), UDAT_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UnicodeString("juillet 2008") },
3850 { "fr", UnicodeString("MMMM y"), UDAT_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, UnicodeString("Juillet 2008") },
3851 { "fr", UnicodeString("MMMM y"), UDAT_CAPITALIZATION_FOR_UI_LIST_OR_MENU, UnicodeString("juillet 2008") },
3852 { "fr", UnicodeString("MMMM y"), UDAT_CAPITALIZATION_FOR_STANDALONE, UnicodeString("Juillet 2008") },
3853 #endif
3854 { "cs", UnicodeString("LLLL y"), UDAT_CONTEXT_UNKNOWN, CharsToUnicodeString("\\u010Dervenec 2008") },
3855 #if !UCONFIG_NO_BREAK_ITERATION
3856 { "cs", UnicodeString("LLLL y"), UDAT_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, CharsToUnicodeString("\\u010Dervenec 2008") },
3857 { "cs", UnicodeString("LLLL y"), UDAT_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, CharsToUnicodeString("\\u010Cervenec 2008") },
3858 { "cs", UnicodeString("LLLL y"), UDAT_CAPITALIZATION_FOR_UI_LIST_OR_MENU, CharsToUnicodeString("\\u010Cervenec 2008") },
3859 { "cs", UnicodeString("LLLL y"), UDAT_CAPITALIZATION_FOR_STANDALONE, CharsToUnicodeString("\\u010Dervenec 2008") },
3860 #endif
3861 // terminator
3862 { NULL, UnicodeString(""), (UDateFormatContextValue)0, UnicodeString("") }
3863 };
3864 UErrorCode status = U_ZERO_ERROR;
3865 Calendar* cal = Calendar::createInstance(status);
3866 if (U_FAILURE(status)) {
3867 dataerrln(UnicodeString("FAIL: Unable to create Calendar for default timezone and locale."));
3868 } else {
3869 cal->setTime(july022008, status);
3870 const TestContextItem * itemPtr;
3871 for (itemPtr = items; itemPtr->locale != NULL; itemPtr++ ) {
3872 Locale locale = Locale::createFromName(itemPtr->locale);
3873 status = U_ZERO_ERROR;
3874 SimpleDateFormat * sdmft = new SimpleDateFormat(itemPtr->pattern, locale, status);
3875 if (U_FAILURE(status)) {
3876 dataerrln(UnicodeString("FAIL: Unable to create SimpleDateFormat for specified pattern with locale ") + UnicodeString(itemPtr->locale));
3877 } else {
3878 UDateFormatContextType contextType = UDAT_CAPITALIZATION;
3879 UDateFormatContextValue contextValue = itemPtr->capitalizationContext;
3880 UnicodeString result;
3881 FieldPosition pos(0);
3882 sdmft->format(*cal, &contextType, &contextValue, 1, result, pos);
3883 if (result.compare(itemPtr->expectedFormat) != 0) {
3884 errln(UnicodeString("FAIL: format for locale ") + UnicodeString(itemPtr->locale) +
3885 ", capitalizationContext " + (int)itemPtr->capitalizationContext +
3886 ", expected " + itemPtr->expectedFormat + ", got " + result);
3887 }
3888 }
3889 if (sdmft) {
3890 delete sdmft;
3891 }
3892 }
3893 }
3894 if (cal) {
3895 delete cal;
3896 }
3897 }
3898
3899 #endif /* #if !UCONFIG_NO_FORMATTING */
3900
3901 //eof