Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * Copyright (C) 1997-2013, International Business Machines Corporation and * |
michael@0 | 4 | * others. All Rights Reserved. * |
michael@0 | 5 | ******************************************************************************* |
michael@0 | 6 | * |
michael@0 | 7 | * File DTFMTSYM.CPP |
michael@0 | 8 | * |
michael@0 | 9 | * Modification History: |
michael@0 | 10 | * |
michael@0 | 11 | * Date Name Description |
michael@0 | 12 | * 02/19/97 aliu Converted from java. |
michael@0 | 13 | * 07/21/98 stephen Added getZoneIndex |
michael@0 | 14 | * Changed weekdays/short weekdays to be one-based |
michael@0 | 15 | * 06/14/99 stephen Removed SimpleDateFormat::fgTimeZoneDataSuffix |
michael@0 | 16 | * 11/16/99 weiv Added 'Y' and 'e' to fgPatternChars |
michael@0 | 17 | * 03/27/00 weiv Keeping resource bundle around! |
michael@0 | 18 | * 06/30/05 emmons Added eraNames, narrow month/day, standalone context |
michael@0 | 19 | * 10/12/05 emmons Added setters for eraNames, month/day by width/context |
michael@0 | 20 | ******************************************************************************* |
michael@0 | 21 | */ |
michael@0 | 22 | #include "unicode/utypes.h" |
michael@0 | 23 | |
michael@0 | 24 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 25 | #include "unicode/ustring.h" |
michael@0 | 26 | #include "unicode/dtfmtsym.h" |
michael@0 | 27 | #include "unicode/smpdtfmt.h" |
michael@0 | 28 | #include "unicode/msgfmt.h" |
michael@0 | 29 | #include "unicode/tznames.h" |
michael@0 | 30 | #include "cpputils.h" |
michael@0 | 31 | #include "ucln_in.h" |
michael@0 | 32 | #include "umutex.h" |
michael@0 | 33 | #include "cmemory.h" |
michael@0 | 34 | #include "cstring.h" |
michael@0 | 35 | #include "locbased.h" |
michael@0 | 36 | #include "gregoimp.h" |
michael@0 | 37 | #include "hash.h" |
michael@0 | 38 | #include "uresimp.h" |
michael@0 | 39 | #include "ureslocs.h" |
michael@0 | 40 | |
michael@0 | 41 | // ***************************************************************************** |
michael@0 | 42 | // class DateFormatSymbols |
michael@0 | 43 | // ***************************************************************************** |
michael@0 | 44 | |
michael@0 | 45 | /** |
michael@0 | 46 | * These are static arrays we use only in the case where we have no |
michael@0 | 47 | * resource data. |
michael@0 | 48 | */ |
michael@0 | 49 | |
michael@0 | 50 | #define PATTERN_CHARS_LEN 34 |
michael@0 | 51 | |
michael@0 | 52 | /** |
michael@0 | 53 | * Unlocalized date-time pattern characters. For example: 'y', 'd', etc. All |
michael@0 | 54 | * locales use the same these unlocalized pattern characters. |
michael@0 | 55 | */ |
michael@0 | 56 | static const UChar gPatternChars[] = { |
michael@0 | 57 | // GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXx |
michael@0 | 58 | 0x47, 0x79, 0x4D, 0x64, 0x6B, 0x48, 0x6D, 0x73, 0x53, 0x45, |
michael@0 | 59 | 0x44, 0x46, 0x77, 0x57, 0x61, 0x68, 0x4B, 0x7A, 0x59, 0x65, |
michael@0 | 60 | 0x75, 0x67, 0x41, 0x5A, 0x76, 0x63, 0x4c, 0x51, 0x71, 0x56, |
michael@0 | 61 | 0x55, 0x4F, 0x58, 0x78, 0 |
michael@0 | 62 | }; |
michael@0 | 63 | |
michael@0 | 64 | /* length of an array */ |
michael@0 | 65 | #define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0])) |
michael@0 | 66 | |
michael@0 | 67 | //------------------------------------------------------ |
michael@0 | 68 | // Strings of last resort. These are only used if we have no resource |
michael@0 | 69 | // files. They aren't designed for actual use, just for backup. |
michael@0 | 70 | |
michael@0 | 71 | // These are the month names and abbreviations of last resort. |
michael@0 | 72 | static const UChar gLastResortMonthNames[13][3] = |
michael@0 | 73 | { |
michael@0 | 74 | {0x0030, 0x0031, 0x0000}, /* "01" */ |
michael@0 | 75 | {0x0030, 0x0032, 0x0000}, /* "02" */ |
michael@0 | 76 | {0x0030, 0x0033, 0x0000}, /* "03" */ |
michael@0 | 77 | {0x0030, 0x0034, 0x0000}, /* "04" */ |
michael@0 | 78 | {0x0030, 0x0035, 0x0000}, /* "05" */ |
michael@0 | 79 | {0x0030, 0x0036, 0x0000}, /* "06" */ |
michael@0 | 80 | {0x0030, 0x0037, 0x0000}, /* "07" */ |
michael@0 | 81 | {0x0030, 0x0038, 0x0000}, /* "08" */ |
michael@0 | 82 | {0x0030, 0x0039, 0x0000}, /* "09" */ |
michael@0 | 83 | {0x0031, 0x0030, 0x0000}, /* "10" */ |
michael@0 | 84 | {0x0031, 0x0031, 0x0000}, /* "11" */ |
michael@0 | 85 | {0x0031, 0x0032, 0x0000}, /* "12" */ |
michael@0 | 86 | {0x0031, 0x0033, 0x0000} /* "13" */ |
michael@0 | 87 | }; |
michael@0 | 88 | |
michael@0 | 89 | // These are the weekday names and abbreviations of last resort. |
michael@0 | 90 | static const UChar gLastResortDayNames[8][2] = |
michael@0 | 91 | { |
michael@0 | 92 | {0x0030, 0x0000}, /* "0" */ |
michael@0 | 93 | {0x0031, 0x0000}, /* "1" */ |
michael@0 | 94 | {0x0032, 0x0000}, /* "2" */ |
michael@0 | 95 | {0x0033, 0x0000}, /* "3" */ |
michael@0 | 96 | {0x0034, 0x0000}, /* "4" */ |
michael@0 | 97 | {0x0035, 0x0000}, /* "5" */ |
michael@0 | 98 | {0x0036, 0x0000}, /* "6" */ |
michael@0 | 99 | {0x0037, 0x0000} /* "7" */ |
michael@0 | 100 | }; |
michael@0 | 101 | |
michael@0 | 102 | // These are the quarter names and abbreviations of last resort. |
michael@0 | 103 | static const UChar gLastResortQuarters[4][2] = |
michael@0 | 104 | { |
michael@0 | 105 | {0x0031, 0x0000}, /* "1" */ |
michael@0 | 106 | {0x0032, 0x0000}, /* "2" */ |
michael@0 | 107 | {0x0033, 0x0000}, /* "3" */ |
michael@0 | 108 | {0x0034, 0x0000}, /* "4" */ |
michael@0 | 109 | }; |
michael@0 | 110 | |
michael@0 | 111 | // These are the am/pm and BC/AD markers of last resort. |
michael@0 | 112 | static const UChar gLastResortAmPmMarkers[2][3] = |
michael@0 | 113 | { |
michael@0 | 114 | {0x0041, 0x004D, 0x0000}, /* "AM" */ |
michael@0 | 115 | {0x0050, 0x004D, 0x0000} /* "PM" */ |
michael@0 | 116 | }; |
michael@0 | 117 | |
michael@0 | 118 | static const UChar gLastResortEras[2][3] = |
michael@0 | 119 | { |
michael@0 | 120 | {0x0042, 0x0043, 0x0000}, /* "BC" */ |
michael@0 | 121 | {0x0041, 0x0044, 0x0000} /* "AD" */ |
michael@0 | 122 | }; |
michael@0 | 123 | |
michael@0 | 124 | /* Sizes for the last resort string arrays */ |
michael@0 | 125 | typedef enum LastResortSize { |
michael@0 | 126 | kMonthNum = 13, |
michael@0 | 127 | kMonthLen = 3, |
michael@0 | 128 | |
michael@0 | 129 | kDayNum = 8, |
michael@0 | 130 | kDayLen = 2, |
michael@0 | 131 | |
michael@0 | 132 | kAmPmNum = 2, |
michael@0 | 133 | kAmPmLen = 3, |
michael@0 | 134 | |
michael@0 | 135 | kQuarterNum = 4, |
michael@0 | 136 | kQuarterLen = 2, |
michael@0 | 137 | |
michael@0 | 138 | kEraNum = 2, |
michael@0 | 139 | kEraLen = 3, |
michael@0 | 140 | |
michael@0 | 141 | kZoneNum = 5, |
michael@0 | 142 | kZoneLen = 4, |
michael@0 | 143 | |
michael@0 | 144 | kGmtHourNum = 4, |
michael@0 | 145 | kGmtHourLen = 10 |
michael@0 | 146 | } LastResortSize; |
michael@0 | 147 | |
michael@0 | 148 | U_NAMESPACE_BEGIN |
michael@0 | 149 | |
michael@0 | 150 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateFormatSymbols) |
michael@0 | 151 | |
michael@0 | 152 | #define kSUPPLEMENTAL "supplementalData" |
michael@0 | 153 | |
michael@0 | 154 | /** |
michael@0 | 155 | * These are the tags we expect to see in normal resource bundle files associated |
michael@0 | 156 | * with a locale and calendar |
michael@0 | 157 | */ |
michael@0 | 158 | static const char gErasTag[]="eras"; |
michael@0 | 159 | static const char gCyclicNameSetsTag[]="cyclicNameSets"; |
michael@0 | 160 | static const char gNameSetYearsTag[]="years"; |
michael@0 | 161 | static const char gMonthNamesTag[]="monthNames"; |
michael@0 | 162 | static const char gMonthPatternsTag[]="monthPatterns"; |
michael@0 | 163 | static const char gDayNamesTag[]="dayNames"; |
michael@0 | 164 | static const char gNamesWideTag[]="wide"; |
michael@0 | 165 | static const char gNamesAbbrTag[]="abbreviated"; |
michael@0 | 166 | static const char gNamesShortTag[]="short"; |
michael@0 | 167 | static const char gNamesNarrowTag[]="narrow"; |
michael@0 | 168 | static const char gNamesAllTag[]="all"; |
michael@0 | 169 | static const char gNamesLeapTag[]="leap"; |
michael@0 | 170 | static const char gNamesFormatTag[]="format"; |
michael@0 | 171 | static const char gNamesStandaloneTag[]="stand-alone"; |
michael@0 | 172 | static const char gNamesNumericTag[]="numeric"; |
michael@0 | 173 | static const char gAmPmMarkersTag[]="AmPmMarkers"; |
michael@0 | 174 | static const char gQuartersTag[]="quarters"; |
michael@0 | 175 | |
michael@0 | 176 | // static const char gZoneStringsTag[]="zoneStrings"; |
michael@0 | 177 | |
michael@0 | 178 | // static const char gLocalPatternCharsTag[]="localPatternChars"; |
michael@0 | 179 | |
michael@0 | 180 | static const char gContextTransformsTag[]="contextTransforms"; |
michael@0 | 181 | |
michael@0 | 182 | static UMutex LOCK = U_MUTEX_INITIALIZER; |
michael@0 | 183 | |
michael@0 | 184 | /** |
michael@0 | 185 | * Jitterbug 2974: MSVC has a bug whereby new X[0] behaves badly. |
michael@0 | 186 | * Work around this. |
michael@0 | 187 | */ |
michael@0 | 188 | static inline UnicodeString* newUnicodeStringArray(size_t count) { |
michael@0 | 189 | return new UnicodeString[count ? count : 1]; |
michael@0 | 190 | } |
michael@0 | 191 | |
michael@0 | 192 | //------------------------------------------------------ |
michael@0 | 193 | |
michael@0 | 194 | DateFormatSymbols::DateFormatSymbols(const Locale& locale, |
michael@0 | 195 | UErrorCode& status) |
michael@0 | 196 | : UObject() |
michael@0 | 197 | { |
michael@0 | 198 | initializeData(locale, NULL, status); |
michael@0 | 199 | } |
michael@0 | 200 | |
michael@0 | 201 | DateFormatSymbols::DateFormatSymbols(UErrorCode& status) |
michael@0 | 202 | : UObject() |
michael@0 | 203 | { |
michael@0 | 204 | initializeData(Locale::getDefault(), NULL, status, TRUE); |
michael@0 | 205 | } |
michael@0 | 206 | |
michael@0 | 207 | |
michael@0 | 208 | DateFormatSymbols::DateFormatSymbols(const Locale& locale, |
michael@0 | 209 | const char *type, |
michael@0 | 210 | UErrorCode& status) |
michael@0 | 211 | : UObject() |
michael@0 | 212 | { |
michael@0 | 213 | initializeData(locale, type, status); |
michael@0 | 214 | } |
michael@0 | 215 | |
michael@0 | 216 | DateFormatSymbols::DateFormatSymbols(const char *type, UErrorCode& status) |
michael@0 | 217 | : UObject() |
michael@0 | 218 | { |
michael@0 | 219 | initializeData(Locale::getDefault(), type, status, TRUE); |
michael@0 | 220 | } |
michael@0 | 221 | |
michael@0 | 222 | DateFormatSymbols::DateFormatSymbols(const DateFormatSymbols& other) |
michael@0 | 223 | : UObject(other) |
michael@0 | 224 | { |
michael@0 | 225 | copyData(other); |
michael@0 | 226 | } |
michael@0 | 227 | |
michael@0 | 228 | void |
michael@0 | 229 | DateFormatSymbols::assignArray(UnicodeString*& dstArray, |
michael@0 | 230 | int32_t& dstCount, |
michael@0 | 231 | const UnicodeString* srcArray, |
michael@0 | 232 | int32_t srcCount) |
michael@0 | 233 | { |
michael@0 | 234 | // assignArray() is only called by copyData(), which in turn implements the |
michael@0 | 235 | // copy constructor and the assignment operator. |
michael@0 | 236 | // All strings in a DateFormatSymbols object are created in one of the following |
michael@0 | 237 | // three ways that all allow to safely use UnicodeString::fastCopyFrom(): |
michael@0 | 238 | // - readonly-aliases from resource bundles |
michael@0 | 239 | // - readonly-aliases or allocated strings from constants |
michael@0 | 240 | // - safely cloned strings (with owned buffers) from setXYZ() functions |
michael@0 | 241 | // |
michael@0 | 242 | // Note that this is true for as long as DateFormatSymbols can be constructed |
michael@0 | 243 | // only from a locale bundle or set via the cloning API, |
michael@0 | 244 | // *and* for as long as all the strings are in *private* fields, preventing |
michael@0 | 245 | // a subclass from creating these strings in an "unsafe" way (with respect to fastCopyFrom()). |
michael@0 | 246 | dstCount = srcCount; |
michael@0 | 247 | dstArray = newUnicodeStringArray(srcCount); |
michael@0 | 248 | if(dstArray != NULL) { |
michael@0 | 249 | int32_t i; |
michael@0 | 250 | for(i=0; i<srcCount; ++i) { |
michael@0 | 251 | dstArray[i].fastCopyFrom(srcArray[i]); |
michael@0 | 252 | } |
michael@0 | 253 | } |
michael@0 | 254 | } |
michael@0 | 255 | |
michael@0 | 256 | /** |
michael@0 | 257 | * Create a copy, in fZoneStrings, of the given zone strings array. The |
michael@0 | 258 | * member variables fZoneStringsRowCount and fZoneStringsColCount should |
michael@0 | 259 | * be set already by the caller. |
michael@0 | 260 | */ |
michael@0 | 261 | void |
michael@0 | 262 | DateFormatSymbols::createZoneStrings(const UnicodeString *const * otherStrings) |
michael@0 | 263 | { |
michael@0 | 264 | int32_t row, col; |
michael@0 | 265 | UBool failed = FALSE; |
michael@0 | 266 | |
michael@0 | 267 | fZoneStrings = (UnicodeString **)uprv_malloc(fZoneStringsRowCount * sizeof(UnicodeString *)); |
michael@0 | 268 | if (fZoneStrings != NULL) { |
michael@0 | 269 | for (row=0; row<fZoneStringsRowCount; ++row) |
michael@0 | 270 | { |
michael@0 | 271 | fZoneStrings[row] = newUnicodeStringArray(fZoneStringsColCount); |
michael@0 | 272 | if (fZoneStrings[row] == NULL) { |
michael@0 | 273 | failed = TRUE; |
michael@0 | 274 | break; |
michael@0 | 275 | } |
michael@0 | 276 | for (col=0; col<fZoneStringsColCount; ++col) { |
michael@0 | 277 | // fastCopyFrom() - see assignArray comments |
michael@0 | 278 | fZoneStrings[row][col].fastCopyFrom(otherStrings[row][col]); |
michael@0 | 279 | } |
michael@0 | 280 | } |
michael@0 | 281 | } |
michael@0 | 282 | // If memory allocation failed, roll back and delete fZoneStrings |
michael@0 | 283 | if (failed) { |
michael@0 | 284 | for (int i = row; i >= 0; i--) { |
michael@0 | 285 | delete[] fZoneStrings[i]; |
michael@0 | 286 | } |
michael@0 | 287 | uprv_free(fZoneStrings); |
michael@0 | 288 | fZoneStrings = NULL; |
michael@0 | 289 | } |
michael@0 | 290 | } |
michael@0 | 291 | |
michael@0 | 292 | /** |
michael@0 | 293 | * Copy all of the other's data to this. |
michael@0 | 294 | */ |
michael@0 | 295 | void |
michael@0 | 296 | DateFormatSymbols::copyData(const DateFormatSymbols& other) { |
michael@0 | 297 | assignArray(fEras, fErasCount, other.fEras, other.fErasCount); |
michael@0 | 298 | assignArray(fEraNames, fEraNamesCount, other.fEraNames, other.fEraNamesCount); |
michael@0 | 299 | assignArray(fNarrowEras, fNarrowErasCount, other.fNarrowEras, other.fNarrowErasCount); |
michael@0 | 300 | assignArray(fMonths, fMonthsCount, other.fMonths, other.fMonthsCount); |
michael@0 | 301 | assignArray(fShortMonths, fShortMonthsCount, other.fShortMonths, other.fShortMonthsCount); |
michael@0 | 302 | assignArray(fNarrowMonths, fNarrowMonthsCount, other.fNarrowMonths, other.fNarrowMonthsCount); |
michael@0 | 303 | assignArray(fStandaloneMonths, fStandaloneMonthsCount, other.fStandaloneMonths, other.fStandaloneMonthsCount); |
michael@0 | 304 | assignArray(fStandaloneShortMonths, fStandaloneShortMonthsCount, other.fStandaloneShortMonths, other.fStandaloneShortMonthsCount); |
michael@0 | 305 | assignArray(fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, other.fStandaloneNarrowMonths, other.fStandaloneNarrowMonthsCount); |
michael@0 | 306 | assignArray(fWeekdays, fWeekdaysCount, other.fWeekdays, other.fWeekdaysCount); |
michael@0 | 307 | assignArray(fShortWeekdays, fShortWeekdaysCount, other.fShortWeekdays, other.fShortWeekdaysCount); |
michael@0 | 308 | assignArray(fShorterWeekdays, fShorterWeekdaysCount, other.fShorterWeekdays, other.fShorterWeekdaysCount); |
michael@0 | 309 | assignArray(fNarrowWeekdays, fNarrowWeekdaysCount, other.fNarrowWeekdays, other.fNarrowWeekdaysCount); |
michael@0 | 310 | assignArray(fStandaloneWeekdays, fStandaloneWeekdaysCount, other.fStandaloneWeekdays, other.fStandaloneWeekdaysCount); |
michael@0 | 311 | assignArray(fStandaloneShortWeekdays, fStandaloneShortWeekdaysCount, other.fStandaloneShortWeekdays, other.fStandaloneShortWeekdaysCount); |
michael@0 | 312 | assignArray(fStandaloneShorterWeekdays, fStandaloneShorterWeekdaysCount, other.fStandaloneShorterWeekdays, other.fStandaloneShorterWeekdaysCount); |
michael@0 | 313 | assignArray(fStandaloneNarrowWeekdays, fStandaloneNarrowWeekdaysCount, other.fStandaloneNarrowWeekdays, other.fStandaloneNarrowWeekdaysCount); |
michael@0 | 314 | assignArray(fAmPms, fAmPmsCount, other.fAmPms, other.fAmPmsCount); |
michael@0 | 315 | assignArray(fQuarters, fQuartersCount, other.fQuarters, other.fQuartersCount); |
michael@0 | 316 | assignArray(fShortQuarters, fShortQuartersCount, other.fShortQuarters, other.fShortQuartersCount); |
michael@0 | 317 | assignArray(fStandaloneQuarters, fStandaloneQuartersCount, other.fStandaloneQuarters, other.fStandaloneQuartersCount); |
michael@0 | 318 | assignArray(fStandaloneShortQuarters, fStandaloneShortQuartersCount, other.fStandaloneShortQuarters, other.fStandaloneShortQuartersCount); |
michael@0 | 319 | if (other.fLeapMonthPatterns != NULL) { |
michael@0 | 320 | assignArray(fLeapMonthPatterns, fLeapMonthPatternsCount, other.fLeapMonthPatterns, other.fLeapMonthPatternsCount); |
michael@0 | 321 | } else { |
michael@0 | 322 | fLeapMonthPatterns = NULL; |
michael@0 | 323 | fLeapMonthPatternsCount = 0; |
michael@0 | 324 | } |
michael@0 | 325 | if (other.fShortYearNames != NULL) { |
michael@0 | 326 | assignArray(fShortYearNames, fShortYearNamesCount, other.fShortYearNames, other.fShortYearNamesCount); |
michael@0 | 327 | } else { |
michael@0 | 328 | fShortYearNames = NULL; |
michael@0 | 329 | fShortYearNamesCount = 0; |
michael@0 | 330 | } |
michael@0 | 331 | |
michael@0 | 332 | if (other.fZoneStrings != NULL) { |
michael@0 | 333 | fZoneStringsColCount = other.fZoneStringsColCount; |
michael@0 | 334 | fZoneStringsRowCount = other.fZoneStringsRowCount; |
michael@0 | 335 | createZoneStrings((const UnicodeString**)other.fZoneStrings); |
michael@0 | 336 | |
michael@0 | 337 | } else { |
michael@0 | 338 | fZoneStrings = NULL; |
michael@0 | 339 | fZoneStringsColCount = 0; |
michael@0 | 340 | fZoneStringsRowCount = 0; |
michael@0 | 341 | } |
michael@0 | 342 | fZSFLocale = other.fZSFLocale; |
michael@0 | 343 | // Other zone strings data is created on demand |
michael@0 | 344 | fLocaleZoneStrings = NULL; |
michael@0 | 345 | |
michael@0 | 346 | // fastCopyFrom() - see assignArray comments |
michael@0 | 347 | fLocalPatternChars.fastCopyFrom(other.fLocalPatternChars); |
michael@0 | 348 | |
michael@0 | 349 | uprv_memcpy(fCapitalization, other.fCapitalization, sizeof(fCapitalization)); |
michael@0 | 350 | } |
michael@0 | 351 | |
michael@0 | 352 | /** |
michael@0 | 353 | * Assignment operator. |
michael@0 | 354 | */ |
michael@0 | 355 | DateFormatSymbols& DateFormatSymbols::operator=(const DateFormatSymbols& other) |
michael@0 | 356 | { |
michael@0 | 357 | dispose(); |
michael@0 | 358 | copyData(other); |
michael@0 | 359 | |
michael@0 | 360 | return *this; |
michael@0 | 361 | } |
michael@0 | 362 | |
michael@0 | 363 | DateFormatSymbols::~DateFormatSymbols() |
michael@0 | 364 | { |
michael@0 | 365 | dispose(); |
michael@0 | 366 | } |
michael@0 | 367 | |
michael@0 | 368 | void DateFormatSymbols::dispose() |
michael@0 | 369 | { |
michael@0 | 370 | if (fEras) delete[] fEras; |
michael@0 | 371 | if (fEraNames) delete[] fEraNames; |
michael@0 | 372 | if (fNarrowEras) delete[] fNarrowEras; |
michael@0 | 373 | if (fMonths) delete[] fMonths; |
michael@0 | 374 | if (fShortMonths) delete[] fShortMonths; |
michael@0 | 375 | if (fNarrowMonths) delete[] fNarrowMonths; |
michael@0 | 376 | if (fStandaloneMonths) delete[] fStandaloneMonths; |
michael@0 | 377 | if (fStandaloneShortMonths) delete[] fStandaloneShortMonths; |
michael@0 | 378 | if (fStandaloneNarrowMonths) delete[] fStandaloneNarrowMonths; |
michael@0 | 379 | if (fWeekdays) delete[] fWeekdays; |
michael@0 | 380 | if (fShortWeekdays) delete[] fShortWeekdays; |
michael@0 | 381 | if (fShorterWeekdays) delete[] fShorterWeekdays; |
michael@0 | 382 | if (fNarrowWeekdays) delete[] fNarrowWeekdays; |
michael@0 | 383 | if (fStandaloneWeekdays) delete[] fStandaloneWeekdays; |
michael@0 | 384 | if (fStandaloneShortWeekdays) delete[] fStandaloneShortWeekdays; |
michael@0 | 385 | if (fStandaloneShorterWeekdays) delete[] fStandaloneShorterWeekdays; |
michael@0 | 386 | if (fStandaloneNarrowWeekdays) delete[] fStandaloneNarrowWeekdays; |
michael@0 | 387 | if (fAmPms) delete[] fAmPms; |
michael@0 | 388 | if (fQuarters) delete[] fQuarters; |
michael@0 | 389 | if (fShortQuarters) delete[] fShortQuarters; |
michael@0 | 390 | if (fStandaloneQuarters) delete[] fStandaloneQuarters; |
michael@0 | 391 | if (fStandaloneShortQuarters) delete[] fStandaloneShortQuarters; |
michael@0 | 392 | if (fLeapMonthPatterns) delete[] fLeapMonthPatterns; |
michael@0 | 393 | if (fShortYearNames) delete[] fShortYearNames; |
michael@0 | 394 | |
michael@0 | 395 | disposeZoneStrings(); |
michael@0 | 396 | } |
michael@0 | 397 | |
michael@0 | 398 | void DateFormatSymbols::disposeZoneStrings() |
michael@0 | 399 | { |
michael@0 | 400 | if (fZoneStrings) { |
michael@0 | 401 | for (int32_t row = 0; row < fZoneStringsRowCount; ++row) { |
michael@0 | 402 | delete[] fZoneStrings[row]; |
michael@0 | 403 | } |
michael@0 | 404 | uprv_free(fZoneStrings); |
michael@0 | 405 | } |
michael@0 | 406 | if (fLocaleZoneStrings) { |
michael@0 | 407 | for (int32_t row = 0; row < fZoneStringsRowCount; ++row) { |
michael@0 | 408 | delete[] fLocaleZoneStrings[row]; |
michael@0 | 409 | } |
michael@0 | 410 | uprv_free(fLocaleZoneStrings); |
michael@0 | 411 | } |
michael@0 | 412 | |
michael@0 | 413 | fZoneStrings = NULL; |
michael@0 | 414 | fLocaleZoneStrings = NULL; |
michael@0 | 415 | fZoneStringsRowCount = 0; |
michael@0 | 416 | fZoneStringsColCount = 0; |
michael@0 | 417 | } |
michael@0 | 418 | |
michael@0 | 419 | UBool |
michael@0 | 420 | DateFormatSymbols::arrayCompare(const UnicodeString* array1, |
michael@0 | 421 | const UnicodeString* array2, |
michael@0 | 422 | int32_t count) |
michael@0 | 423 | { |
michael@0 | 424 | if (array1 == array2) return TRUE; |
michael@0 | 425 | while (count>0) |
michael@0 | 426 | { |
michael@0 | 427 | --count; |
michael@0 | 428 | if (array1[count] != array2[count]) return FALSE; |
michael@0 | 429 | } |
michael@0 | 430 | return TRUE; |
michael@0 | 431 | } |
michael@0 | 432 | |
michael@0 | 433 | UBool |
michael@0 | 434 | DateFormatSymbols::operator==(const DateFormatSymbols& other) const |
michael@0 | 435 | { |
michael@0 | 436 | // First do cheap comparisons |
michael@0 | 437 | if (this == &other) { |
michael@0 | 438 | return TRUE; |
michael@0 | 439 | } |
michael@0 | 440 | if (fErasCount == other.fErasCount && |
michael@0 | 441 | fEraNamesCount == other.fEraNamesCount && |
michael@0 | 442 | fNarrowErasCount == other.fNarrowErasCount && |
michael@0 | 443 | fMonthsCount == other.fMonthsCount && |
michael@0 | 444 | fShortMonthsCount == other.fShortMonthsCount && |
michael@0 | 445 | fNarrowMonthsCount == other.fNarrowMonthsCount && |
michael@0 | 446 | fStandaloneMonthsCount == other.fStandaloneMonthsCount && |
michael@0 | 447 | fStandaloneShortMonthsCount == other.fStandaloneShortMonthsCount && |
michael@0 | 448 | fStandaloneNarrowMonthsCount == other.fStandaloneNarrowMonthsCount && |
michael@0 | 449 | fWeekdaysCount == other.fWeekdaysCount && |
michael@0 | 450 | fShortWeekdaysCount == other.fShortWeekdaysCount && |
michael@0 | 451 | fShorterWeekdaysCount == other.fShorterWeekdaysCount && |
michael@0 | 452 | fNarrowWeekdaysCount == other.fNarrowWeekdaysCount && |
michael@0 | 453 | fStandaloneWeekdaysCount == other.fStandaloneWeekdaysCount && |
michael@0 | 454 | fStandaloneShortWeekdaysCount == other.fStandaloneShortWeekdaysCount && |
michael@0 | 455 | fStandaloneShorterWeekdaysCount == other.fStandaloneShorterWeekdaysCount && |
michael@0 | 456 | fStandaloneNarrowWeekdaysCount == other.fStandaloneNarrowWeekdaysCount && |
michael@0 | 457 | fAmPmsCount == other.fAmPmsCount && |
michael@0 | 458 | fQuartersCount == other.fQuartersCount && |
michael@0 | 459 | fShortQuartersCount == other.fShortQuartersCount && |
michael@0 | 460 | fStandaloneQuartersCount == other.fStandaloneQuartersCount && |
michael@0 | 461 | fStandaloneShortQuartersCount == other.fStandaloneShortQuartersCount && |
michael@0 | 462 | fLeapMonthPatternsCount == other.fLeapMonthPatternsCount && |
michael@0 | 463 | fShortYearNamesCount == other.fShortYearNamesCount && |
michael@0 | 464 | (uprv_memcmp(fCapitalization, other.fCapitalization, sizeof(fCapitalization))==0)) |
michael@0 | 465 | { |
michael@0 | 466 | // Now compare the arrays themselves |
michael@0 | 467 | if (arrayCompare(fEras, other.fEras, fErasCount) && |
michael@0 | 468 | arrayCompare(fEraNames, other.fEraNames, fEraNamesCount) && |
michael@0 | 469 | arrayCompare(fNarrowEras, other.fNarrowEras, fNarrowErasCount) && |
michael@0 | 470 | arrayCompare(fMonths, other.fMonths, fMonthsCount) && |
michael@0 | 471 | arrayCompare(fShortMonths, other.fShortMonths, fShortMonthsCount) && |
michael@0 | 472 | arrayCompare(fNarrowMonths, other.fNarrowMonths, fNarrowMonthsCount) && |
michael@0 | 473 | arrayCompare(fStandaloneMonths, other.fStandaloneMonths, fStandaloneMonthsCount) && |
michael@0 | 474 | arrayCompare(fStandaloneShortMonths, other.fStandaloneShortMonths, fStandaloneShortMonthsCount) && |
michael@0 | 475 | arrayCompare(fStandaloneNarrowMonths, other.fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount) && |
michael@0 | 476 | arrayCompare(fWeekdays, other.fWeekdays, fWeekdaysCount) && |
michael@0 | 477 | arrayCompare(fShortWeekdays, other.fShortWeekdays, fShortWeekdaysCount) && |
michael@0 | 478 | arrayCompare(fShorterWeekdays, other.fShorterWeekdays, fShorterWeekdaysCount) && |
michael@0 | 479 | arrayCompare(fNarrowWeekdays, other.fNarrowWeekdays, fNarrowWeekdaysCount) && |
michael@0 | 480 | arrayCompare(fStandaloneWeekdays, other.fStandaloneWeekdays, fStandaloneWeekdaysCount) && |
michael@0 | 481 | arrayCompare(fStandaloneShortWeekdays, other.fStandaloneShortWeekdays, fStandaloneShortWeekdaysCount) && |
michael@0 | 482 | arrayCompare(fStandaloneShorterWeekdays, other.fStandaloneShorterWeekdays, fStandaloneShorterWeekdaysCount) && |
michael@0 | 483 | arrayCompare(fStandaloneNarrowWeekdays, other.fStandaloneNarrowWeekdays, fStandaloneNarrowWeekdaysCount) && |
michael@0 | 484 | arrayCompare(fAmPms, other.fAmPms, fAmPmsCount) && |
michael@0 | 485 | arrayCompare(fQuarters, other.fQuarters, fQuartersCount) && |
michael@0 | 486 | arrayCompare(fShortQuarters, other.fShortQuarters, fShortQuartersCount) && |
michael@0 | 487 | arrayCompare(fStandaloneQuarters, other.fStandaloneQuarters, fStandaloneQuartersCount) && |
michael@0 | 488 | arrayCompare(fStandaloneShortQuarters, other.fStandaloneShortQuarters, fStandaloneShortQuartersCount) && |
michael@0 | 489 | arrayCompare(fLeapMonthPatterns, other.fLeapMonthPatterns, fLeapMonthPatternsCount) && |
michael@0 | 490 | arrayCompare(fShortYearNames, other.fShortYearNames, fShortYearNamesCount)) |
michael@0 | 491 | { |
michael@0 | 492 | // Compare the contents of fZoneStrings |
michael@0 | 493 | if (fZoneStrings == NULL && other.fZoneStrings == NULL) { |
michael@0 | 494 | if (fZSFLocale == other.fZSFLocale) { |
michael@0 | 495 | return TRUE; |
michael@0 | 496 | } |
michael@0 | 497 | } else if (fZoneStrings != NULL && other.fZoneStrings != NULL) { |
michael@0 | 498 | if (fZoneStringsRowCount == other.fZoneStringsRowCount |
michael@0 | 499 | && fZoneStringsColCount == other.fZoneStringsColCount) { |
michael@0 | 500 | UBool cmpres = TRUE; |
michael@0 | 501 | for (int32_t i = 0; (i < fZoneStringsRowCount) && cmpres; i++) { |
michael@0 | 502 | cmpres = arrayCompare(fZoneStrings[i], other.fZoneStrings[i], fZoneStringsColCount); |
michael@0 | 503 | } |
michael@0 | 504 | return cmpres; |
michael@0 | 505 | } |
michael@0 | 506 | } |
michael@0 | 507 | return FALSE; |
michael@0 | 508 | } |
michael@0 | 509 | } |
michael@0 | 510 | return FALSE; |
michael@0 | 511 | } |
michael@0 | 512 | |
michael@0 | 513 | //------------------------------------------------------ |
michael@0 | 514 | |
michael@0 | 515 | const UnicodeString* |
michael@0 | 516 | DateFormatSymbols::getEras(int32_t &count) const |
michael@0 | 517 | { |
michael@0 | 518 | count = fErasCount; |
michael@0 | 519 | return fEras; |
michael@0 | 520 | } |
michael@0 | 521 | |
michael@0 | 522 | const UnicodeString* |
michael@0 | 523 | DateFormatSymbols::getEraNames(int32_t &count) const |
michael@0 | 524 | { |
michael@0 | 525 | count = fEraNamesCount; |
michael@0 | 526 | return fEraNames; |
michael@0 | 527 | } |
michael@0 | 528 | |
michael@0 | 529 | const UnicodeString* |
michael@0 | 530 | DateFormatSymbols::getNarrowEras(int32_t &count) const |
michael@0 | 531 | { |
michael@0 | 532 | count = fNarrowErasCount; |
michael@0 | 533 | return fNarrowEras; |
michael@0 | 534 | } |
michael@0 | 535 | |
michael@0 | 536 | const UnicodeString* |
michael@0 | 537 | DateFormatSymbols::getMonths(int32_t &count) const |
michael@0 | 538 | { |
michael@0 | 539 | count = fMonthsCount; |
michael@0 | 540 | return fMonths; |
michael@0 | 541 | } |
michael@0 | 542 | |
michael@0 | 543 | const UnicodeString* |
michael@0 | 544 | DateFormatSymbols::getShortMonths(int32_t &count) const |
michael@0 | 545 | { |
michael@0 | 546 | count = fShortMonthsCount; |
michael@0 | 547 | return fShortMonths; |
michael@0 | 548 | } |
michael@0 | 549 | |
michael@0 | 550 | const UnicodeString* |
michael@0 | 551 | DateFormatSymbols::getMonths(int32_t &count, DtContextType context, DtWidthType width ) const |
michael@0 | 552 | { |
michael@0 | 553 | UnicodeString *returnValue = NULL; |
michael@0 | 554 | |
michael@0 | 555 | switch (context) { |
michael@0 | 556 | case FORMAT : |
michael@0 | 557 | switch(width) { |
michael@0 | 558 | case WIDE : |
michael@0 | 559 | count = fMonthsCount; |
michael@0 | 560 | returnValue = fMonths; |
michael@0 | 561 | break; |
michael@0 | 562 | case ABBREVIATED : |
michael@0 | 563 | case SHORT : // no month data for this, defaults to ABBREVIATED |
michael@0 | 564 | count = fShortMonthsCount; |
michael@0 | 565 | returnValue = fShortMonths; |
michael@0 | 566 | break; |
michael@0 | 567 | case NARROW : |
michael@0 | 568 | count = fNarrowMonthsCount; |
michael@0 | 569 | returnValue = fNarrowMonths; |
michael@0 | 570 | break; |
michael@0 | 571 | case DT_WIDTH_COUNT : |
michael@0 | 572 | break; |
michael@0 | 573 | } |
michael@0 | 574 | break; |
michael@0 | 575 | case STANDALONE : |
michael@0 | 576 | switch(width) { |
michael@0 | 577 | case WIDE : |
michael@0 | 578 | count = fStandaloneMonthsCount; |
michael@0 | 579 | returnValue = fStandaloneMonths; |
michael@0 | 580 | break; |
michael@0 | 581 | case ABBREVIATED : |
michael@0 | 582 | case SHORT : // no month data for this, defaults to ABBREVIATED |
michael@0 | 583 | count = fStandaloneShortMonthsCount; |
michael@0 | 584 | returnValue = fStandaloneShortMonths; |
michael@0 | 585 | break; |
michael@0 | 586 | case NARROW : |
michael@0 | 587 | count = fStandaloneNarrowMonthsCount; |
michael@0 | 588 | returnValue = fStandaloneNarrowMonths; |
michael@0 | 589 | break; |
michael@0 | 590 | case DT_WIDTH_COUNT : |
michael@0 | 591 | break; |
michael@0 | 592 | } |
michael@0 | 593 | break; |
michael@0 | 594 | case DT_CONTEXT_COUNT : |
michael@0 | 595 | break; |
michael@0 | 596 | } |
michael@0 | 597 | return returnValue; |
michael@0 | 598 | } |
michael@0 | 599 | |
michael@0 | 600 | const UnicodeString* |
michael@0 | 601 | DateFormatSymbols::getWeekdays(int32_t &count) const |
michael@0 | 602 | { |
michael@0 | 603 | count = fWeekdaysCount; |
michael@0 | 604 | return fWeekdays; |
michael@0 | 605 | } |
michael@0 | 606 | |
michael@0 | 607 | const UnicodeString* |
michael@0 | 608 | DateFormatSymbols::getShortWeekdays(int32_t &count) const |
michael@0 | 609 | { |
michael@0 | 610 | count = fShortWeekdaysCount; |
michael@0 | 611 | return fShortWeekdays; |
michael@0 | 612 | } |
michael@0 | 613 | |
michael@0 | 614 | const UnicodeString* |
michael@0 | 615 | DateFormatSymbols::getWeekdays(int32_t &count, DtContextType context, DtWidthType width) const |
michael@0 | 616 | { |
michael@0 | 617 | UnicodeString *returnValue = NULL; |
michael@0 | 618 | switch (context) { |
michael@0 | 619 | case FORMAT : |
michael@0 | 620 | switch(width) { |
michael@0 | 621 | case WIDE : |
michael@0 | 622 | count = fWeekdaysCount; |
michael@0 | 623 | returnValue = fWeekdays; |
michael@0 | 624 | break; |
michael@0 | 625 | case ABBREVIATED : |
michael@0 | 626 | count = fShortWeekdaysCount; |
michael@0 | 627 | returnValue = fShortWeekdays; |
michael@0 | 628 | break; |
michael@0 | 629 | case SHORT : |
michael@0 | 630 | count = fShorterWeekdaysCount; |
michael@0 | 631 | returnValue = fShorterWeekdays; |
michael@0 | 632 | break; |
michael@0 | 633 | case NARROW : |
michael@0 | 634 | count = fNarrowWeekdaysCount; |
michael@0 | 635 | returnValue = fNarrowWeekdays; |
michael@0 | 636 | break; |
michael@0 | 637 | case DT_WIDTH_COUNT : |
michael@0 | 638 | break; |
michael@0 | 639 | } |
michael@0 | 640 | break; |
michael@0 | 641 | case STANDALONE : |
michael@0 | 642 | switch(width) { |
michael@0 | 643 | case WIDE : |
michael@0 | 644 | count = fStandaloneWeekdaysCount; |
michael@0 | 645 | returnValue = fStandaloneWeekdays; |
michael@0 | 646 | break; |
michael@0 | 647 | case ABBREVIATED : |
michael@0 | 648 | count = fStandaloneShortWeekdaysCount; |
michael@0 | 649 | returnValue = fStandaloneShortWeekdays; |
michael@0 | 650 | break; |
michael@0 | 651 | case SHORT : |
michael@0 | 652 | count = fStandaloneShorterWeekdaysCount; |
michael@0 | 653 | returnValue = fStandaloneShorterWeekdays; |
michael@0 | 654 | break; |
michael@0 | 655 | case NARROW : |
michael@0 | 656 | count = fStandaloneNarrowWeekdaysCount; |
michael@0 | 657 | returnValue = fStandaloneNarrowWeekdays; |
michael@0 | 658 | break; |
michael@0 | 659 | case DT_WIDTH_COUNT : |
michael@0 | 660 | break; |
michael@0 | 661 | } |
michael@0 | 662 | break; |
michael@0 | 663 | case DT_CONTEXT_COUNT : |
michael@0 | 664 | break; |
michael@0 | 665 | } |
michael@0 | 666 | return returnValue; |
michael@0 | 667 | } |
michael@0 | 668 | |
michael@0 | 669 | const UnicodeString* |
michael@0 | 670 | DateFormatSymbols::getQuarters(int32_t &count, DtContextType context, DtWidthType width ) const |
michael@0 | 671 | { |
michael@0 | 672 | UnicodeString *returnValue = NULL; |
michael@0 | 673 | |
michael@0 | 674 | switch (context) { |
michael@0 | 675 | case FORMAT : |
michael@0 | 676 | switch(width) { |
michael@0 | 677 | case WIDE : |
michael@0 | 678 | count = fQuartersCount; |
michael@0 | 679 | returnValue = fQuarters; |
michael@0 | 680 | break; |
michael@0 | 681 | case ABBREVIATED : |
michael@0 | 682 | case SHORT : // no quarter data for this, defaults to ABBREVIATED |
michael@0 | 683 | count = fShortQuartersCount; |
michael@0 | 684 | returnValue = fShortQuarters; |
michael@0 | 685 | break; |
michael@0 | 686 | case NARROW : |
michael@0 | 687 | count = 0; |
michael@0 | 688 | returnValue = NULL; |
michael@0 | 689 | break; |
michael@0 | 690 | case DT_WIDTH_COUNT : |
michael@0 | 691 | break; |
michael@0 | 692 | } |
michael@0 | 693 | break; |
michael@0 | 694 | case STANDALONE : |
michael@0 | 695 | switch(width) { |
michael@0 | 696 | case WIDE : |
michael@0 | 697 | count = fStandaloneQuartersCount; |
michael@0 | 698 | returnValue = fStandaloneQuarters; |
michael@0 | 699 | break; |
michael@0 | 700 | case ABBREVIATED : |
michael@0 | 701 | case SHORT : // no quarter data for this, defaults to ABBREVIATED |
michael@0 | 702 | count = fStandaloneShortQuartersCount; |
michael@0 | 703 | returnValue = fStandaloneShortQuarters; |
michael@0 | 704 | break; |
michael@0 | 705 | case NARROW : |
michael@0 | 706 | count = 0; |
michael@0 | 707 | returnValue = NULL; |
michael@0 | 708 | break; |
michael@0 | 709 | case DT_WIDTH_COUNT : |
michael@0 | 710 | break; |
michael@0 | 711 | } |
michael@0 | 712 | break; |
michael@0 | 713 | case DT_CONTEXT_COUNT : |
michael@0 | 714 | break; |
michael@0 | 715 | } |
michael@0 | 716 | return returnValue; |
michael@0 | 717 | } |
michael@0 | 718 | |
michael@0 | 719 | const UnicodeString* |
michael@0 | 720 | DateFormatSymbols::getAmPmStrings(int32_t &count) const |
michael@0 | 721 | { |
michael@0 | 722 | count = fAmPmsCount; |
michael@0 | 723 | return fAmPms; |
michael@0 | 724 | } |
michael@0 | 725 | |
michael@0 | 726 | const UnicodeString* |
michael@0 | 727 | DateFormatSymbols::getLeapMonthPatterns(int32_t &count) const |
michael@0 | 728 | { |
michael@0 | 729 | count = fLeapMonthPatternsCount; |
michael@0 | 730 | return fLeapMonthPatterns; |
michael@0 | 731 | } |
michael@0 | 732 | |
michael@0 | 733 | //------------------------------------------------------ |
michael@0 | 734 | |
michael@0 | 735 | void |
michael@0 | 736 | DateFormatSymbols::setEras(const UnicodeString* erasArray, int32_t count) |
michael@0 | 737 | { |
michael@0 | 738 | // delete the old list if we own it |
michael@0 | 739 | if (fEras) |
michael@0 | 740 | delete[] fEras; |
michael@0 | 741 | |
michael@0 | 742 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 743 | // than adopting the list passed in) |
michael@0 | 744 | fEras = newUnicodeStringArray(count); |
michael@0 | 745 | uprv_arrayCopy(erasArray,fEras, count); |
michael@0 | 746 | fErasCount = count; |
michael@0 | 747 | } |
michael@0 | 748 | |
michael@0 | 749 | void |
michael@0 | 750 | DateFormatSymbols::setEraNames(const UnicodeString* eraNamesArray, int32_t count) |
michael@0 | 751 | { |
michael@0 | 752 | // delete the old list if we own it |
michael@0 | 753 | if (fEraNames) |
michael@0 | 754 | delete[] fEraNames; |
michael@0 | 755 | |
michael@0 | 756 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 757 | // than adopting the list passed in) |
michael@0 | 758 | fEraNames = newUnicodeStringArray(count); |
michael@0 | 759 | uprv_arrayCopy(eraNamesArray,fEraNames, count); |
michael@0 | 760 | fEraNamesCount = count; |
michael@0 | 761 | } |
michael@0 | 762 | |
michael@0 | 763 | void |
michael@0 | 764 | DateFormatSymbols::setNarrowEras(const UnicodeString* narrowErasArray, int32_t count) |
michael@0 | 765 | { |
michael@0 | 766 | // delete the old list if we own it |
michael@0 | 767 | if (fNarrowEras) |
michael@0 | 768 | delete[] fNarrowEras; |
michael@0 | 769 | |
michael@0 | 770 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 771 | // than adopting the list passed in) |
michael@0 | 772 | fNarrowEras = newUnicodeStringArray(count); |
michael@0 | 773 | uprv_arrayCopy(narrowErasArray,fNarrowEras, count); |
michael@0 | 774 | fNarrowErasCount = count; |
michael@0 | 775 | } |
michael@0 | 776 | |
michael@0 | 777 | void |
michael@0 | 778 | DateFormatSymbols::setMonths(const UnicodeString* monthsArray, int32_t count) |
michael@0 | 779 | { |
michael@0 | 780 | // delete the old list if we own it |
michael@0 | 781 | if (fMonths) |
michael@0 | 782 | delete[] fMonths; |
michael@0 | 783 | |
michael@0 | 784 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 785 | // than adopting the list passed in) |
michael@0 | 786 | fMonths = newUnicodeStringArray(count); |
michael@0 | 787 | uprv_arrayCopy( monthsArray,fMonths,count); |
michael@0 | 788 | fMonthsCount = count; |
michael@0 | 789 | } |
michael@0 | 790 | |
michael@0 | 791 | void |
michael@0 | 792 | DateFormatSymbols::setShortMonths(const UnicodeString* shortMonthsArray, int32_t count) |
michael@0 | 793 | { |
michael@0 | 794 | // delete the old list if we own it |
michael@0 | 795 | if (fShortMonths) |
michael@0 | 796 | delete[] fShortMonths; |
michael@0 | 797 | |
michael@0 | 798 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 799 | // than adopting the list passed in) |
michael@0 | 800 | fShortMonths = newUnicodeStringArray(count); |
michael@0 | 801 | uprv_arrayCopy(shortMonthsArray,fShortMonths, count); |
michael@0 | 802 | fShortMonthsCount = count; |
michael@0 | 803 | } |
michael@0 | 804 | |
michael@0 | 805 | void |
michael@0 | 806 | DateFormatSymbols::setMonths(const UnicodeString* monthsArray, int32_t count, DtContextType context, DtWidthType width) |
michael@0 | 807 | { |
michael@0 | 808 | // delete the old list if we own it |
michael@0 | 809 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 810 | // than adopting the list passed in) |
michael@0 | 811 | |
michael@0 | 812 | switch (context) { |
michael@0 | 813 | case FORMAT : |
michael@0 | 814 | switch (width) { |
michael@0 | 815 | case WIDE : |
michael@0 | 816 | if (fMonths) |
michael@0 | 817 | delete[] fMonths; |
michael@0 | 818 | fMonths = newUnicodeStringArray(count); |
michael@0 | 819 | uprv_arrayCopy( monthsArray,fMonths,count); |
michael@0 | 820 | fMonthsCount = count; |
michael@0 | 821 | break; |
michael@0 | 822 | case ABBREVIATED : |
michael@0 | 823 | if (fShortMonths) |
michael@0 | 824 | delete[] fShortMonths; |
michael@0 | 825 | fShortMonths = newUnicodeStringArray(count); |
michael@0 | 826 | uprv_arrayCopy( monthsArray,fShortMonths,count); |
michael@0 | 827 | fShortMonthsCount = count; |
michael@0 | 828 | break; |
michael@0 | 829 | case NARROW : |
michael@0 | 830 | if (fNarrowMonths) |
michael@0 | 831 | delete[] fNarrowMonths; |
michael@0 | 832 | fNarrowMonths = newUnicodeStringArray(count); |
michael@0 | 833 | uprv_arrayCopy( monthsArray,fNarrowMonths,count); |
michael@0 | 834 | fNarrowMonthsCount = count; |
michael@0 | 835 | break; |
michael@0 | 836 | default : |
michael@0 | 837 | break; |
michael@0 | 838 | } |
michael@0 | 839 | break; |
michael@0 | 840 | case STANDALONE : |
michael@0 | 841 | switch (width) { |
michael@0 | 842 | case WIDE : |
michael@0 | 843 | if (fStandaloneMonths) |
michael@0 | 844 | delete[] fStandaloneMonths; |
michael@0 | 845 | fStandaloneMonths = newUnicodeStringArray(count); |
michael@0 | 846 | uprv_arrayCopy( monthsArray,fStandaloneMonths,count); |
michael@0 | 847 | fStandaloneMonthsCount = count; |
michael@0 | 848 | break; |
michael@0 | 849 | case ABBREVIATED : |
michael@0 | 850 | if (fStandaloneShortMonths) |
michael@0 | 851 | delete[] fStandaloneShortMonths; |
michael@0 | 852 | fStandaloneShortMonths = newUnicodeStringArray(count); |
michael@0 | 853 | uprv_arrayCopy( monthsArray,fStandaloneShortMonths,count); |
michael@0 | 854 | fStandaloneShortMonthsCount = count; |
michael@0 | 855 | break; |
michael@0 | 856 | case NARROW : |
michael@0 | 857 | if (fStandaloneNarrowMonths) |
michael@0 | 858 | delete[] fStandaloneNarrowMonths; |
michael@0 | 859 | fStandaloneNarrowMonths = newUnicodeStringArray(count); |
michael@0 | 860 | uprv_arrayCopy( monthsArray,fStandaloneNarrowMonths,count); |
michael@0 | 861 | fStandaloneNarrowMonthsCount = count; |
michael@0 | 862 | break; |
michael@0 | 863 | default : |
michael@0 | 864 | break; |
michael@0 | 865 | } |
michael@0 | 866 | break; |
michael@0 | 867 | case DT_CONTEXT_COUNT : |
michael@0 | 868 | break; |
michael@0 | 869 | } |
michael@0 | 870 | } |
michael@0 | 871 | |
michael@0 | 872 | void DateFormatSymbols::setWeekdays(const UnicodeString* weekdaysArray, int32_t count) |
michael@0 | 873 | { |
michael@0 | 874 | // delete the old list if we own it |
michael@0 | 875 | if (fWeekdays) |
michael@0 | 876 | delete[] fWeekdays; |
michael@0 | 877 | |
michael@0 | 878 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 879 | // than adopting the list passed in) |
michael@0 | 880 | fWeekdays = newUnicodeStringArray(count); |
michael@0 | 881 | uprv_arrayCopy(weekdaysArray,fWeekdays,count); |
michael@0 | 882 | fWeekdaysCount = count; |
michael@0 | 883 | } |
michael@0 | 884 | |
michael@0 | 885 | void |
michael@0 | 886 | DateFormatSymbols::setShortWeekdays(const UnicodeString* shortWeekdaysArray, int32_t count) |
michael@0 | 887 | { |
michael@0 | 888 | // delete the old list if we own it |
michael@0 | 889 | if (fShortWeekdays) |
michael@0 | 890 | delete[] fShortWeekdays; |
michael@0 | 891 | |
michael@0 | 892 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 893 | // than adopting the list passed in) |
michael@0 | 894 | fShortWeekdays = newUnicodeStringArray(count); |
michael@0 | 895 | uprv_arrayCopy(shortWeekdaysArray, fShortWeekdays, count); |
michael@0 | 896 | fShortWeekdaysCount = count; |
michael@0 | 897 | } |
michael@0 | 898 | |
michael@0 | 899 | void |
michael@0 | 900 | DateFormatSymbols::setWeekdays(const UnicodeString* weekdaysArray, int32_t count, DtContextType context, DtWidthType width) |
michael@0 | 901 | { |
michael@0 | 902 | // delete the old list if we own it |
michael@0 | 903 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 904 | // than adopting the list passed in) |
michael@0 | 905 | |
michael@0 | 906 | switch (context) { |
michael@0 | 907 | case FORMAT : |
michael@0 | 908 | switch (width) { |
michael@0 | 909 | case WIDE : |
michael@0 | 910 | if (fWeekdays) |
michael@0 | 911 | delete[] fWeekdays; |
michael@0 | 912 | fWeekdays = newUnicodeStringArray(count); |
michael@0 | 913 | uprv_arrayCopy(weekdaysArray, fWeekdays, count); |
michael@0 | 914 | fWeekdaysCount = count; |
michael@0 | 915 | break; |
michael@0 | 916 | case ABBREVIATED : |
michael@0 | 917 | if (fShortWeekdays) |
michael@0 | 918 | delete[] fShortWeekdays; |
michael@0 | 919 | fShortWeekdays = newUnicodeStringArray(count); |
michael@0 | 920 | uprv_arrayCopy(weekdaysArray, fShortWeekdays, count); |
michael@0 | 921 | fShortWeekdaysCount = count; |
michael@0 | 922 | break; |
michael@0 | 923 | case SHORT : |
michael@0 | 924 | if (fShorterWeekdays) |
michael@0 | 925 | delete[] fShorterWeekdays; |
michael@0 | 926 | fShorterWeekdays = newUnicodeStringArray(count); |
michael@0 | 927 | uprv_arrayCopy(weekdaysArray, fShorterWeekdays, count); |
michael@0 | 928 | fShorterWeekdaysCount = count; |
michael@0 | 929 | break; |
michael@0 | 930 | case NARROW : |
michael@0 | 931 | if (fNarrowWeekdays) |
michael@0 | 932 | delete[] fNarrowWeekdays; |
michael@0 | 933 | fNarrowWeekdays = newUnicodeStringArray(count); |
michael@0 | 934 | uprv_arrayCopy(weekdaysArray, fNarrowWeekdays, count); |
michael@0 | 935 | fNarrowWeekdaysCount = count; |
michael@0 | 936 | break; |
michael@0 | 937 | case DT_WIDTH_COUNT : |
michael@0 | 938 | break; |
michael@0 | 939 | } |
michael@0 | 940 | break; |
michael@0 | 941 | case STANDALONE : |
michael@0 | 942 | switch (width) { |
michael@0 | 943 | case WIDE : |
michael@0 | 944 | if (fStandaloneWeekdays) |
michael@0 | 945 | delete[] fStandaloneWeekdays; |
michael@0 | 946 | fStandaloneWeekdays = newUnicodeStringArray(count); |
michael@0 | 947 | uprv_arrayCopy(weekdaysArray, fStandaloneWeekdays, count); |
michael@0 | 948 | fStandaloneWeekdaysCount = count; |
michael@0 | 949 | break; |
michael@0 | 950 | case ABBREVIATED : |
michael@0 | 951 | if (fStandaloneShortWeekdays) |
michael@0 | 952 | delete[] fStandaloneShortWeekdays; |
michael@0 | 953 | fStandaloneShortWeekdays = newUnicodeStringArray(count); |
michael@0 | 954 | uprv_arrayCopy(weekdaysArray, fStandaloneShortWeekdays, count); |
michael@0 | 955 | fStandaloneShortWeekdaysCount = count; |
michael@0 | 956 | break; |
michael@0 | 957 | case SHORT : |
michael@0 | 958 | if (fStandaloneShorterWeekdays) |
michael@0 | 959 | delete[] fStandaloneShorterWeekdays; |
michael@0 | 960 | fStandaloneShorterWeekdays = newUnicodeStringArray(count); |
michael@0 | 961 | uprv_arrayCopy(weekdaysArray, fStandaloneShorterWeekdays, count); |
michael@0 | 962 | fStandaloneShorterWeekdaysCount = count; |
michael@0 | 963 | break; |
michael@0 | 964 | case NARROW : |
michael@0 | 965 | if (fStandaloneNarrowWeekdays) |
michael@0 | 966 | delete[] fStandaloneNarrowWeekdays; |
michael@0 | 967 | fStandaloneNarrowWeekdays = newUnicodeStringArray(count); |
michael@0 | 968 | uprv_arrayCopy(weekdaysArray, fStandaloneNarrowWeekdays, count); |
michael@0 | 969 | fStandaloneNarrowWeekdaysCount = count; |
michael@0 | 970 | break; |
michael@0 | 971 | case DT_WIDTH_COUNT : |
michael@0 | 972 | break; |
michael@0 | 973 | } |
michael@0 | 974 | break; |
michael@0 | 975 | case DT_CONTEXT_COUNT : |
michael@0 | 976 | break; |
michael@0 | 977 | } |
michael@0 | 978 | } |
michael@0 | 979 | |
michael@0 | 980 | void |
michael@0 | 981 | DateFormatSymbols::setQuarters(const UnicodeString* quartersArray, int32_t count, DtContextType context, DtWidthType width) |
michael@0 | 982 | { |
michael@0 | 983 | // delete the old list if we own it |
michael@0 | 984 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 985 | // than adopting the list passed in) |
michael@0 | 986 | |
michael@0 | 987 | switch (context) { |
michael@0 | 988 | case FORMAT : |
michael@0 | 989 | switch (width) { |
michael@0 | 990 | case WIDE : |
michael@0 | 991 | if (fQuarters) |
michael@0 | 992 | delete[] fQuarters; |
michael@0 | 993 | fQuarters = newUnicodeStringArray(count); |
michael@0 | 994 | uprv_arrayCopy( quartersArray,fQuarters,count); |
michael@0 | 995 | fQuartersCount = count; |
michael@0 | 996 | break; |
michael@0 | 997 | case ABBREVIATED : |
michael@0 | 998 | if (fShortQuarters) |
michael@0 | 999 | delete[] fShortQuarters; |
michael@0 | 1000 | fShortQuarters = newUnicodeStringArray(count); |
michael@0 | 1001 | uprv_arrayCopy( quartersArray,fShortQuarters,count); |
michael@0 | 1002 | fShortQuartersCount = count; |
michael@0 | 1003 | break; |
michael@0 | 1004 | case NARROW : |
michael@0 | 1005 | /* |
michael@0 | 1006 | if (fNarrowQuarters) |
michael@0 | 1007 | delete[] fNarrowQuarters; |
michael@0 | 1008 | fNarrowQuarters = newUnicodeStringArray(count); |
michael@0 | 1009 | uprv_arrayCopy( quartersArray,fNarrowQuarters,count); |
michael@0 | 1010 | fNarrowQuartersCount = count; |
michael@0 | 1011 | */ |
michael@0 | 1012 | break; |
michael@0 | 1013 | default : |
michael@0 | 1014 | break; |
michael@0 | 1015 | } |
michael@0 | 1016 | break; |
michael@0 | 1017 | case STANDALONE : |
michael@0 | 1018 | switch (width) { |
michael@0 | 1019 | case WIDE : |
michael@0 | 1020 | if (fStandaloneQuarters) |
michael@0 | 1021 | delete[] fStandaloneQuarters; |
michael@0 | 1022 | fStandaloneQuarters = newUnicodeStringArray(count); |
michael@0 | 1023 | uprv_arrayCopy( quartersArray,fStandaloneQuarters,count); |
michael@0 | 1024 | fStandaloneQuartersCount = count; |
michael@0 | 1025 | break; |
michael@0 | 1026 | case ABBREVIATED : |
michael@0 | 1027 | if (fStandaloneShortQuarters) |
michael@0 | 1028 | delete[] fStandaloneShortQuarters; |
michael@0 | 1029 | fStandaloneShortQuarters = newUnicodeStringArray(count); |
michael@0 | 1030 | uprv_arrayCopy( quartersArray,fStandaloneShortQuarters,count); |
michael@0 | 1031 | fStandaloneShortQuartersCount = count; |
michael@0 | 1032 | break; |
michael@0 | 1033 | case NARROW : |
michael@0 | 1034 | /* |
michael@0 | 1035 | if (fStandaloneNarrowQuarters) |
michael@0 | 1036 | delete[] fStandaloneNarrowQuarters; |
michael@0 | 1037 | fStandaloneNarrowQuarters = newUnicodeStringArray(count); |
michael@0 | 1038 | uprv_arrayCopy( quartersArray,fStandaloneNarrowQuarters,count); |
michael@0 | 1039 | fStandaloneNarrowQuartersCount = count; |
michael@0 | 1040 | */ |
michael@0 | 1041 | break; |
michael@0 | 1042 | default : |
michael@0 | 1043 | break; |
michael@0 | 1044 | } |
michael@0 | 1045 | break; |
michael@0 | 1046 | case DT_CONTEXT_COUNT : |
michael@0 | 1047 | break; |
michael@0 | 1048 | } |
michael@0 | 1049 | } |
michael@0 | 1050 | |
michael@0 | 1051 | void |
michael@0 | 1052 | DateFormatSymbols::setAmPmStrings(const UnicodeString* amPmsArray, int32_t count) |
michael@0 | 1053 | { |
michael@0 | 1054 | // delete the old list if we own it |
michael@0 | 1055 | if (fAmPms) delete[] fAmPms; |
michael@0 | 1056 | |
michael@0 | 1057 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 1058 | // than adopting the list passed in) |
michael@0 | 1059 | fAmPms = newUnicodeStringArray(count); |
michael@0 | 1060 | uprv_arrayCopy(amPmsArray,fAmPms,count); |
michael@0 | 1061 | fAmPmsCount = count; |
michael@0 | 1062 | } |
michael@0 | 1063 | |
michael@0 | 1064 | const UnicodeString** |
michael@0 | 1065 | DateFormatSymbols::getZoneStrings(int32_t& rowCount, int32_t& columnCount) const |
michael@0 | 1066 | { |
michael@0 | 1067 | const UnicodeString **result = NULL; |
michael@0 | 1068 | |
michael@0 | 1069 | umtx_lock(&LOCK); |
michael@0 | 1070 | if (fZoneStrings == NULL) { |
michael@0 | 1071 | if (fLocaleZoneStrings == NULL) { |
michael@0 | 1072 | ((DateFormatSymbols*)this)->initZoneStringsArray(); |
michael@0 | 1073 | } |
michael@0 | 1074 | result = (const UnicodeString**)fLocaleZoneStrings; |
michael@0 | 1075 | } else { |
michael@0 | 1076 | result = (const UnicodeString**)fZoneStrings; |
michael@0 | 1077 | } |
michael@0 | 1078 | rowCount = fZoneStringsRowCount; |
michael@0 | 1079 | columnCount = fZoneStringsColCount; |
michael@0 | 1080 | umtx_unlock(&LOCK); |
michael@0 | 1081 | |
michael@0 | 1082 | return result; |
michael@0 | 1083 | } |
michael@0 | 1084 | |
michael@0 | 1085 | // For now, we include all zones |
michael@0 | 1086 | #define ZONE_SET UCAL_ZONE_TYPE_ANY |
michael@0 | 1087 | |
michael@0 | 1088 | // This code must be called within a synchronized block |
michael@0 | 1089 | void |
michael@0 | 1090 | DateFormatSymbols::initZoneStringsArray(void) { |
michael@0 | 1091 | if (fZoneStrings != NULL || fLocaleZoneStrings != NULL) { |
michael@0 | 1092 | return; |
michael@0 | 1093 | } |
michael@0 | 1094 | |
michael@0 | 1095 | UErrorCode status = U_ZERO_ERROR; |
michael@0 | 1096 | |
michael@0 | 1097 | StringEnumeration *tzids = NULL; |
michael@0 | 1098 | UnicodeString ** zarray = NULL; |
michael@0 | 1099 | TimeZoneNames *tzNames = NULL; |
michael@0 | 1100 | int32_t rows = 0; |
michael@0 | 1101 | |
michael@0 | 1102 | do { // dummy do-while |
michael@0 | 1103 | |
michael@0 | 1104 | tzids = TimeZone::createTimeZoneIDEnumeration(ZONE_SET, NULL, NULL, status); |
michael@0 | 1105 | rows = tzids->count(status); |
michael@0 | 1106 | if (U_FAILURE(status)) { |
michael@0 | 1107 | break; |
michael@0 | 1108 | } |
michael@0 | 1109 | |
michael@0 | 1110 | // Allocate array |
michael@0 | 1111 | int32_t size = rows * sizeof(UnicodeString*); |
michael@0 | 1112 | zarray = (UnicodeString**)uprv_malloc(size); |
michael@0 | 1113 | if (zarray == NULL) { |
michael@0 | 1114 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1115 | break; |
michael@0 | 1116 | } |
michael@0 | 1117 | uprv_memset(zarray, 0, size); |
michael@0 | 1118 | |
michael@0 | 1119 | tzNames = TimeZoneNames::createInstance(fZSFLocale, status); |
michael@0 | 1120 | |
michael@0 | 1121 | const UnicodeString *tzid; |
michael@0 | 1122 | int32_t i = 0; |
michael@0 | 1123 | UDate now = Calendar::getNow(); |
michael@0 | 1124 | UnicodeString tzDispName; |
michael@0 | 1125 | |
michael@0 | 1126 | while ((tzid = tzids->snext(status))) { |
michael@0 | 1127 | if (U_FAILURE(status)) { |
michael@0 | 1128 | break; |
michael@0 | 1129 | } |
michael@0 | 1130 | |
michael@0 | 1131 | zarray[i] = new UnicodeString[5]; |
michael@0 | 1132 | if (zarray[i] == NULL) { |
michael@0 | 1133 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1134 | break; |
michael@0 | 1135 | } |
michael@0 | 1136 | |
michael@0 | 1137 | zarray[i][0].setTo(*tzid); |
michael@0 | 1138 | zarray[i][1].setTo(tzNames->getDisplayName(*tzid, UTZNM_LONG_STANDARD, now, tzDispName)); |
michael@0 | 1139 | zarray[i][2].setTo(tzNames->getDisplayName(*tzid, UTZNM_SHORT_STANDARD, now, tzDispName)); |
michael@0 | 1140 | zarray[i][3].setTo(tzNames->getDisplayName(*tzid, UTZNM_LONG_DAYLIGHT, now, tzDispName)); |
michael@0 | 1141 | zarray[i][4].setTo(tzNames->getDisplayName(*tzid, UTZNM_SHORT_DAYLIGHT, now, tzDispName)); |
michael@0 | 1142 | i++; |
michael@0 | 1143 | } |
michael@0 | 1144 | |
michael@0 | 1145 | } while (FALSE); |
michael@0 | 1146 | |
michael@0 | 1147 | if (U_FAILURE(status)) { |
michael@0 | 1148 | if (zarray) { |
michael@0 | 1149 | for (int32_t i = 0; i < rows; i++) { |
michael@0 | 1150 | if (zarray[i]) { |
michael@0 | 1151 | delete[] zarray[i]; |
michael@0 | 1152 | } |
michael@0 | 1153 | } |
michael@0 | 1154 | uprv_free(zarray); |
michael@0 | 1155 | } |
michael@0 | 1156 | } |
michael@0 | 1157 | |
michael@0 | 1158 | if (tzNames) { |
michael@0 | 1159 | delete tzNames; |
michael@0 | 1160 | } |
michael@0 | 1161 | if (tzids) { |
michael@0 | 1162 | delete tzids; |
michael@0 | 1163 | } |
michael@0 | 1164 | |
michael@0 | 1165 | fLocaleZoneStrings = zarray; |
michael@0 | 1166 | fZoneStringsRowCount = rows; |
michael@0 | 1167 | fZoneStringsColCount = 5; |
michael@0 | 1168 | } |
michael@0 | 1169 | |
michael@0 | 1170 | void |
michael@0 | 1171 | DateFormatSymbols::setZoneStrings(const UnicodeString* const *strings, int32_t rowCount, int32_t columnCount) |
michael@0 | 1172 | { |
michael@0 | 1173 | // since deleting a 2-d array is a pain in the butt, we offload that task to |
michael@0 | 1174 | // a separate function |
michael@0 | 1175 | disposeZoneStrings(); |
michael@0 | 1176 | // we always own the new list, which we create here (we duplicate rather |
michael@0 | 1177 | // than adopting the list passed in) |
michael@0 | 1178 | fZoneStringsRowCount = rowCount; |
michael@0 | 1179 | fZoneStringsColCount = columnCount; |
michael@0 | 1180 | createZoneStrings((const UnicodeString**)strings); |
michael@0 | 1181 | } |
michael@0 | 1182 | |
michael@0 | 1183 | //------------------------------------------------------ |
michael@0 | 1184 | |
michael@0 | 1185 | const UChar * U_EXPORT2 |
michael@0 | 1186 | DateFormatSymbols::getPatternUChars(void) |
michael@0 | 1187 | { |
michael@0 | 1188 | return gPatternChars; |
michael@0 | 1189 | } |
michael@0 | 1190 | |
michael@0 | 1191 | UDateFormatField U_EXPORT2 |
michael@0 | 1192 | DateFormatSymbols::getPatternCharIndex(UChar c) { |
michael@0 | 1193 | const UChar *p = u_strchr(gPatternChars, c); |
michael@0 | 1194 | if (p == NULL) { |
michael@0 | 1195 | return UDAT_FIELD_COUNT; |
michael@0 | 1196 | } else { |
michael@0 | 1197 | return static_cast<UDateFormatField>(p - gPatternChars); |
michael@0 | 1198 | } |
michael@0 | 1199 | } |
michael@0 | 1200 | |
michael@0 | 1201 | static const uint32_t kNumericFields = |
michael@0 | 1202 | ((uint32_t)1 << UDAT_YEAR_FIELD) | // y |
michael@0 | 1203 | ((uint32_t)1 << UDAT_MONTH_FIELD) | // M or MM |
michael@0 | 1204 | ((uint32_t)1 << UDAT_DATE_FIELD) | // d |
michael@0 | 1205 | ((uint32_t)1 << UDAT_HOUR_OF_DAY1_FIELD) | // k |
michael@0 | 1206 | ((uint32_t)1 << UDAT_HOUR_OF_DAY0_FIELD) | // H |
michael@0 | 1207 | ((uint32_t)1 << UDAT_MINUTE_FIELD) | // m |
michael@0 | 1208 | ((uint32_t)1 << UDAT_SECOND_FIELD) | // s |
michael@0 | 1209 | ((uint32_t)1 << UDAT_FRACTIONAL_SECOND_FIELD) | // S |
michael@0 | 1210 | ((uint32_t)1 << UDAT_DAY_OF_YEAR_FIELD) | // D |
michael@0 | 1211 | ((uint32_t)1 << UDAT_DAY_OF_WEEK_IN_MONTH_FIELD) | // F |
michael@0 | 1212 | ((uint32_t)1 << UDAT_WEEK_OF_YEAR_FIELD) | // w |
michael@0 | 1213 | ((uint32_t)1 << UDAT_WEEK_OF_MONTH_FIELD) | // W |
michael@0 | 1214 | ((uint32_t)1 << UDAT_HOUR1_FIELD) | // h |
michael@0 | 1215 | ((uint32_t)1 << UDAT_HOUR0_FIELD) | // K |
michael@0 | 1216 | ((uint32_t)1 << UDAT_YEAR_WOY_FIELD) | // Y |
michael@0 | 1217 | ((uint32_t)1 << UDAT_DOW_LOCAL_FIELD) | // e |
michael@0 | 1218 | ((uint32_t)1 << UDAT_EXTENDED_YEAR_FIELD); // u |
michael@0 | 1219 | |
michael@0 | 1220 | UBool U_EXPORT2 |
michael@0 | 1221 | DateFormatSymbols::isNumericField(UDateFormatField f, int32_t count) { |
michael@0 | 1222 | return |
michael@0 | 1223 | f != UDAT_FIELD_COUNT && |
michael@0 | 1224 | (kNumericFields & ((uint32_t)1 << f)) != 0 && |
michael@0 | 1225 | (f != UDAT_MONTH_FIELD || count < 3); |
michael@0 | 1226 | } |
michael@0 | 1227 | |
michael@0 | 1228 | UBool U_EXPORT2 |
michael@0 | 1229 | DateFormatSymbols::isNumericPatternChar(UChar c, int32_t count) { |
michael@0 | 1230 | return isNumericField(getPatternCharIndex(c), count); |
michael@0 | 1231 | } |
michael@0 | 1232 | |
michael@0 | 1233 | //------------------------------------------------------ |
michael@0 | 1234 | |
michael@0 | 1235 | UnicodeString& |
michael@0 | 1236 | DateFormatSymbols::getLocalPatternChars(UnicodeString& result) const |
michael@0 | 1237 | { |
michael@0 | 1238 | // fastCopyFrom() - see assignArray comments |
michael@0 | 1239 | return result.fastCopyFrom(fLocalPatternChars); |
michael@0 | 1240 | } |
michael@0 | 1241 | |
michael@0 | 1242 | //------------------------------------------------------ |
michael@0 | 1243 | |
michael@0 | 1244 | void |
michael@0 | 1245 | DateFormatSymbols::setLocalPatternChars(const UnicodeString& newLocalPatternChars) |
michael@0 | 1246 | { |
michael@0 | 1247 | fLocalPatternChars = newLocalPatternChars; |
michael@0 | 1248 | } |
michael@0 | 1249 | |
michael@0 | 1250 | //------------------------------------------------------ |
michael@0 | 1251 | |
michael@0 | 1252 | static void |
michael@0 | 1253 | initField(UnicodeString **field, int32_t& length, const UResourceBundle *data, UErrorCode &status) { |
michael@0 | 1254 | if (U_SUCCESS(status)) { |
michael@0 | 1255 | int32_t strLen = 0; |
michael@0 | 1256 | length = ures_getSize(data); |
michael@0 | 1257 | *field = newUnicodeStringArray(length); |
michael@0 | 1258 | if (*field) { |
michael@0 | 1259 | for(int32_t i = 0; i<length; i++) { |
michael@0 | 1260 | const UChar *resStr = ures_getStringByIndex(data, i, &strLen, &status); |
michael@0 | 1261 | // setTo() - see assignArray comments |
michael@0 | 1262 | (*(field)+i)->setTo(TRUE, resStr, strLen); |
michael@0 | 1263 | } |
michael@0 | 1264 | } |
michael@0 | 1265 | else { |
michael@0 | 1266 | length = 0; |
michael@0 | 1267 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1268 | } |
michael@0 | 1269 | } |
michael@0 | 1270 | } |
michael@0 | 1271 | |
michael@0 | 1272 | static void |
michael@0 | 1273 | initField(UnicodeString **field, int32_t& length, const UChar *data, LastResortSize numStr, LastResortSize strLen, UErrorCode &status) { |
michael@0 | 1274 | if (U_SUCCESS(status)) { |
michael@0 | 1275 | length = numStr; |
michael@0 | 1276 | *field = newUnicodeStringArray((size_t)numStr); |
michael@0 | 1277 | if (*field) { |
michael@0 | 1278 | for(int32_t i = 0; i<length; i++) { |
michael@0 | 1279 | // readonly aliases - all "data" strings are constant |
michael@0 | 1280 | // -1 as length for variable-length strings (gLastResortDayNames[0] is empty) |
michael@0 | 1281 | (*(field)+i)->setTo(TRUE, data+(i*((int32_t)strLen)), -1); |
michael@0 | 1282 | } |
michael@0 | 1283 | } |
michael@0 | 1284 | else { |
michael@0 | 1285 | length = 0; |
michael@0 | 1286 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1287 | } |
michael@0 | 1288 | } |
michael@0 | 1289 | } |
michael@0 | 1290 | |
michael@0 | 1291 | static void |
michael@0 | 1292 | initLeapMonthPattern(UnicodeString *field, int32_t index, const UResourceBundle *data, UErrorCode &status) { |
michael@0 | 1293 | field[index].remove(); |
michael@0 | 1294 | if (U_SUCCESS(status)) { |
michael@0 | 1295 | int32_t strLen = 0; |
michael@0 | 1296 | const UChar *resStr = ures_getStringByKey(data, gNamesLeapTag, &strLen, &status); |
michael@0 | 1297 | if (U_SUCCESS(status)) { |
michael@0 | 1298 | field[index].setTo(TRUE, resStr, strLen); |
michael@0 | 1299 | } |
michael@0 | 1300 | } |
michael@0 | 1301 | status = U_ZERO_ERROR; |
michael@0 | 1302 | } |
michael@0 | 1303 | |
michael@0 | 1304 | typedef struct { |
michael@0 | 1305 | const char * usageTypeName; |
michael@0 | 1306 | DateFormatSymbols::ECapitalizationContextUsageType usageTypeEnumValue; |
michael@0 | 1307 | } ContextUsageTypeNameToEnumValue; |
michael@0 | 1308 | |
michael@0 | 1309 | static const ContextUsageTypeNameToEnumValue contextUsageTypeMap[] = { |
michael@0 | 1310 | // Entries must be sorted by usageTypeName; entry with NULL name terminates list. |
michael@0 | 1311 | { "day-format-except-narrow", DateFormatSymbols::kCapContextUsageDayFormat }, |
michael@0 | 1312 | { "day-narrow", DateFormatSymbols::kCapContextUsageDayNarrow }, |
michael@0 | 1313 | { "day-standalone-except-narrow", DateFormatSymbols::kCapContextUsageDayStandalone }, |
michael@0 | 1314 | { "era-abbr", DateFormatSymbols::kCapContextUsageEraAbbrev }, |
michael@0 | 1315 | { "era-name", DateFormatSymbols::kCapContextUsageEraWide }, |
michael@0 | 1316 | { "era-narrow", DateFormatSymbols::kCapContextUsageEraNarrow }, |
michael@0 | 1317 | { "metazone-long", DateFormatSymbols::kCapContextUsageMetazoneLong }, |
michael@0 | 1318 | { "metazone-short", DateFormatSymbols::kCapContextUsageMetazoneShort }, |
michael@0 | 1319 | { "month-format-except-narrow", DateFormatSymbols::kCapContextUsageMonthFormat }, |
michael@0 | 1320 | { "month-narrow", DateFormatSymbols::kCapContextUsageMonthNarrow }, |
michael@0 | 1321 | { "month-standalone-except-narrow", DateFormatSymbols::kCapContextUsageMonthStandalone }, |
michael@0 | 1322 | { "zone-long", DateFormatSymbols::kCapContextUsageZoneLong }, |
michael@0 | 1323 | { "zone-short", DateFormatSymbols::kCapContextUsageZoneShort }, |
michael@0 | 1324 | { NULL, (DateFormatSymbols::ECapitalizationContextUsageType)0 }, |
michael@0 | 1325 | }; |
michael@0 | 1326 | |
michael@0 | 1327 | void |
michael@0 | 1328 | DateFormatSymbols::initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData) |
michael@0 | 1329 | { |
michael@0 | 1330 | int32_t i; |
michael@0 | 1331 | int32_t len = 0; |
michael@0 | 1332 | const UChar *resStr; |
michael@0 | 1333 | /* In case something goes wrong, initialize all of the data to NULL. */ |
michael@0 | 1334 | fEras = NULL; |
michael@0 | 1335 | fErasCount = 0; |
michael@0 | 1336 | fEraNames = NULL; |
michael@0 | 1337 | fEraNamesCount = 0; |
michael@0 | 1338 | fNarrowEras = NULL; |
michael@0 | 1339 | fNarrowErasCount = 0; |
michael@0 | 1340 | fMonths = NULL; |
michael@0 | 1341 | fMonthsCount=0; |
michael@0 | 1342 | fShortMonths = NULL; |
michael@0 | 1343 | fShortMonthsCount=0; |
michael@0 | 1344 | fNarrowMonths = NULL; |
michael@0 | 1345 | fNarrowMonthsCount=0; |
michael@0 | 1346 | fStandaloneMonths = NULL; |
michael@0 | 1347 | fStandaloneMonthsCount=0; |
michael@0 | 1348 | fStandaloneShortMonths = NULL; |
michael@0 | 1349 | fStandaloneShortMonthsCount=0; |
michael@0 | 1350 | fStandaloneNarrowMonths = NULL; |
michael@0 | 1351 | fStandaloneNarrowMonthsCount=0; |
michael@0 | 1352 | fWeekdays = NULL; |
michael@0 | 1353 | fWeekdaysCount=0; |
michael@0 | 1354 | fShortWeekdays = NULL; |
michael@0 | 1355 | fShortWeekdaysCount=0; |
michael@0 | 1356 | fShorterWeekdays = NULL; |
michael@0 | 1357 | fShorterWeekdaysCount=0; |
michael@0 | 1358 | fNarrowWeekdays = NULL; |
michael@0 | 1359 | fNarrowWeekdaysCount=0; |
michael@0 | 1360 | fStandaloneWeekdays = NULL; |
michael@0 | 1361 | fStandaloneWeekdaysCount=0; |
michael@0 | 1362 | fStandaloneShortWeekdays = NULL; |
michael@0 | 1363 | fStandaloneShortWeekdaysCount=0; |
michael@0 | 1364 | fStandaloneShorterWeekdays = NULL; |
michael@0 | 1365 | fStandaloneShorterWeekdaysCount=0; |
michael@0 | 1366 | fStandaloneNarrowWeekdays = NULL; |
michael@0 | 1367 | fStandaloneNarrowWeekdaysCount=0; |
michael@0 | 1368 | fAmPms = NULL; |
michael@0 | 1369 | fAmPmsCount=0; |
michael@0 | 1370 | fQuarters = NULL; |
michael@0 | 1371 | fQuartersCount = 0; |
michael@0 | 1372 | fShortQuarters = NULL; |
michael@0 | 1373 | fShortQuartersCount = 0; |
michael@0 | 1374 | fStandaloneQuarters = NULL; |
michael@0 | 1375 | fStandaloneQuartersCount = 0; |
michael@0 | 1376 | fStandaloneShortQuarters = NULL; |
michael@0 | 1377 | fStandaloneShortQuartersCount = 0; |
michael@0 | 1378 | fLeapMonthPatterns = NULL; |
michael@0 | 1379 | fLeapMonthPatternsCount = 0; |
michael@0 | 1380 | fShortYearNames = NULL; |
michael@0 | 1381 | fShortYearNamesCount = 0; |
michael@0 | 1382 | fZoneStringsRowCount = 0; |
michael@0 | 1383 | fZoneStringsColCount = 0; |
michael@0 | 1384 | fZoneStrings = NULL; |
michael@0 | 1385 | fLocaleZoneStrings = NULL; |
michael@0 | 1386 | uprv_memset(fCapitalization, 0, sizeof(fCapitalization)); |
michael@0 | 1387 | |
michael@0 | 1388 | // We need to preserve the requested locale for |
michael@0 | 1389 | // lazy ZoneStringFormat instantiation. ZoneStringFormat |
michael@0 | 1390 | // is region sensitive, thus, bundle locale bundle's locale |
michael@0 | 1391 | // is not sufficient. |
michael@0 | 1392 | fZSFLocale = locale; |
michael@0 | 1393 | |
michael@0 | 1394 | if (U_FAILURE(status)) return; |
michael@0 | 1395 | |
michael@0 | 1396 | /** |
michael@0 | 1397 | * Retrieve the string arrays we need from the resource bundle file. |
michael@0 | 1398 | * We cast away const here, but that's okay; we won't delete any of |
michael@0 | 1399 | * these. |
michael@0 | 1400 | */ |
michael@0 | 1401 | CalendarData calData(locale, type, status); |
michael@0 | 1402 | |
michael@0 | 1403 | // load the first data item |
michael@0 | 1404 | UResourceBundle *erasMain = calData.getByKey(gErasTag, status); |
michael@0 | 1405 | UResourceBundle *eras = ures_getByKeyWithFallback(erasMain, gNamesAbbrTag, NULL, &status); |
michael@0 | 1406 | UErrorCode oldStatus = status; |
michael@0 | 1407 | UResourceBundle *eraNames = ures_getByKeyWithFallback(erasMain, gNamesWideTag, NULL, &status); |
michael@0 | 1408 | if ( status == U_MISSING_RESOURCE_ERROR ) { // Workaround because eras/wide was omitted from CLDR 1.3 |
michael@0 | 1409 | status = oldStatus; |
michael@0 | 1410 | eraNames = ures_getByKeyWithFallback(erasMain, gNamesAbbrTag, NULL, &status); |
michael@0 | 1411 | } |
michael@0 | 1412 | // current ICU4J falls back to abbreviated if narrow eras are missing, so we will too |
michael@0 | 1413 | oldStatus = status; |
michael@0 | 1414 | UResourceBundle *narrowEras = ures_getByKeyWithFallback(erasMain, gNamesNarrowTag, NULL, &status); |
michael@0 | 1415 | if ( status == U_MISSING_RESOURCE_ERROR ) { |
michael@0 | 1416 | status = oldStatus; |
michael@0 | 1417 | narrowEras = ures_getByKeyWithFallback(erasMain, gNamesAbbrTag, NULL, &status); |
michael@0 | 1418 | } |
michael@0 | 1419 | |
michael@0 | 1420 | UErrorCode tempStatus = U_ZERO_ERROR; |
michael@0 | 1421 | UResourceBundle *monthPatterns = calData.getByKey(gMonthPatternsTag, tempStatus); |
michael@0 | 1422 | if (U_SUCCESS(tempStatus) && monthPatterns != NULL) { |
michael@0 | 1423 | fLeapMonthPatterns = newUnicodeStringArray(kMonthPatternsCount); |
michael@0 | 1424 | if (fLeapMonthPatterns) { |
michael@0 | 1425 | initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternFormatWide, calData.getByKey2(gMonthPatternsTag, gNamesWideTag, tempStatus), tempStatus); |
michael@0 | 1426 | initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternFormatAbbrev, calData.getByKey2(gMonthPatternsTag, gNamesAbbrTag, tempStatus), tempStatus); |
michael@0 | 1427 | initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternFormatNarrow, calData.getByKey2(gMonthPatternsTag, gNamesNarrowTag, tempStatus), tempStatus); |
michael@0 | 1428 | initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternStandaloneWide, calData.getByKey3(gMonthPatternsTag, gNamesStandaloneTag, gNamesWideTag, tempStatus), tempStatus); |
michael@0 | 1429 | initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternStandaloneAbbrev, calData.getByKey3(gMonthPatternsTag, gNamesStandaloneTag, gNamesAbbrTag, tempStatus), tempStatus); |
michael@0 | 1430 | initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternStandaloneNarrow, calData.getByKey3(gMonthPatternsTag, gNamesStandaloneTag, gNamesNarrowTag, tempStatus), tempStatus); |
michael@0 | 1431 | initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternNumeric, calData.getByKey3(gMonthPatternsTag, gNamesNumericTag, gNamesAllTag, tempStatus), tempStatus); |
michael@0 | 1432 | if (U_SUCCESS(tempStatus)) { |
michael@0 | 1433 | fLeapMonthPatternsCount = kMonthPatternsCount; |
michael@0 | 1434 | } else { |
michael@0 | 1435 | delete[] fLeapMonthPatterns; |
michael@0 | 1436 | fLeapMonthPatterns = NULL; |
michael@0 | 1437 | } |
michael@0 | 1438 | } |
michael@0 | 1439 | } |
michael@0 | 1440 | |
michael@0 | 1441 | tempStatus = U_ZERO_ERROR; |
michael@0 | 1442 | UResourceBundle *cyclicNameSets= calData.getByKey(gCyclicNameSetsTag, tempStatus); |
michael@0 | 1443 | if (U_SUCCESS(tempStatus) && cyclicNameSets != NULL) { |
michael@0 | 1444 | UResourceBundle *nameSetYears = ures_getByKeyWithFallback(cyclicNameSets, gNameSetYearsTag, NULL, &tempStatus); |
michael@0 | 1445 | if (U_SUCCESS(tempStatus)) { |
michael@0 | 1446 | UResourceBundle *nameSetYearsFmt = ures_getByKeyWithFallback(nameSetYears, gNamesFormatTag, NULL, &tempStatus); |
michael@0 | 1447 | if (U_SUCCESS(tempStatus)) { |
michael@0 | 1448 | UResourceBundle *nameSetYearsFmtAbbrev = ures_getByKeyWithFallback(nameSetYearsFmt, gNamesAbbrTag, NULL, &tempStatus); |
michael@0 | 1449 | if (U_SUCCESS(tempStatus)) { |
michael@0 | 1450 | initField(&fShortYearNames, fShortYearNamesCount, nameSetYearsFmtAbbrev, tempStatus); |
michael@0 | 1451 | ures_close(nameSetYearsFmtAbbrev); |
michael@0 | 1452 | } |
michael@0 | 1453 | ures_close(nameSetYearsFmt); |
michael@0 | 1454 | } |
michael@0 | 1455 | ures_close(nameSetYears); |
michael@0 | 1456 | } |
michael@0 | 1457 | } |
michael@0 | 1458 | |
michael@0 | 1459 | tempStatus = U_ZERO_ERROR; |
michael@0 | 1460 | UResourceBundle *localeBundle = ures_open(NULL, locale.getName(), &tempStatus); |
michael@0 | 1461 | if (U_SUCCESS(tempStatus)) { |
michael@0 | 1462 | UResourceBundle *contextTransforms = ures_getByKeyWithFallback(localeBundle, gContextTransformsTag, NULL, &tempStatus); |
michael@0 | 1463 | if (U_SUCCESS(tempStatus)) { |
michael@0 | 1464 | UResourceBundle *contextTransformUsage; |
michael@0 | 1465 | while ( (contextTransformUsage = ures_getNextResource(contextTransforms, NULL, &tempStatus)) != NULL ) { |
michael@0 | 1466 | const int32_t * intVector = ures_getIntVector(contextTransformUsage, &len, &status); |
michael@0 | 1467 | if (U_SUCCESS(tempStatus) && intVector != NULL && len >= 2) { |
michael@0 | 1468 | const char* usageType = ures_getKey(contextTransformUsage); |
michael@0 | 1469 | if (usageType != NULL) { |
michael@0 | 1470 | const ContextUsageTypeNameToEnumValue * typeMapPtr = contextUsageTypeMap; |
michael@0 | 1471 | int32_t compResult = 0; |
michael@0 | 1472 | // linear search; list is short and we cannot be sure that bsearch is available |
michael@0 | 1473 | while ( typeMapPtr->usageTypeName != NULL && (compResult = uprv_strcmp(usageType, typeMapPtr->usageTypeName)) > 0 ) { |
michael@0 | 1474 | ++typeMapPtr; |
michael@0 | 1475 | } |
michael@0 | 1476 | if (typeMapPtr->usageTypeName != NULL && compResult == 0) { |
michael@0 | 1477 | fCapitalization[typeMapPtr->usageTypeEnumValue][0] = intVector[0]; |
michael@0 | 1478 | fCapitalization[typeMapPtr->usageTypeEnumValue][1] = intVector[1]; |
michael@0 | 1479 | } |
michael@0 | 1480 | } |
michael@0 | 1481 | } |
michael@0 | 1482 | tempStatus = U_ZERO_ERROR; |
michael@0 | 1483 | ures_close(contextTransformUsage); |
michael@0 | 1484 | } |
michael@0 | 1485 | ures_close(contextTransforms); |
michael@0 | 1486 | } |
michael@0 | 1487 | ures_close(localeBundle); |
michael@0 | 1488 | } |
michael@0 | 1489 | |
michael@0 | 1490 | UResourceBundle *weekdaysData = NULL; // Data closed by calData |
michael@0 | 1491 | UResourceBundle *abbrWeekdaysData = NULL; // Data closed by calData |
michael@0 | 1492 | UResourceBundle *shorterWeekdaysData = NULL; // Data closed by calData |
michael@0 | 1493 | UResourceBundle *narrowWeekdaysData = NULL; // Data closed by calData |
michael@0 | 1494 | UResourceBundle *standaloneWeekdaysData = NULL; // Data closed by calData |
michael@0 | 1495 | UResourceBundle *standaloneAbbrWeekdaysData = NULL; // Data closed by calData |
michael@0 | 1496 | UResourceBundle *standaloneShorterWeekdaysData = NULL; // Data closed by calData |
michael@0 | 1497 | UResourceBundle *standaloneNarrowWeekdaysData = NULL; // Data closed by calData |
michael@0 | 1498 | |
michael@0 | 1499 | U_LOCALE_BASED(locBased, *this); |
michael@0 | 1500 | if (U_FAILURE(status)) |
michael@0 | 1501 | { |
michael@0 | 1502 | if (useLastResortData) |
michael@0 | 1503 | { |
michael@0 | 1504 | // Handle the case in which there is no resource data present. |
michael@0 | 1505 | // We don't have to generate usable patterns in this situation; |
michael@0 | 1506 | // we just need to produce something that will be semi-intelligible |
michael@0 | 1507 | // in most locales. |
michael@0 | 1508 | |
michael@0 | 1509 | status = U_USING_FALLBACK_WARNING; |
michael@0 | 1510 | |
michael@0 | 1511 | initField(&fEras, fErasCount, (const UChar *)gLastResortEras, kEraNum, kEraLen, status); |
michael@0 | 1512 | initField(&fEraNames, fEraNamesCount, (const UChar *)gLastResortEras, kEraNum, kEraLen, status); |
michael@0 | 1513 | initField(&fNarrowEras, fNarrowErasCount, (const UChar *)gLastResortEras, kEraNum, kEraLen, status); |
michael@0 | 1514 | initField(&fMonths, fMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status); |
michael@0 | 1515 | initField(&fShortMonths, fShortMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status); |
michael@0 | 1516 | initField(&fNarrowMonths, fNarrowMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status); |
michael@0 | 1517 | initField(&fStandaloneMonths, fStandaloneMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status); |
michael@0 | 1518 | initField(&fStandaloneShortMonths, fStandaloneShortMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status); |
michael@0 | 1519 | initField(&fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status); |
michael@0 | 1520 | initField(&fWeekdays, fWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status); |
michael@0 | 1521 | initField(&fShortWeekdays, fShortWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status); |
michael@0 | 1522 | initField(&fShorterWeekdays, fShorterWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status); |
michael@0 | 1523 | initField(&fNarrowWeekdays, fNarrowWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status); |
michael@0 | 1524 | initField(&fStandaloneWeekdays, fStandaloneWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status); |
michael@0 | 1525 | initField(&fStandaloneShortWeekdays, fStandaloneShortWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status); |
michael@0 | 1526 | initField(&fStandaloneShorterWeekdays, fStandaloneShorterWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status); |
michael@0 | 1527 | initField(&fStandaloneNarrowWeekdays, fStandaloneNarrowWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status); |
michael@0 | 1528 | initField(&fAmPms, fAmPmsCount, (const UChar *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status); |
michael@0 | 1529 | initField(&fQuarters, fQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status); |
michael@0 | 1530 | initField(&fShortQuarters, fShortQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status); |
michael@0 | 1531 | initField(&fStandaloneQuarters, fStandaloneQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status); |
michael@0 | 1532 | initField(&fStandaloneShortQuarters, fStandaloneShortQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status); |
michael@0 | 1533 | fLocalPatternChars.setTo(TRUE, gPatternChars, PATTERN_CHARS_LEN); |
michael@0 | 1534 | } |
michael@0 | 1535 | goto cleanup; |
michael@0 | 1536 | } |
michael@0 | 1537 | |
michael@0 | 1538 | // if we make it to here, the resource data is cool, and we can get everything out |
michael@0 | 1539 | // of it that we need except for the time-zone and localized-pattern data, which |
michael@0 | 1540 | // are stored in a separate file |
michael@0 | 1541 | locBased.setLocaleIDs(ures_getLocaleByType(eras, ULOC_VALID_LOCALE, &status), |
michael@0 | 1542 | ures_getLocaleByType(eras, ULOC_ACTUAL_LOCALE, &status)); |
michael@0 | 1543 | |
michael@0 | 1544 | initField(&fEras, fErasCount, eras, status); |
michael@0 | 1545 | initField(&fEraNames, fEraNamesCount, eraNames, status); |
michael@0 | 1546 | initField(&fNarrowEras, fNarrowErasCount, narrowEras, status); |
michael@0 | 1547 | |
michael@0 | 1548 | initField(&fMonths, fMonthsCount, calData.getByKey2(gMonthNamesTag, gNamesWideTag, status), status); |
michael@0 | 1549 | initField(&fShortMonths, fShortMonthsCount, calData.getByKey2(gMonthNamesTag, gNamesAbbrTag, status), status); |
michael@0 | 1550 | |
michael@0 | 1551 | initField(&fNarrowMonths, fNarrowMonthsCount, calData.getByKey2(gMonthNamesTag, gNamesNarrowTag, status), status); |
michael@0 | 1552 | if(status == U_MISSING_RESOURCE_ERROR) { |
michael@0 | 1553 | status = U_ZERO_ERROR; |
michael@0 | 1554 | initField(&fNarrowMonths, fNarrowMonthsCount, calData.getByKey3(gMonthNamesTag, gNamesStandaloneTag, gNamesNarrowTag, status), status); |
michael@0 | 1555 | } |
michael@0 | 1556 | if ( status == U_MISSING_RESOURCE_ERROR ) { /* If format/narrow not available, use format/abbreviated */ |
michael@0 | 1557 | status = U_ZERO_ERROR; |
michael@0 | 1558 | initField(&fNarrowMonths, fNarrowMonthsCount, calData.getByKey2(gMonthNamesTag, gNamesAbbrTag, status), status); |
michael@0 | 1559 | } |
michael@0 | 1560 | |
michael@0 | 1561 | initField(&fStandaloneMonths, fStandaloneMonthsCount, calData.getByKey3(gMonthNamesTag, gNamesStandaloneTag, gNamesWideTag, status), status); |
michael@0 | 1562 | if ( status == U_MISSING_RESOURCE_ERROR ) { /* If standalone/wide not available, use format/wide */ |
michael@0 | 1563 | status = U_ZERO_ERROR; |
michael@0 | 1564 | initField(&fStandaloneMonths, fStandaloneMonthsCount, calData.getByKey2(gMonthNamesTag, gNamesWideTag, status), status); |
michael@0 | 1565 | } |
michael@0 | 1566 | initField(&fStandaloneShortMonths, fStandaloneShortMonthsCount, calData.getByKey3(gMonthNamesTag, gNamesStandaloneTag, gNamesAbbrTag, status), status); |
michael@0 | 1567 | if ( status == U_MISSING_RESOURCE_ERROR ) { /* If standalone/abbreviated not available, use format/abbreviated */ |
michael@0 | 1568 | status = U_ZERO_ERROR; |
michael@0 | 1569 | initField(&fStandaloneShortMonths, fStandaloneShortMonthsCount, calData.getByKey2(gMonthNamesTag, gNamesAbbrTag, status), status); |
michael@0 | 1570 | } |
michael@0 | 1571 | initField(&fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, calData.getByKey3(gMonthNamesTag, gNamesStandaloneTag, gNamesNarrowTag, status), status); |
michael@0 | 1572 | if ( status == U_MISSING_RESOURCE_ERROR ) { /* if standalone/narrow not availabe, try format/narrow */ |
michael@0 | 1573 | status = U_ZERO_ERROR; |
michael@0 | 1574 | initField(&fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, calData.getByKey2(gMonthNamesTag, gNamesNarrowTag, status), status); |
michael@0 | 1575 | if ( status == U_MISSING_RESOURCE_ERROR ) { /* if still not there, use format/abbreviated */ |
michael@0 | 1576 | status = U_ZERO_ERROR; |
michael@0 | 1577 | initField(&fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, calData.getByKey2(gMonthNamesTag, gNamesAbbrTag, status), status); |
michael@0 | 1578 | } |
michael@0 | 1579 | } |
michael@0 | 1580 | initField(&fAmPms, fAmPmsCount, calData.getByKey(gAmPmMarkersTag, status), status); |
michael@0 | 1581 | |
michael@0 | 1582 | initField(&fQuarters, fQuartersCount, calData.getByKey2(gQuartersTag, gNamesWideTag, status), status); |
michael@0 | 1583 | initField(&fShortQuarters, fShortQuartersCount, calData.getByKey2(gQuartersTag, gNamesAbbrTag, status), status); |
michael@0 | 1584 | |
michael@0 | 1585 | initField(&fStandaloneQuarters, fStandaloneQuartersCount, calData.getByKey3(gQuartersTag, gNamesStandaloneTag, gNamesWideTag, status), status); |
michael@0 | 1586 | if(status == U_MISSING_RESOURCE_ERROR) { |
michael@0 | 1587 | status = U_ZERO_ERROR; |
michael@0 | 1588 | initField(&fStandaloneQuarters, fStandaloneQuartersCount, calData.getByKey2(gQuartersTag, gNamesWideTag, status), status); |
michael@0 | 1589 | } |
michael@0 | 1590 | |
michael@0 | 1591 | initField(&fStandaloneShortQuarters, fStandaloneShortQuartersCount, calData.getByKey3(gQuartersTag, gNamesStandaloneTag, gNamesAbbrTag, status), status); |
michael@0 | 1592 | if(status == U_MISSING_RESOURCE_ERROR) { |
michael@0 | 1593 | status = U_ZERO_ERROR; |
michael@0 | 1594 | initField(&fStandaloneShortQuarters, fStandaloneShortQuartersCount, calData.getByKey2(gQuartersTag, gNamesAbbrTag, status), status); |
michael@0 | 1595 | } |
michael@0 | 1596 | |
michael@0 | 1597 | // ICU 3.8 or later version no longer uses localized date-time pattern characters by default (ticket#5597) |
michael@0 | 1598 | /* |
michael@0 | 1599 | // fastCopyFrom()/setTo() - see assignArray comments |
michael@0 | 1600 | resStr = ures_getStringByKey(fResourceBundle, gLocalPatternCharsTag, &len, &status); |
michael@0 | 1601 | fLocalPatternChars.setTo(TRUE, resStr, len); |
michael@0 | 1602 | // If the locale data does not include new pattern chars, use the defaults |
michael@0 | 1603 | // TODO: Consider making this an error, since this may add conflicting characters. |
michael@0 | 1604 | if (len < PATTERN_CHARS_LEN) { |
michael@0 | 1605 | fLocalPatternChars.append(UnicodeString(TRUE, &gPatternChars[len], PATTERN_CHARS_LEN-len)); |
michael@0 | 1606 | } |
michael@0 | 1607 | */ |
michael@0 | 1608 | fLocalPatternChars.setTo(TRUE, gPatternChars, PATTERN_CHARS_LEN); |
michael@0 | 1609 | |
michael@0 | 1610 | // Format wide weekdays -> fWeekdays |
michael@0 | 1611 | // {sfb} fixed to handle 1-based weekdays |
michael@0 | 1612 | weekdaysData = calData.getByKey2(gDayNamesTag, gNamesWideTag, status); |
michael@0 | 1613 | fWeekdaysCount = ures_getSize(weekdaysData); |
michael@0 | 1614 | fWeekdays = new UnicodeString[fWeekdaysCount+1]; |
michael@0 | 1615 | /* pin the blame on system. If we cannot get a chunk of memory .. the system is dying!*/ |
michael@0 | 1616 | if (fWeekdays == NULL) { |
michael@0 | 1617 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1618 | goto cleanup; |
michael@0 | 1619 | } |
michael@0 | 1620 | // leave fWeekdays[0] empty |
michael@0 | 1621 | for(i = 0; i<fWeekdaysCount; i++) { |
michael@0 | 1622 | resStr = ures_getStringByIndex(weekdaysData, i, &len, &status); |
michael@0 | 1623 | // setTo() - see assignArray comments |
michael@0 | 1624 | fWeekdays[i+1].setTo(TRUE, resStr, len); |
michael@0 | 1625 | } |
michael@0 | 1626 | fWeekdaysCount++; |
michael@0 | 1627 | |
michael@0 | 1628 | // Format abbreviated weekdays -> fShortWeekdays |
michael@0 | 1629 | abbrWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status); |
michael@0 | 1630 | fShortWeekdaysCount = ures_getSize(abbrWeekdaysData); |
michael@0 | 1631 | fShortWeekdays = new UnicodeString[fShortWeekdaysCount+1]; |
michael@0 | 1632 | /* test for NULL */ |
michael@0 | 1633 | if (fShortWeekdays == 0) { |
michael@0 | 1634 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1635 | goto cleanup; |
michael@0 | 1636 | } |
michael@0 | 1637 | // leave fShortWeekdays[0] empty |
michael@0 | 1638 | for(i = 0; i<fShortWeekdaysCount; i++) { |
michael@0 | 1639 | resStr = ures_getStringByIndex(abbrWeekdaysData, i, &len, &status); |
michael@0 | 1640 | // setTo() - see assignArray comments |
michael@0 | 1641 | fShortWeekdays[i+1].setTo(TRUE, resStr, len); |
michael@0 | 1642 | } |
michael@0 | 1643 | fShortWeekdaysCount++; |
michael@0 | 1644 | |
michael@0 | 1645 | // Format short weekdays -> fShorterWeekdays (fall back to abbreviated) |
michael@0 | 1646 | shorterWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesShortTag, status); |
michael@0 | 1647 | if ( status == U_MISSING_RESOURCE_ERROR ) { |
michael@0 | 1648 | status = U_ZERO_ERROR; |
michael@0 | 1649 | shorterWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status); |
michael@0 | 1650 | } |
michael@0 | 1651 | fShorterWeekdaysCount = ures_getSize(shorterWeekdaysData); |
michael@0 | 1652 | fShorterWeekdays = new UnicodeString[fShorterWeekdaysCount+1]; |
michael@0 | 1653 | /* test for NULL */ |
michael@0 | 1654 | if (fShorterWeekdays == 0) { |
michael@0 | 1655 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1656 | goto cleanup; |
michael@0 | 1657 | } |
michael@0 | 1658 | // leave fShorterWeekdays[0] empty |
michael@0 | 1659 | for(i = 0; i<fShorterWeekdaysCount; i++) { |
michael@0 | 1660 | resStr = ures_getStringByIndex(shorterWeekdaysData, i, &len, &status); |
michael@0 | 1661 | // setTo() - see assignArray comments |
michael@0 | 1662 | fShorterWeekdays[i+1].setTo(TRUE, resStr, len); |
michael@0 | 1663 | } |
michael@0 | 1664 | fShorterWeekdaysCount++; |
michael@0 | 1665 | |
michael@0 | 1666 | // Format narrow weekdays -> fNarrowWeekdays |
michael@0 | 1667 | narrowWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesNarrowTag, status); |
michael@0 | 1668 | if(status == U_MISSING_RESOURCE_ERROR) { |
michael@0 | 1669 | status = U_ZERO_ERROR; |
michael@0 | 1670 | narrowWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesNarrowTag, status); |
michael@0 | 1671 | } |
michael@0 | 1672 | if ( status == U_MISSING_RESOURCE_ERROR ) { |
michael@0 | 1673 | status = U_ZERO_ERROR; |
michael@0 | 1674 | narrowWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status); |
michael@0 | 1675 | } |
michael@0 | 1676 | fNarrowWeekdaysCount = ures_getSize(narrowWeekdaysData); |
michael@0 | 1677 | fNarrowWeekdays = new UnicodeString[fNarrowWeekdaysCount+1]; |
michael@0 | 1678 | /* test for NULL */ |
michael@0 | 1679 | if (fNarrowWeekdays == 0) { |
michael@0 | 1680 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1681 | goto cleanup; |
michael@0 | 1682 | } |
michael@0 | 1683 | // leave fNarrowWeekdays[0] empty |
michael@0 | 1684 | for(i = 0; i<fNarrowWeekdaysCount; i++) { |
michael@0 | 1685 | resStr = ures_getStringByIndex(narrowWeekdaysData, i, &len, &status); |
michael@0 | 1686 | // setTo() - see assignArray comments |
michael@0 | 1687 | fNarrowWeekdays[i+1].setTo(TRUE, resStr, len); |
michael@0 | 1688 | } |
michael@0 | 1689 | fNarrowWeekdaysCount++; |
michael@0 | 1690 | |
michael@0 | 1691 | // Stand-alone wide weekdays -> fStandaloneWeekdays |
michael@0 | 1692 | standaloneWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesWideTag, status); |
michael@0 | 1693 | if ( status == U_MISSING_RESOURCE_ERROR ) { |
michael@0 | 1694 | status = U_ZERO_ERROR; |
michael@0 | 1695 | standaloneWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesWideTag, status); |
michael@0 | 1696 | } |
michael@0 | 1697 | fStandaloneWeekdaysCount = ures_getSize(standaloneWeekdaysData); |
michael@0 | 1698 | fStandaloneWeekdays = new UnicodeString[fStandaloneWeekdaysCount+1]; |
michael@0 | 1699 | /* test for NULL */ |
michael@0 | 1700 | if (fStandaloneWeekdays == 0) { |
michael@0 | 1701 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1702 | goto cleanup; |
michael@0 | 1703 | } |
michael@0 | 1704 | // leave fStandaloneWeekdays[0] empty |
michael@0 | 1705 | for(i = 0; i<fStandaloneWeekdaysCount; i++) { |
michael@0 | 1706 | resStr = ures_getStringByIndex(standaloneWeekdaysData, i, &len, &status); |
michael@0 | 1707 | // setTo() - see assignArray comments |
michael@0 | 1708 | fStandaloneWeekdays[i+1].setTo(TRUE, resStr, len); |
michael@0 | 1709 | } |
michael@0 | 1710 | fStandaloneWeekdaysCount++; |
michael@0 | 1711 | |
michael@0 | 1712 | // Stand-alone abbreviated weekdays -> fStandaloneShortWeekdays |
michael@0 | 1713 | standaloneAbbrWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesAbbrTag, status); |
michael@0 | 1714 | if ( status == U_MISSING_RESOURCE_ERROR ) { |
michael@0 | 1715 | status = U_ZERO_ERROR; |
michael@0 | 1716 | standaloneAbbrWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status); |
michael@0 | 1717 | } |
michael@0 | 1718 | fStandaloneShortWeekdaysCount = ures_getSize(standaloneAbbrWeekdaysData); |
michael@0 | 1719 | fStandaloneShortWeekdays = new UnicodeString[fStandaloneShortWeekdaysCount+1]; |
michael@0 | 1720 | /* test for NULL */ |
michael@0 | 1721 | if (fStandaloneShortWeekdays == 0) { |
michael@0 | 1722 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1723 | goto cleanup; |
michael@0 | 1724 | } |
michael@0 | 1725 | // leave fStandaloneShortWeekdays[0] empty |
michael@0 | 1726 | for(i = 0; i<fStandaloneShortWeekdaysCount; i++) { |
michael@0 | 1727 | resStr = ures_getStringByIndex(standaloneAbbrWeekdaysData, i, &len, &status); |
michael@0 | 1728 | // setTo() - see assignArray comments |
michael@0 | 1729 | fStandaloneShortWeekdays[i+1].setTo(TRUE, resStr, len); |
michael@0 | 1730 | } |
michael@0 | 1731 | fStandaloneShortWeekdaysCount++; |
michael@0 | 1732 | |
michael@0 | 1733 | // Stand-alone short weekdays -> fStandaloneShorterWeekdays (fall back to format abbreviated) |
michael@0 | 1734 | standaloneShorterWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesShortTag, status); |
michael@0 | 1735 | if ( status == U_MISSING_RESOURCE_ERROR ) { |
michael@0 | 1736 | status = U_ZERO_ERROR; |
michael@0 | 1737 | standaloneShorterWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status); |
michael@0 | 1738 | } |
michael@0 | 1739 | fStandaloneShorterWeekdaysCount = ures_getSize(standaloneShorterWeekdaysData); |
michael@0 | 1740 | fStandaloneShorterWeekdays = new UnicodeString[fStandaloneShorterWeekdaysCount+1]; |
michael@0 | 1741 | /* test for NULL */ |
michael@0 | 1742 | if (fStandaloneShorterWeekdays == 0) { |
michael@0 | 1743 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1744 | goto cleanup; |
michael@0 | 1745 | } |
michael@0 | 1746 | // leave fStandaloneShorterWeekdays[0] empty |
michael@0 | 1747 | for(i = 0; i<fStandaloneShorterWeekdaysCount; i++) { |
michael@0 | 1748 | resStr = ures_getStringByIndex(standaloneShorterWeekdaysData, i, &len, &status); |
michael@0 | 1749 | // setTo() - see assignArray comments |
michael@0 | 1750 | fStandaloneShorterWeekdays[i+1].setTo(TRUE, resStr, len); |
michael@0 | 1751 | } |
michael@0 | 1752 | fStandaloneShorterWeekdaysCount++; |
michael@0 | 1753 | |
michael@0 | 1754 | // Stand-alone narrow weekdays -> fStandaloneNarrowWeekdays |
michael@0 | 1755 | standaloneNarrowWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesNarrowTag, status); |
michael@0 | 1756 | if ( status == U_MISSING_RESOURCE_ERROR ) { |
michael@0 | 1757 | status = U_ZERO_ERROR; |
michael@0 | 1758 | standaloneNarrowWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesNarrowTag, status); |
michael@0 | 1759 | if ( status == U_MISSING_RESOURCE_ERROR ) { |
michael@0 | 1760 | status = U_ZERO_ERROR; |
michael@0 | 1761 | standaloneNarrowWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status); |
michael@0 | 1762 | } |
michael@0 | 1763 | } |
michael@0 | 1764 | fStandaloneNarrowWeekdaysCount = ures_getSize(standaloneNarrowWeekdaysData); |
michael@0 | 1765 | fStandaloneNarrowWeekdays = new UnicodeString[fStandaloneNarrowWeekdaysCount+1]; |
michael@0 | 1766 | /* test for NULL */ |
michael@0 | 1767 | if (fStandaloneNarrowWeekdays == 0) { |
michael@0 | 1768 | status = U_MEMORY_ALLOCATION_ERROR; |
michael@0 | 1769 | goto cleanup; |
michael@0 | 1770 | } |
michael@0 | 1771 | // leave fStandaloneNarrowWeekdays[0] empty |
michael@0 | 1772 | for(i = 0; i<fStandaloneNarrowWeekdaysCount; i++) { |
michael@0 | 1773 | resStr = ures_getStringByIndex(standaloneNarrowWeekdaysData, i, &len, &status); |
michael@0 | 1774 | // setTo() - see assignArray comments |
michael@0 | 1775 | fStandaloneNarrowWeekdays[i+1].setTo(TRUE, resStr, len); |
michael@0 | 1776 | } |
michael@0 | 1777 | fStandaloneNarrowWeekdaysCount++; |
michael@0 | 1778 | |
michael@0 | 1779 | cleanup: |
michael@0 | 1780 | ures_close(eras); |
michael@0 | 1781 | ures_close(eraNames); |
michael@0 | 1782 | ures_close(narrowEras); |
michael@0 | 1783 | } |
michael@0 | 1784 | |
michael@0 | 1785 | Locale |
michael@0 | 1786 | DateFormatSymbols::getLocale(ULocDataLocaleType type, UErrorCode& status) const { |
michael@0 | 1787 | U_LOCALE_BASED(locBased, *this); |
michael@0 | 1788 | return locBased.getLocale(type, status); |
michael@0 | 1789 | } |
michael@0 | 1790 | |
michael@0 | 1791 | U_NAMESPACE_END |
michael@0 | 1792 | |
michael@0 | 1793 | #endif /* #if !UCONFIG_NO_FORMATTING */ |
michael@0 | 1794 | |
michael@0 | 1795 | //eof |