2 *******************************************************************************
3 * Copyright (C) 1997-2003, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
9 * Modification History:
11 * Date Name Description
12 * 02/19/97 aliu Converted from java.
13 * 07/21/98 stephen Added getZoneIndex
14 * Changed weekdays/short weekdays to be one-based
15 * 06/14/99 stephen Removed SimpleDateFormat::fgTimeZoneDataSuffix
16 * 11/16/99 weiv Added 'Y' and 'e' to fgPatternChars
17 * 03/27/00 weiv Keeping resource bundle around!
18 *******************************************************************************
21 #include "unicode/utypes.h"
23 #if !UCONFIG_NO_FORMATTING
25 #include "unicode/dtfmtsym.h"
26 #include "unicode/resbund.h"
27 #include "unicode/smpdtfmt.h"
33 // *****************************************************************************
34 // class DateFormatSymbols
35 // *****************************************************************************
37 * These are static arrays we use only in the case where we have no
41 #define PATTERN_CHARS_LEN 20
44 * Unlocalized date-time pattern characters. For example: 'y', 'd', etc. All
45 * locales use the same these unlocalized pattern characters.
47 static const UChar gPatternChars
[] =
49 0x47, 0x79, 0x4D, 0x64, 0x6B, 0x48, 0x6D, 0x73, 0x53, 0x45,
50 0x44, 0x46, 0x77, 0x57, 0x61, 0x68, 0x4B, 0x7A, 0x59, 0x65, 0 /* "GyMdkHmsSEDFwWahKzYe" */
53 //------------------------------------------------------
54 // Strings of last resort. These are only used if we have no resource
55 // files. They aren't designed for actual use, just for backup.
57 // These are the month names and abbreviations of last resort.
58 static const UChar gLastResortMonthNames
[13][3] =
60 {0x0030, 0x0031, 0x0000}, /* "01" */
61 {0x0030, 0x0032, 0x0000}, /* "02" */
62 {0x0030, 0x0033, 0x0000}, /* "03" */
63 {0x0030, 0x0034, 0x0000}, /* "04" */
64 {0x0030, 0x0035, 0x0000}, /* "05" */
65 {0x0030, 0x0036, 0x0000}, /* "06" */
66 {0x0030, 0x0037, 0x0000}, /* "07" */
67 {0x0030, 0x0038, 0x0000}, /* "08" */
68 {0x0030, 0x0039, 0x0000}, /* "09" */
69 {0x0031, 0x0030, 0x0000}, /* "10" */
70 {0x0031, 0x0031, 0x0000}, /* "11" */
71 {0x0031, 0x0032, 0x0000}, /* "12" */
72 {0x0031, 0x0033, 0x0000} /* "13" */
75 // These are the weekday names and abbreviations of last resort.
76 static const UChar gLastResortDayNames
[8][2] =
78 {0x0000, 0x0000}, /* "" */
79 {0x0031, 0x0000}, /* "1" */
80 {0x0032, 0x0000}, /* "2" */
81 {0x0033, 0x0000}, /* "3" */
82 {0x0034, 0x0000}, /* "4" */
83 {0x0035, 0x0000}, /* "5" */
84 {0x0036, 0x0000}, /* "6" */
85 {0x0037, 0x0000} /* "7" */
88 // These are the am/pm and BC/AD markers of last resort.
89 static const UChar gLastResortAmPmMarkers
[2][3] =
91 {0x0041, 0x004D, 0x0000}, /* "AM" */
92 {0x0050, 0x004D, 0x0000} /* "PM" */
95 static const UChar gLastResortEras
[2][3] =
97 {0x0042, 0x0043, 0x0000}, /* "BC" */
98 {0x0041, 0x0044, 0x0000} /* "AD" */
102 // These are the zone strings of last resort.
103 static const UChar gLastResortZoneStrings
[5][4] =
105 {0x0047, 0x004D, 0x0054, 0x0000}, /* "GMT" */
106 {0x0047, 0x004D, 0x0054, 0x0000}, /* "GMT" */
107 {0x0047, 0x004D, 0x0054, 0x0000}, /* "GMT" */
108 {0x0047, 0x004D, 0x0054, 0x0000}, /* "GMT" */
109 {0x0047, 0x004D, 0x0054, 0x0000} /* "GMT" */
114 const char DateFormatSymbols::fgClassID
=0;
117 * These are the tags we expect to see in normal resource bundle files associated
120 const char DateFormatSymbols::fgErasTag
[]="Eras";
121 const char DateFormatSymbols::fgMonthNamesTag
[]="MonthNames";
122 const char DateFormatSymbols::fgMonthAbbreviationsTag
[]="MonthAbbreviations";
123 const char DateFormatSymbols::fgDayNamesTag
[]="DayNames";
124 const char DateFormatSymbols::fgDayAbbreviationsTag
[]="DayAbbreviations";
125 const char DateFormatSymbols::fgAmPmMarkersTag
[]="AmPmMarkers";
128 * These are the tags we expect to see in time zone data resource bundle files
129 * associated with a locale.
131 const char DateFormatSymbols::fgZoneStringsTag
[]="zoneStrings";
132 const char DateFormatSymbols::fgLocalPatternCharsTag
[]="localPatternChars";
135 * Jitterbug 2974: MSVC has a bug whereby new X[0] behaves badly.
138 static inline UnicodeString
* newUnicodeStringArray(size_t count
) {
139 return new UnicodeString
[count
? count
: 1];
142 //------------------------------------------------------
144 DateFormatSymbols::DateFormatSymbols(const Locale
& locale
,
148 initializeData(locale
, NULL
, status
);
151 DateFormatSymbols::DateFormatSymbols(UErrorCode
& status
)
154 initializeData(Locale::getDefault(), NULL
, status
, TRUE
);
158 DateFormatSymbols::DateFormatSymbols(const Locale
& locale
,
163 initializeData(locale
, type
, status
);
166 DateFormatSymbols::DateFormatSymbols(const char *type
, UErrorCode
& status
)
169 initializeData(Locale::getDefault(), type
, status
, TRUE
);
172 DateFormatSymbols::DateFormatSymbols(const DateFormatSymbols
& other
)
179 DateFormatSymbols::assignArray(UnicodeString
*& dstArray
,
181 const UnicodeString
* srcArray
,
184 // assignArray() is only called by copyData(), which in turn implements the
185 // copy constructor and the assignment operator.
186 // All strings in a DateFormatSymbols object are created in one of the following
187 // three ways that all allow to safely use UnicodeString::fastCopyFrom():
188 // - readonly-aliases from resource bundles
189 // - readonly-aliases or allocated strings from constants
190 // - safely cloned strings (with owned buffers) from setXYZ() functions
192 // Note that this is true for as long as DateFormatSymbols can be constructed
193 // only from a locale bundle or set via the cloning API,
194 // *and* for as long as all the strings are in *private* fields, preventing
195 // a subclass from creating these strings in an "unsafe" way (with respect to fastCopyFrom()).
197 dstArray
= newUnicodeStringArray(srcCount
);
198 if(dstArray
!= NULL
) {
200 for(i
=0; i
<srcCount
; ++i
) {
201 dstArray
[i
].fastCopyFrom(srcArray
[i
]);
207 * Create a copy, in fZoneStrings, of the given zone strings array. The
208 * member variables fZoneStringsRowCount and fZoneStringsColCount should
209 * be set already by the caller.
212 DateFormatSymbols::createZoneStrings(const UnicodeString
*const * otherStrings
)
216 fZoneStrings
= (UnicodeString
**)uprv_malloc(fZoneStringsRowCount
* sizeof(UnicodeString
*));
217 for (row
=0; row
<fZoneStringsRowCount
; ++row
)
219 fZoneStrings
[row
] = newUnicodeStringArray(fZoneStringsColCount
);
220 for (col
=0; col
<fZoneStringsColCount
; ++col
) {
221 // fastCopyFrom() - see assignArray comments
222 fZoneStrings
[row
][col
].fastCopyFrom(otherStrings
[row
][col
]);
228 * Copy all of the other's data to this.
231 DateFormatSymbols::copyData(const DateFormatSymbols
& other
) {
232 assignArray(fEras
, fErasCount
, other
.fEras
, other
.fErasCount
);
233 assignArray(fMonths
, fMonthsCount
, other
.fMonths
, other
.fMonthsCount
);
234 assignArray(fShortMonths
, fShortMonthsCount
, other
.fShortMonths
, other
.fShortMonthsCount
);
235 assignArray(fWeekdays
, fWeekdaysCount
, other
.fWeekdays
, other
.fWeekdaysCount
);
236 assignArray(fShortWeekdays
, fShortWeekdaysCount
, other
.fShortWeekdays
, other
.fShortWeekdaysCount
);
237 assignArray(fAmPms
, fAmPmsCount
, other
.fAmPms
, other
.fAmPmsCount
);
239 fZoneStringsRowCount
= other
.fZoneStringsRowCount
;
240 fZoneStringsColCount
= other
.fZoneStringsColCount
;
241 createZoneStrings((const UnicodeString
**)other
.fZoneStrings
);
243 // fastCopyFrom() - see assignArray comments
244 fLocalPatternChars
.fastCopyFrom(other
.fLocalPatternChars
);
248 * Assignment operator.
250 DateFormatSymbols
& DateFormatSymbols::operator=(const DateFormatSymbols
& other
)
258 DateFormatSymbols::~DateFormatSymbols()
263 void DateFormatSymbols::dispose()
265 if (fEras
) delete[] fEras
;
266 if (fMonths
) delete[] fMonths
;
267 if (fShortMonths
) delete[] fShortMonths
;
268 if (fWeekdays
) delete[] fWeekdays
;
269 if (fShortWeekdays
) delete[] fShortWeekdays
;
270 if (fAmPms
) delete[] fAmPms
;
272 disposeZoneStrings();
275 void DateFormatSymbols::disposeZoneStrings()
278 for (int32_t row
=0; row
<fZoneStringsRowCount
; ++row
)
279 delete[] fZoneStrings
[row
];
280 uprv_free(fZoneStrings
);
285 DateFormatSymbols::arrayCompare(const UnicodeString
* array1
,
286 const UnicodeString
* array2
,
289 if (array1
== array2
) return TRUE
;
293 if (array1
[count
] != array2
[count
]) return FALSE
;
299 DateFormatSymbols::operator==(const DateFormatSymbols
& other
) const
301 // First do cheap comparisons
302 if (this == &other
) {
305 if (fErasCount
== other
.fErasCount
&&
306 fMonthsCount
== other
.fMonthsCount
&&
307 fShortMonthsCount
== other
.fShortMonthsCount
&&
308 fWeekdaysCount
== other
.fWeekdaysCount
&&
309 fShortWeekdaysCount
== other
.fShortWeekdaysCount
&&
310 fAmPmsCount
== other
.fAmPmsCount
&&
311 fZoneStringsRowCount
== other
.fZoneStringsRowCount
&&
312 fZoneStringsColCount
== other
.fZoneStringsColCount
)
314 // Now compare the arrays themselves
315 if (arrayCompare(fEras
, other
.fEras
, fErasCount
) &&
316 arrayCompare(fMonths
, other
.fMonths
, fMonthsCount
) &&
317 arrayCompare(fShortMonths
, other
.fShortMonths
, fShortMonthsCount
) &&
318 arrayCompare(fWeekdays
, other
.fWeekdays
, fWeekdaysCount
) &&
319 arrayCompare(fShortWeekdays
, other
.fShortWeekdays
, fShortWeekdaysCount
) &&
320 arrayCompare(fAmPms
, other
.fAmPms
, fAmPmsCount
))
322 if (fZoneStrings
== other
.fZoneStrings
) return TRUE
;
324 for (int32_t row
=0; row
<fZoneStringsRowCount
; ++row
)
326 if (!arrayCompare(fZoneStrings
[row
], other
.fZoneStrings
[row
], fZoneStringsColCount
))
335 //------------------------------------------------------
338 DateFormatSymbols::getEras(int32_t &count
) const
345 DateFormatSymbols::getMonths(int32_t &count
) const
347 count
= fMonthsCount
;
352 DateFormatSymbols::getShortMonths(int32_t &count
) const
354 count
= fShortMonthsCount
;
359 DateFormatSymbols::getWeekdays(int32_t &count
) const
361 count
= fWeekdaysCount
;
366 DateFormatSymbols::getShortWeekdays(int32_t &count
) const
368 count
= fShortWeekdaysCount
;
369 return fShortWeekdays
;
373 DateFormatSymbols::getAmPmStrings(int32_t &count
) const
379 //------------------------------------------------------
382 DateFormatSymbols::setEras(const UnicodeString
* erasArray
, int32_t count
)
384 // delete the old list if we own it
385 if (fEras
) delete[] fEras
;
387 // we always own the new list, which we create here (we duplicate rather
388 // than adopting the list passed in)
389 fEras
= newUnicodeStringArray(count
);
390 uprv_arrayCopy(erasArray
,fEras
, count
);
395 DateFormatSymbols::setMonths(const UnicodeString
* monthsArray
, int32_t count
)
397 // delete the old list if we own it
398 if (fMonths
) delete[] fMonths
;
400 // we always own the new list, which we create here (we duplicate rather
401 // than adopting the list passed in)
402 fMonths
= newUnicodeStringArray(count
);
403 uprv_arrayCopy( monthsArray
,fMonths
,count
);
404 fMonthsCount
= count
;
408 DateFormatSymbols::setShortMonths(const UnicodeString
* shortMonthsArray
, int32_t count
)
410 // delete the old list if we own it
411 if (fShortMonths
) delete[] fShortMonths
;
413 // we always own the new list, which we create here (we duplicate rather
414 // than adopting the list passed in)
415 fShortMonths
= newUnicodeStringArray(count
);
416 uprv_arrayCopy(shortMonthsArray
,fShortMonths
, count
);
417 fShortMonthsCount
= count
;
420 void DateFormatSymbols::setWeekdays(const UnicodeString
* weekdaysArray
, int32_t count
)
422 // delete the old list if we own it
423 if (fWeekdays
) delete[] fWeekdays
;
425 // we always own the new list, which we create here (we duplicate rather
426 // than adopting the list passed in)
427 fWeekdays
= newUnicodeStringArray(count
);
428 uprv_arrayCopy(weekdaysArray
,fWeekdays
,count
);
429 fWeekdaysCount
= count
;
433 DateFormatSymbols::setShortWeekdays(const UnicodeString
* shortWeekdaysArray
, int32_t count
)
435 // delete the old list if we own it
436 if (fShortWeekdays
) delete[] fShortWeekdays
;
438 // we always own the new list, which we create here (we duplicate rather
439 // than adopting the list passed in)
440 fShortWeekdays
= newUnicodeStringArray(count
);
441 uprv_arrayCopy( shortWeekdaysArray
,fShortWeekdays
,count
);
442 fShortWeekdaysCount
= count
;
446 DateFormatSymbols::setAmPmStrings(const UnicodeString
* amPmsArray
, int32_t count
)
448 // delete the old list if we own it
449 if (fAmPms
) delete[] fAmPms
;
451 // we always own the new list, which we create here (we duplicate rather
452 // than adopting the list passed in)
453 fAmPms
= newUnicodeStringArray(count
);
454 uprv_arrayCopy(amPmsArray
,fAmPms
,count
);
458 //------------------------------------------------------
460 const UnicodeString
**
461 DateFormatSymbols::getZoneStrings(int32_t& rowCount
, int32_t& columnCount
) const
463 rowCount
= fZoneStringsRowCount
;
464 columnCount
= fZoneStringsColCount
;
465 return (const UnicodeString
**)fZoneStrings
; // Compiler requires cast
469 DateFormatSymbols::setZoneStrings(const UnicodeString
* const *strings
, int32_t rowCount
, int32_t columnCount
)
471 // since deleting a 2-d array is a pain in the butt, we offload that task to
472 // a separate function
473 disposeZoneStrings();
475 // we always own the new list, which we create here (we duplicate rather
476 // than adopting the list passed in)
477 fZoneStringsRowCount
= rowCount
;
478 fZoneStringsColCount
= columnCount
;
479 createZoneStrings((const UnicodeString
**)strings
);
482 //------------------------------------------------------
485 DateFormatSymbols::getPatternUChars(void)
487 return gPatternChars
;
490 //------------------------------------------------------
493 DateFormatSymbols::getLocalPatternChars(UnicodeString
& result
) const
495 // fastCopyFrom() - see assignArray comments
496 return result
.fastCopyFrom(fLocalPatternChars
);
499 //------------------------------------------------------
502 DateFormatSymbols::setLocalPatternChars(const UnicodeString
& newLocalPatternChars
)
504 fLocalPatternChars
= newLocalPatternChars
;
507 //------------------------------------------------------
510 DateFormatSymbols::initField(UnicodeString
**field
, int32_t& length
, const ResourceBundle data
, UErrorCode
&status
) {
511 if (U_SUCCESS(status
)) {
512 length
= data
.getSize();
513 *field
= newUnicodeStringArray(length
);
515 for(int32_t i
= 0; i
<length
; i
++) {
516 // fastCopyFrom() - see assignArray comments
517 (*(field
)+i
)->fastCopyFrom(data
.getStringEx(i
, status
));
522 status
= U_MEMORY_ALLOCATION_ERROR
;
528 DateFormatSymbols::initField(UnicodeString
**field
, int32_t& length
, const UChar
*data
, LastResortSize numStr
, LastResortSize strLen
, UErrorCode
&status
) {
529 if (U_SUCCESS(status
)) {
531 *field
= newUnicodeStringArray((size_t)numStr
);
533 for(int32_t i
= 0; i
<length
; i
++) {
534 // readonly aliases - all "data" strings are constant
535 // -1 as length for variable-length strings (gLastResortDayNames[0] is empty)
536 (*(field
)+i
)->setTo(TRUE
, data
+(i
*((int32_t)strLen
)), -1);
541 status
= U_MEMORY_ALLOCATION_ERROR
;
547 DateFormatSymbols::getData(ResourceBundle
&rb
, const char *tag
, const char *type
, UErrorCode
& status
)
552 if(!type
|| !*type
) {
556 int32_t len
= uprv_strlen(tag
) + 1 + uprv_strlen(type
); // tag + _ + type (i.e. Eras_Japanese )
557 if(len
>= (int32_t)sizeof(tmp
)) {
558 fullTag
= (char*)uprv_malloc(len
+1);
561 uprv_strcpy(fullTag
, tag
);
562 uprv_strcat(fullTag
, "_");
563 uprv_strcat(fullTag
, type
);
565 ResourceBundle resource
= rb
.get(fullTag
, status
);
567 if(status
== U_MISSING_RESOURCE_ERROR
) {
568 status
= U_ZERO_ERROR
;
569 resource
= rb
.get(tag
, status
);
573 uprv_free(fullTag
); // not stack allocated
580 DateFormatSymbols::initializeData(const Locale
& locale
, const char *type
, UErrorCode
& status
, UBool useLastResortData
)
584 /* In case something goes wrong, initialize all of the data to NULL. */
593 fShortWeekdays
= NULL
;
594 fShortWeekdaysCount
=0;
597 fZoneStringsRowCount
= 0;
598 fZoneStringsColCount
= 0;
602 if (U_FAILURE(status
)) return;
605 * Retrieve the string arrays we need from the resource bundle file.
606 * We cast away const here, but that's okay; we won't delete any of
609 ResourceBundle
resource((char *)0, locale
, status
);
611 if (U_FAILURE(status
))
613 if (useLastResortData
)
615 // Handle the case in which there is no resource data present.
616 // We don't have to generate usable patterns in this situation;
617 // we just need to produce something that will be semi-intelligible
620 status
= U_USING_FALLBACK_WARNING
;
622 initField(&fEras
, fErasCount
, (const UChar
*)gLastResortEras
, kEraNum
, kEraLen
, status
);
623 initField(&fMonths
, fMonthsCount
, (const UChar
*)gLastResortMonthNames
, kMonthNum
, kMonthLen
, status
);
624 initField(&fShortMonths
, fShortMonthsCount
, (const UChar
*)gLastResortMonthNames
, kMonthNum
, kMonthLen
, status
);
625 initField(&fWeekdays
, fWeekdaysCount
, (const UChar
*)gLastResortDayNames
, kDayNum
, kDayLen
, status
);
626 initField(&fShortWeekdays
, fShortWeekdaysCount
, (const UChar
*)gLastResortDayNames
, kDayNum
, kDayLen
, status
);
627 initField(&fAmPms
, fAmPmsCount
, (const UChar
*)gLastResortAmPmMarkers
, kAmPmNum
, kAmPmLen
, status
);
629 fZoneStrings
= (UnicodeString
**)uprv_malloc(sizeof(UnicodeString
*));
631 if (fZoneStrings
== 0) {
632 status
= U_MEMORY_ALLOCATION_ERROR
;
635 fZoneStringsRowCount
= 1;
636 initField(fZoneStrings
, fZoneStringsColCount
, (const UChar
*)gLastResortZoneStrings
, kZoneNum
, kZoneLen
, status
);
637 fLocalPatternChars
= gPatternChars
;
642 // if we make it to here, the resource data is cool, and we can get everything out
643 // of it that we need except for the time-zone and localized-pattern data, which
644 // are stoerd in a separate file
645 initField(&fEras
, fErasCount
, getData(resource
, fgErasTag
, type
, status
), status
);
646 initField(&fMonths
, fMonthsCount
, getData(resource
, fgMonthNamesTag
, type
, status
), status
);
647 initField(&fShortMonths
, fShortMonthsCount
, getData(resource
, fgMonthAbbreviationsTag
, type
, status
), status
);
648 initField(&fAmPms
, fAmPmsCount
, getData(resource
, fgAmPmMarkersTag
, type
, status
), status
);
649 // fastCopyFrom() - see assignArray comments
650 fLocalPatternChars
.fastCopyFrom(resource
.getStringEx(fgLocalPatternCharsTag
, status
));
652 ResourceBundle zoneArray
= resource
.get(fgZoneStringsTag
, status
);
653 fZoneStringsRowCount
= zoneArray
.getSize();
654 ResourceBundle zoneRow
= zoneArray
.get((int32_t)0, status
);
655 /* TODO: Fix the case where the zoneStrings is not a perfect square array of information. */
656 fZoneStringsColCount
= zoneRow
.getSize();
657 fZoneStrings
= (UnicodeString
**)uprv_malloc(fZoneStringsRowCount
* sizeof(UnicodeString
*));
659 if (fZoneStrings
== 0) {
660 status
= U_MEMORY_ALLOCATION_ERROR
;
663 for(i
= 0; i
<fZoneStringsRowCount
; i
++) {
664 *(fZoneStrings
+i
) = newUnicodeStringArray(fZoneStringsColCount
);
666 if ((*(fZoneStrings
+i
)) == 0) {
667 status
= U_MEMORY_ALLOCATION_ERROR
;
670 zoneRow
= zoneArray
.get(i
, status
);
671 for(int32_t j
= 0; j
<fZoneStringsColCount
; j
++) {
672 // fastCopyFrom() - see assignArray comments
673 fZoneStrings
[i
][j
].fastCopyFrom(zoneRow
.getStringEx(j
, status
));
677 // {sfb} fixed to handle 1-based weekdays
678 ResourceBundle weekdaysData
= getData(resource
, fgDayNamesTag
, type
, status
);
679 fWeekdaysCount
= weekdaysData
.getSize();
680 fWeekdays
= new UnicodeString
[fWeekdaysCount
+1];
682 if (fWeekdays
== 0) {
683 status
= U_MEMORY_ALLOCATION_ERROR
;
686 // leave fWeekdays[0] empty
687 for(i
= 0; i
<fWeekdaysCount
; i
++) {
688 // fastCopyFrom() - see assignArray comments
689 fWeekdays
[i
+1].fastCopyFrom(weekdaysData
.getStringEx(i
, status
));
692 ResourceBundle lsweekdaysData
= getData(resource
, fgDayAbbreviationsTag
, type
, status
);
693 fShortWeekdaysCount
= lsweekdaysData
.getSize();
694 fShortWeekdays
= new UnicodeString
[fShortWeekdaysCount
+1];
696 if (fShortWeekdays
== 0) {
697 status
= U_MEMORY_ALLOCATION_ERROR
;
700 // leave fShortWeekdays[0] empty
701 for(i
= 0; i
<fShortWeekdaysCount
; i
++) {
702 // fastCopyFrom() - see assignArray comments
703 fShortWeekdays
[i
+1].fastCopyFrom(lsweekdaysData
.getStringEx(i
, status
));
706 fWeekdaysCount
= fShortWeekdaysCount
= 8;
708 // If the locale data does not include new pattern chars, use the defaults
709 if (fLocalPatternChars
.length() < PATTERN_CHARS_LEN
) {
710 fLocalPatternChars
.append(&gPatternChars
[fLocalPatternChars
.length()]);
715 * Package private: used by SimpleDateFormat
716 * Gets the index for the given time zone ID to obtain the timezone
717 * strings for formatting. The time zone ID is just for programmatic
718 * lookup. NOT LOCALIZED!!!
719 * @param ID the given time zone ID.
720 * @return the index of the given time zone ID. Returns -1 if
721 * the given time zone ID can't be located in the DateFormatSymbols object.
722 * @see java.util.SimpleTimeZone
724 int32_t DateFormatSymbols::getZoneIndex(const UnicodeString
& ID
) const
726 int32_t result
= _getZoneIndex(ID
);
731 // Do a search through the equivalency group for the given ID
732 int32_t n
= TimeZone::countEquivalentIDs(ID
);
735 for (i
=0; i
<n
; ++i
) {
736 UnicodeString equivID
= TimeZone::getEquivalentID(ID
, i
);
738 int32_t equivResult
= _getZoneIndex(equivID
);
739 if (equivResult
>= 0) {
750 * Lookup the given ID. Do NOT do an equivalency search.
752 int32_t DateFormatSymbols::_getZoneIndex(const UnicodeString
& ID
) const
754 for(int32_t index
= 0; index
< fZoneStringsRowCount
; index
++) {
755 if (0 == ID
.caseCompare(fZoneStrings
[index
][0], 0)) {
765 #endif /* #if !UCONFIG_NO_FORMATTING */