| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 1997-2013, International Business Machines Corporation and * | 3 * Copyright (C) 1997-2014, International Business Machines Corporation and * |
| 4 * others. All Rights Reserved. * | 4 * others. All Rights Reserved. * |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 * | 6 * |
| 7 * File DTFMTSYM.CPP | 7 * File DTFMTSYM.CPP |
| 8 * | 8 * |
| 9 * Modification History: | 9 * Modification History: |
| 10 * | 10 * |
| 11 * Date Name Description | 11 * Date Name Description |
| 12 * 02/19/97 aliu Converted from java. | 12 * 02/19/97 aliu Converted from java. |
| 13 * 07/21/98 stephen Added getZoneIndex | 13 * 07/21/98 stephen Added getZoneIndex |
| 14 * Changed weekdays/short weekdays to be one-based | 14 * Changed weekdays/short weekdays to be one-based |
| 15 * 06/14/99 stephen Removed SimpleDateFormat::fgTimeZoneDataSuffix | 15 * 06/14/99 stephen Removed SimpleDateFormat::fgTimeZoneDataSuffix |
| 16 * 11/16/99 weiv Added 'Y' and 'e' to fgPatternChars | 16 * 11/16/99 weiv Added 'Y' and 'e' to fgPatternChars |
| 17 * 03/27/00 weiv Keeping resource bundle around! | 17 * 03/27/00 weiv Keeping resource bundle around! |
| 18 * 06/30/05 emmons Added eraNames, narrow month/day, standalone context | 18 * 06/30/05 emmons Added eraNames, narrow month/day, standalone context |
| 19 * 10/12/05 emmons Added setters for eraNames, month/day by width/conte
xt | 19 * 10/12/05 emmons Added setters for eraNames, month/day by width/conte
xt |
| 20 ******************************************************************************* | 20 ******************************************************************************* |
| 21 */ | 21 */ |
| 22 #include "unicode/utypes.h" | 22 #include "unicode/utypes.h" |
| 23 | 23 |
| 24 #if !UCONFIG_NO_FORMATTING | 24 #if !UCONFIG_NO_FORMATTING |
| 25 #include "unicode/ustring.h" | 25 #include "unicode/ustring.h" |
| 26 #include "unicode/dtfmtsym.h" | 26 #include "unicode/dtfmtsym.h" |
| 27 #include "unicode/smpdtfmt.h" | 27 #include "unicode/smpdtfmt.h" |
| 28 #include "unicode/msgfmt.h" | 28 #include "unicode/msgfmt.h" |
| 29 #include "unicode/tznames.h" | 29 #include "unicode/tznames.h" |
| 30 #include "cpputils.h" | 30 #include "cpputils.h" |
| 31 #include "ucln_in.h" | |
| 32 #include "umutex.h" | 31 #include "umutex.h" |
| 33 #include "cmemory.h" | 32 #include "cmemory.h" |
| 34 #include "cstring.h" | 33 #include "cstring.h" |
| 35 #include "locbased.h" | 34 #include "locbased.h" |
| 36 #include "gregoimp.h" | 35 #include "gregoimp.h" |
| 37 #include "hash.h" | 36 #include "hash.h" |
| 38 #include "uresimp.h" | 37 #include "uresimp.h" |
| 39 #include "ureslocs.h" | 38 #include "ureslocs.h" |
| 40 | 39 |
| 41 // ***************************************************************************** | 40 // ***************************************************************************** |
| 42 // class DateFormatSymbols | 41 // class DateFormatSymbols |
| 43 // ***************************************************************************** | 42 // ***************************************************************************** |
| 44 | 43 |
| 45 /** | 44 /** |
| 46 * These are static arrays we use only in the case where we have no | 45 * These are static arrays we use only in the case where we have no |
| 47 * resource data. | 46 * resource data. |
| 48 */ | 47 */ |
| 49 | 48 |
| 50 #define PATTERN_CHARS_LEN 34 | 49 #define PATTERN_CHARS_LEN 35 |
| 51 | 50 |
| 52 /** | 51 /** |
| 53 * Unlocalized date-time pattern characters. For example: 'y', 'd', etc. All | 52 * Unlocalized date-time pattern characters. For example: 'y', 'd', etc. All |
| 54 * locales use the same these unlocalized pattern characters. | 53 * locales use the same these unlocalized pattern characters. |
| 55 */ | 54 */ |
| 56 static const UChar gPatternChars[] = { | 55 static const UChar gPatternChars[] = { |
| 57 // GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXx | 56 // GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXxr |
| 58 0x47, 0x79, 0x4D, 0x64, 0x6B, 0x48, 0x6D, 0x73, 0x53, 0x45, | 57 0x47, 0x79, 0x4D, 0x64, 0x6B, 0x48, 0x6D, 0x73, 0x53, 0x45, |
| 59 0x44, 0x46, 0x77, 0x57, 0x61, 0x68, 0x4B, 0x7A, 0x59, 0x65, | 58 0x44, 0x46, 0x77, 0x57, 0x61, 0x68, 0x4B, 0x7A, 0x59, 0x65, |
| 60 0x75, 0x67, 0x41, 0x5A, 0x76, 0x63, 0x4c, 0x51, 0x71, 0x56, | 59 0x75, 0x67, 0x41, 0x5A, 0x76, 0x63, 0x4c, 0x51, 0x71, 0x56, |
| 61 0x55, 0x4F, 0x58, 0x78, 0 | 60 0x55, 0x4F, 0x58, 0x78, 0x72, 0 |
| 62 }; | 61 }; |
| 63 | 62 |
| 64 /* length of an array */ | 63 /* length of an array */ |
| 65 #define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0])) | 64 #define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0])) |
| 66 | 65 |
| 67 //------------------------------------------------------ | 66 //------------------------------------------------------ |
| 68 // Strings of last resort. These are only used if we have no resource | 67 // Strings of last resort. These are only used if we have no resource |
| 69 // files. They aren't designed for actual use, just for backup. | 68 // files. They aren't designed for actual use, just for backup. |
| 70 | 69 |
| 71 // These are the month names and abbreviations of last resort. | 70 // These are the month names and abbreviations of last resort. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 150 |
| 152 #define kSUPPLEMENTAL "supplementalData" | 151 #define kSUPPLEMENTAL "supplementalData" |
| 153 | 152 |
| 154 /** | 153 /** |
| 155 * These are the tags we expect to see in normal resource bundle files associate
d | 154 * These are the tags we expect to see in normal resource bundle files associate
d |
| 156 * with a locale and calendar | 155 * with a locale and calendar |
| 157 */ | 156 */ |
| 158 static const char gErasTag[]="eras"; | 157 static const char gErasTag[]="eras"; |
| 159 static const char gCyclicNameSetsTag[]="cyclicNameSets"; | 158 static const char gCyclicNameSetsTag[]="cyclicNameSets"; |
| 160 static const char gNameSetYearsTag[]="years"; | 159 static const char gNameSetYearsTag[]="years"; |
| 160 static const char gNameSetZodiacsTag[]="zodiacs"; |
| 161 static const char gMonthNamesTag[]="monthNames"; | 161 static const char gMonthNamesTag[]="monthNames"; |
| 162 static const char gMonthPatternsTag[]="monthPatterns"; | 162 static const char gMonthPatternsTag[]="monthPatterns"; |
| 163 static const char gDayNamesTag[]="dayNames"; | 163 static const char gDayNamesTag[]="dayNames"; |
| 164 static const char gNamesWideTag[]="wide"; | 164 static const char gNamesWideTag[]="wide"; |
| 165 static const char gNamesAbbrTag[]="abbreviated"; | 165 static const char gNamesAbbrTag[]="abbreviated"; |
| 166 static const char gNamesShortTag[]="short"; | 166 static const char gNamesShortTag[]="short"; |
| 167 static const char gNamesNarrowTag[]="narrow"; | 167 static const char gNamesNarrowTag[]="narrow"; |
| 168 static const char gNamesAllTag[]="all"; | 168 static const char gNamesAllTag[]="all"; |
| 169 static const char gNamesLeapTag[]="leap"; | 169 static const char gNamesLeapTag[]="leap"; |
| 170 static const char gNamesFormatTag[]="format"; | 170 static const char gNamesFormatTag[]="format"; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 } else { | 321 } else { |
| 322 fLeapMonthPatterns = NULL; | 322 fLeapMonthPatterns = NULL; |
| 323 fLeapMonthPatternsCount = 0; | 323 fLeapMonthPatternsCount = 0; |
| 324 } | 324 } |
| 325 if (other.fShortYearNames != NULL) { | 325 if (other.fShortYearNames != NULL) { |
| 326 assignArray(fShortYearNames, fShortYearNamesCount, other.fShortYearNames
, other.fShortYearNamesCount); | 326 assignArray(fShortYearNames, fShortYearNamesCount, other.fShortYearNames
, other.fShortYearNamesCount); |
| 327 } else { | 327 } else { |
| 328 fShortYearNames = NULL; | 328 fShortYearNames = NULL; |
| 329 fShortYearNamesCount = 0; | 329 fShortYearNamesCount = 0; |
| 330 } | 330 } |
| 331 if (other.fShortZodiacNames != NULL) { |
| 332 assignArray(fShortZodiacNames, fShortZodiacNamesCount, other.fShortZodia
cNames, other.fShortZodiacNamesCount); |
| 333 } else { |
| 334 fShortZodiacNames = NULL; |
| 335 fShortZodiacNamesCount = 0; |
| 336 } |
| 331 | 337 |
| 332 if (other.fZoneStrings != NULL) { | 338 if (other.fZoneStrings != NULL) { |
| 333 fZoneStringsColCount = other.fZoneStringsColCount; | 339 fZoneStringsColCount = other.fZoneStringsColCount; |
| 334 fZoneStringsRowCount = other.fZoneStringsRowCount; | 340 fZoneStringsRowCount = other.fZoneStringsRowCount; |
| 335 createZoneStrings((const UnicodeString**)other.fZoneStrings); | 341 createZoneStrings((const UnicodeString**)other.fZoneStrings); |
| 336 | 342 |
| 337 } else { | 343 } else { |
| 338 fZoneStrings = NULL; | 344 fZoneStrings = NULL; |
| 339 fZoneStringsColCount = 0; | 345 fZoneStringsColCount = 0; |
| 340 fZoneStringsRowCount = 0; | 346 fZoneStringsRowCount = 0; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 if (fStandaloneShortWeekdays) delete[] fStandaloneShortWeekdays; | 390 if (fStandaloneShortWeekdays) delete[] fStandaloneShortWeekdays; |
| 385 if (fStandaloneShorterWeekdays) delete[] fStandaloneShorterWeekdays; | 391 if (fStandaloneShorterWeekdays) delete[] fStandaloneShorterWeekdays; |
| 386 if (fStandaloneNarrowWeekdays) delete[] fStandaloneNarrowWeekdays; | 392 if (fStandaloneNarrowWeekdays) delete[] fStandaloneNarrowWeekdays; |
| 387 if (fAmPms) delete[] fAmPms; | 393 if (fAmPms) delete[] fAmPms; |
| 388 if (fQuarters) delete[] fQuarters; | 394 if (fQuarters) delete[] fQuarters; |
| 389 if (fShortQuarters) delete[] fShortQuarters; | 395 if (fShortQuarters) delete[] fShortQuarters; |
| 390 if (fStandaloneQuarters) delete[] fStandaloneQuarters; | 396 if (fStandaloneQuarters) delete[] fStandaloneQuarters; |
| 391 if (fStandaloneShortQuarters) delete[] fStandaloneShortQuarters; | 397 if (fStandaloneShortQuarters) delete[] fStandaloneShortQuarters; |
| 392 if (fLeapMonthPatterns) delete[] fLeapMonthPatterns; | 398 if (fLeapMonthPatterns) delete[] fLeapMonthPatterns; |
| 393 if (fShortYearNames) delete[] fShortYearNames; | 399 if (fShortYearNames) delete[] fShortYearNames; |
| 400 if (fShortZodiacNames) delete[] fShortZodiacNames; |
| 394 | 401 |
| 395 disposeZoneStrings(); | 402 disposeZoneStrings(); |
| 396 } | 403 } |
| 397 | 404 |
| 398 void DateFormatSymbols::disposeZoneStrings() | 405 void DateFormatSymbols::disposeZoneStrings() |
| 399 { | 406 { |
| 400 if (fZoneStrings) { | 407 if (fZoneStrings) { |
| 401 for (int32_t row = 0; row < fZoneStringsRowCount; ++row) { | 408 for (int32_t row = 0; row < fZoneStringsRowCount; ++row) { |
| 402 delete[] fZoneStrings[row]; | 409 delete[] fZoneStrings[row]; |
| 403 } | 410 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 fStandaloneShortWeekdaysCount == other.fStandaloneShortWeekdaysCount && | 461 fStandaloneShortWeekdaysCount == other.fStandaloneShortWeekdaysCount && |
| 455 fStandaloneShorterWeekdaysCount == other.fStandaloneShorterWeekdaysCount
&& | 462 fStandaloneShorterWeekdaysCount == other.fStandaloneShorterWeekdaysCount
&& |
| 456 fStandaloneNarrowWeekdaysCount == other.fStandaloneNarrowWeekdaysCount &
& | 463 fStandaloneNarrowWeekdaysCount == other.fStandaloneNarrowWeekdaysCount &
& |
| 457 fAmPmsCount == other.fAmPmsCount && | 464 fAmPmsCount == other.fAmPmsCount && |
| 458 fQuartersCount == other.fQuartersCount && | 465 fQuartersCount == other.fQuartersCount && |
| 459 fShortQuartersCount == other.fShortQuartersCount && | 466 fShortQuartersCount == other.fShortQuartersCount && |
| 460 fStandaloneQuartersCount == other.fStandaloneQuartersCount && | 467 fStandaloneQuartersCount == other.fStandaloneQuartersCount && |
| 461 fStandaloneShortQuartersCount == other.fStandaloneShortQuartersCount && | 468 fStandaloneShortQuartersCount == other.fStandaloneShortQuartersCount && |
| 462 fLeapMonthPatternsCount == other.fLeapMonthPatternsCount && | 469 fLeapMonthPatternsCount == other.fLeapMonthPatternsCount && |
| 463 fShortYearNamesCount == other.fShortYearNamesCount && | 470 fShortYearNamesCount == other.fShortYearNamesCount && |
| 471 fShortZodiacNamesCount == other.fShortZodiacNamesCount && |
| 464 (uprv_memcmp(fCapitalization, other.fCapitalization, sizeof(fCapitalizat
ion))==0)) | 472 (uprv_memcmp(fCapitalization, other.fCapitalization, sizeof(fCapitalizat
ion))==0)) |
| 465 { | 473 { |
| 466 // Now compare the arrays themselves | 474 // Now compare the arrays themselves |
| 467 if (arrayCompare(fEras, other.fEras, fErasCount) && | 475 if (arrayCompare(fEras, other.fEras, fErasCount) && |
| 468 arrayCompare(fEraNames, other.fEraNames, fEraNamesCount) && | 476 arrayCompare(fEraNames, other.fEraNames, fEraNamesCount) && |
| 469 arrayCompare(fNarrowEras, other.fNarrowEras, fNarrowErasCount) && | 477 arrayCompare(fNarrowEras, other.fNarrowEras, fNarrowErasCount) && |
| 470 arrayCompare(fMonths, other.fMonths, fMonthsCount) && | 478 arrayCompare(fMonths, other.fMonths, fMonthsCount) && |
| 471 arrayCompare(fShortMonths, other.fShortMonths, fShortMonthsCount) && | 479 arrayCompare(fShortMonths, other.fShortMonths, fShortMonthsCount) && |
| 472 arrayCompare(fNarrowMonths, other.fNarrowMonths, fNarrowMonthsCount)
&& | 480 arrayCompare(fNarrowMonths, other.fNarrowMonths, fNarrowMonthsCount)
&& |
| 473 arrayCompare(fStandaloneMonths, other.fStandaloneMonths, fStandalone
MonthsCount) && | 481 arrayCompare(fStandaloneMonths, other.fStandaloneMonths, fStandalone
MonthsCount) && |
| 474 arrayCompare(fStandaloneShortMonths, other.fStandaloneShortMonths, f
StandaloneShortMonthsCount) && | 482 arrayCompare(fStandaloneShortMonths, other.fStandaloneShortMonths, f
StandaloneShortMonthsCount) && |
| 475 arrayCompare(fStandaloneNarrowMonths, other.fStandaloneNarrowMonths,
fStandaloneNarrowMonthsCount) && | 483 arrayCompare(fStandaloneNarrowMonths, other.fStandaloneNarrowMonths,
fStandaloneNarrowMonthsCount) && |
| 476 arrayCompare(fWeekdays, other.fWeekdays, fWeekdaysCount) && | 484 arrayCompare(fWeekdays, other.fWeekdays, fWeekdaysCount) && |
| 477 arrayCompare(fShortWeekdays, other.fShortWeekdays, fShortWeekdaysCou
nt) && | 485 arrayCompare(fShortWeekdays, other.fShortWeekdays, fShortWeekdaysCou
nt) && |
| 478 arrayCompare(fShorterWeekdays, other.fShorterWeekdays, fShorterWeekd
aysCount) && | 486 arrayCompare(fShorterWeekdays, other.fShorterWeekdays, fShorterWeekd
aysCount) && |
| 479 arrayCompare(fNarrowWeekdays, other.fNarrowWeekdays, fNarrowWeekdays
Count) && | 487 arrayCompare(fNarrowWeekdays, other.fNarrowWeekdays, fNarrowWeekdays
Count) && |
| 480 arrayCompare(fStandaloneWeekdays, other.fStandaloneWeekdays, fStanda
loneWeekdaysCount) && | 488 arrayCompare(fStandaloneWeekdays, other.fStandaloneWeekdays, fStanda
loneWeekdaysCount) && |
| 481 arrayCompare(fStandaloneShortWeekdays, other.fStandaloneShortWeekday
s, fStandaloneShortWeekdaysCount) && | 489 arrayCompare(fStandaloneShortWeekdays, other.fStandaloneShortWeekday
s, fStandaloneShortWeekdaysCount) && |
| 482 arrayCompare(fStandaloneShorterWeekdays, other.fStandaloneShorterWee
kdays, fStandaloneShorterWeekdaysCount) && | 490 arrayCompare(fStandaloneShorterWeekdays, other.fStandaloneShorterWee
kdays, fStandaloneShorterWeekdaysCount) && |
| 483 arrayCompare(fStandaloneNarrowWeekdays, other.fStandaloneNarrowWeekd
ays, fStandaloneNarrowWeekdaysCount) && | 491 arrayCompare(fStandaloneNarrowWeekdays, other.fStandaloneNarrowWeekd
ays, fStandaloneNarrowWeekdaysCount) && |
| 484 arrayCompare(fAmPms, other.fAmPms, fAmPmsCount) && | 492 arrayCompare(fAmPms, other.fAmPms, fAmPmsCount) && |
| 485 arrayCompare(fQuarters, other.fQuarters, fQuartersCount) && | 493 arrayCompare(fQuarters, other.fQuarters, fQuartersCount) && |
| 486 arrayCompare(fShortQuarters, other.fShortQuarters, fShortQuartersCou
nt) && | 494 arrayCompare(fShortQuarters, other.fShortQuarters, fShortQuartersCou
nt) && |
| 487 arrayCompare(fStandaloneQuarters, other.fStandaloneQuarters, fStanda
loneQuartersCount) && | 495 arrayCompare(fStandaloneQuarters, other.fStandaloneQuarters, fStanda
loneQuartersCount) && |
| 488 arrayCompare(fStandaloneShortQuarters, other.fStandaloneShortQuarter
s, fStandaloneShortQuartersCount) && | 496 arrayCompare(fStandaloneShortQuarters, other.fStandaloneShortQuarter
s, fStandaloneShortQuartersCount) && |
| 489 arrayCompare(fLeapMonthPatterns, other.fLeapMonthPatterns, fLeapMont
hPatternsCount) && | 497 arrayCompare(fLeapMonthPatterns, other.fLeapMonthPatterns, fLeapMont
hPatternsCount) && |
| 490 arrayCompare(fShortYearNames, other.fShortYearNames, fShortYearNames
Count)) | 498 arrayCompare(fShortYearNames, other.fShortYearNames, fShortYearNames
Count) && |
| 499 arrayCompare(fShortZodiacNames, other.fShortZodiacNames, fShortZodia
cNamesCount)) |
| 491 { | 500 { |
| 492 // Compare the contents of fZoneStrings | 501 // Compare the contents of fZoneStrings |
| 493 if (fZoneStrings == NULL && other.fZoneStrings == NULL) { | 502 if (fZoneStrings == NULL && other.fZoneStrings == NULL) { |
| 494 if (fZSFLocale == other.fZSFLocale) { | 503 if (fZSFLocale == other.fZSFLocale) { |
| 495 return TRUE; | 504 return TRUE; |
| 496 } | 505 } |
| 497 } else if (fZoneStrings != NULL && other.fZoneStrings != NULL) { | 506 } else if (fZoneStrings != NULL && other.fZoneStrings != NULL) { |
| 498 if (fZoneStringsRowCount == other.fZoneStringsRowCount | 507 if (fZoneStringsRowCount == other.fZoneStringsRowCount |
| 499 && fZoneStringsColCount == other.fZoneStringsColCount) { | 508 && fZoneStringsColCount == other.fZoneStringsColCount) { |
| 500 UBool cmpres = TRUE; | 509 UBool cmpres = TRUE; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 return fAmPms; | 732 return fAmPms; |
| 724 } | 733 } |
| 725 | 734 |
| 726 const UnicodeString* | 735 const UnicodeString* |
| 727 DateFormatSymbols::getLeapMonthPatterns(int32_t &count) const | 736 DateFormatSymbols::getLeapMonthPatterns(int32_t &count) const |
| 728 { | 737 { |
| 729 count = fLeapMonthPatternsCount; | 738 count = fLeapMonthPatternsCount; |
| 730 return fLeapMonthPatterns; | 739 return fLeapMonthPatterns; |
| 731 } | 740 } |
| 732 | 741 |
| 742 const UnicodeString* |
| 743 DateFormatSymbols::getYearNames(int32_t& count, |
| 744 DtContextType /*ignored*/, DtWidthType /*ignored
*/) const |
| 745 { |
| 746 count = fShortYearNamesCount; |
| 747 return fShortYearNames; |
| 748 } |
| 749 |
| 750 void |
| 751 DateFormatSymbols::setYearNames(const UnicodeString* yearNames, int32_t count, |
| 752 DtContextType context, DtWidthType width) |
| 753 { |
| 754 if (context == FORMAT && width == ABBREVIATED) { |
| 755 if (fShortYearNames) { |
| 756 delete[] fShortYearNames; |
| 757 } |
| 758 fShortYearNames = newUnicodeStringArray(count); |
| 759 uprv_arrayCopy(yearNames, fShortYearNames, count); |
| 760 fShortYearNamesCount = count; |
| 761 } |
| 762 } |
| 763 |
| 764 const UnicodeString* |
| 765 DateFormatSymbols::getZodiacNames(int32_t& count, |
| 766 DtContextType /*ignored*/, DtWidthType /*ignored
*/) const |
| 767 { |
| 768 count = fShortZodiacNamesCount; |
| 769 return fShortZodiacNames; |
| 770 } |
| 771 |
| 772 void |
| 773 DateFormatSymbols::setZodiacNames(const UnicodeString* zodiacNames, int32_t coun
t, |
| 774 DtContextType context, DtWidthType width) |
| 775 { |
| 776 if (context == FORMAT && width == ABBREVIATED) { |
| 777 if (fShortZodiacNames) { |
| 778 delete[] fShortZodiacNames; |
| 779 } |
| 780 fShortZodiacNames = newUnicodeStringArray(count); |
| 781 uprv_arrayCopy(zodiacNames, fShortZodiacNames, count); |
| 782 fShortZodiacNamesCount = count; |
| 783 } |
| 784 } |
| 785 |
| 733 //------------------------------------------------------ | 786 //------------------------------------------------------ |
| 734 | 787 |
| 735 void | 788 void |
| 736 DateFormatSymbols::setEras(const UnicodeString* erasArray, int32_t count) | 789 DateFormatSymbols::setEras(const UnicodeString* erasArray, int32_t count) |
| 737 { | 790 { |
| 738 // delete the old list if we own it | 791 // delete the old list if we own it |
| 739 if (fEras) | 792 if (fEras) |
| 740 delete[] fEras; | 793 delete[] fEras; |
| 741 | 794 |
| 742 // we always own the new list, which we create here (we duplicate rather | 795 // we always own the new list, which we create here (we duplicate rather |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 UDateFormatField U_EXPORT2 | 1244 UDateFormatField U_EXPORT2 |
| 1192 DateFormatSymbols::getPatternCharIndex(UChar c) { | 1245 DateFormatSymbols::getPatternCharIndex(UChar c) { |
| 1193 const UChar *p = u_strchr(gPatternChars, c); | 1246 const UChar *p = u_strchr(gPatternChars, c); |
| 1194 if (p == NULL) { | 1247 if (p == NULL) { |
| 1195 return UDAT_FIELD_COUNT; | 1248 return UDAT_FIELD_COUNT; |
| 1196 } else { | 1249 } else { |
| 1197 return static_cast<UDateFormatField>(p - gPatternChars); | 1250 return static_cast<UDateFormatField>(p - gPatternChars); |
| 1198 } | 1251 } |
| 1199 } | 1252 } |
| 1200 | 1253 |
| 1201 static const uint32_t kNumericFields = | 1254 static const uint64_t kNumericFieldsAlways = |
| 1202 ((uint32_t)1 << UDAT_YEAR_FIELD) | // y | 1255 ((uint64_t)1 << UDAT_YEAR_FIELD) | // y |
| 1203 ((uint32_t)1 << UDAT_MONTH_FIELD) | // M or MM | 1256 ((uint64_t)1 << UDAT_DATE_FIELD) | // d |
| 1204 ((uint32_t)1 << UDAT_DATE_FIELD) | // d | 1257 ((uint64_t)1 << UDAT_HOUR_OF_DAY1_FIELD) | // k |
| 1205 ((uint32_t)1 << UDAT_HOUR_OF_DAY1_FIELD) | // k | 1258 ((uint64_t)1 << UDAT_HOUR_OF_DAY0_FIELD) | // H |
| 1206 ((uint32_t)1 << UDAT_HOUR_OF_DAY0_FIELD) | // H | 1259 ((uint64_t)1 << UDAT_MINUTE_FIELD) | // m |
| 1207 ((uint32_t)1 << UDAT_MINUTE_FIELD) | // m | 1260 ((uint64_t)1 << UDAT_SECOND_FIELD) | // s |
| 1208 ((uint32_t)1 << UDAT_SECOND_FIELD) | // s | 1261 ((uint64_t)1 << UDAT_FRACTIONAL_SECOND_FIELD) | // S |
| 1209 ((uint32_t)1 << UDAT_FRACTIONAL_SECOND_FIELD) | // S | 1262 ((uint64_t)1 << UDAT_DAY_OF_YEAR_FIELD) | // D |
| 1210 ((uint32_t)1 << UDAT_DAY_OF_YEAR_FIELD) | // D | 1263 ((uint64_t)1 << UDAT_DAY_OF_WEEK_IN_MONTH_FIELD) | // F |
| 1211 ((uint32_t)1 << UDAT_DAY_OF_WEEK_IN_MONTH_FIELD) | // F | 1264 ((uint64_t)1 << UDAT_WEEK_OF_YEAR_FIELD) | // w |
| 1212 ((uint32_t)1 << UDAT_WEEK_OF_YEAR_FIELD) | // w | 1265 ((uint64_t)1 << UDAT_WEEK_OF_MONTH_FIELD) | // W |
| 1213 ((uint32_t)1 << UDAT_WEEK_OF_MONTH_FIELD) | // W | 1266 ((uint64_t)1 << UDAT_HOUR1_FIELD) | // h |
| 1214 ((uint32_t)1 << UDAT_HOUR1_FIELD) | // h | 1267 ((uint64_t)1 << UDAT_HOUR0_FIELD) | // K |
| 1215 ((uint32_t)1 << UDAT_HOUR0_FIELD) | // K | 1268 ((uint64_t)1 << UDAT_YEAR_WOY_FIELD) | // Y |
| 1216 ((uint32_t)1 << UDAT_YEAR_WOY_FIELD) | // Y | 1269 ((uint64_t)1 << UDAT_EXTENDED_YEAR_FIELD) | // u |
| 1217 ((uint32_t)1 << UDAT_DOW_LOCAL_FIELD) | // e | 1270 ((uint64_t)1 << UDAT_JULIAN_DAY_FIELD) | // g |
| 1218 ((uint32_t)1 << UDAT_EXTENDED_YEAR_FIELD); // u | 1271 ((uint64_t)1 << UDAT_MILLISECONDS_IN_DAY_FIELD) | // A |
| 1272 ((uint64_t)1 << UDAT_RELATED_YEAR_FIELD); // r |
| 1273 |
| 1274 static const uint64_t kNumericFieldsForCount12 = |
| 1275 ((uint64_t)1 << UDAT_MONTH_FIELD) | // M or MM |
| 1276 ((uint64_t)1 << UDAT_DOW_LOCAL_FIELD) | // e or ee |
| 1277 ((uint64_t)1 << UDAT_STANDALONE_DAY_FIELD) | // c or cc |
| 1278 ((uint64_t)1 << UDAT_STANDALONE_MONTH_FIELD) | // L or LL |
| 1279 ((uint64_t)1 << UDAT_QUARTER_FIELD) | // Q or QQ |
| 1280 ((uint64_t)1 << UDAT_STANDALONE_QUARTER_FIELD); // q or qq |
| 1219 | 1281 |
| 1220 UBool U_EXPORT2 | 1282 UBool U_EXPORT2 |
| 1221 DateFormatSymbols::isNumericField(UDateFormatField f, int32_t count) { | 1283 DateFormatSymbols::isNumericField(UDateFormatField f, int32_t count) { |
| 1222 return | 1284 if (f == UDAT_FIELD_COUNT) { |
| 1223 f != UDAT_FIELD_COUNT && | 1285 return FALSE; |
| 1224 (kNumericFields & ((uint32_t)1 << f)) != 0 && | 1286 } |
| 1225 (f != UDAT_MONTH_FIELD || count < 3); | 1287 uint64_t flag = ((uint64_t)1 << f); |
| 1288 return ((kNumericFieldsAlways & flag) != 0 || ((kNumericFieldsForCount12 & f
lag) != 0 && count < 3)); |
| 1226 } | 1289 } |
| 1227 | 1290 |
| 1228 UBool U_EXPORT2 | 1291 UBool U_EXPORT2 |
| 1229 DateFormatSymbols::isNumericPatternChar(UChar c, int32_t count) { | 1292 DateFormatSymbols::isNumericPatternChar(UChar c, int32_t count) { |
| 1230 return isNumericField(getPatternCharIndex(c), count); | 1293 return isNumericField(getPatternCharIndex(c), count); |
| 1231 } | 1294 } |
| 1232 | 1295 |
| 1233 //------------------------------------------------------ | 1296 //------------------------------------------------------ |
| 1234 | 1297 |
| 1235 UnicodeString& | 1298 UnicodeString& |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 fShortQuarters = NULL; | 1435 fShortQuarters = NULL; |
| 1373 fShortQuartersCount = 0; | 1436 fShortQuartersCount = 0; |
| 1374 fStandaloneQuarters = NULL; | 1437 fStandaloneQuarters = NULL; |
| 1375 fStandaloneQuartersCount = 0; | 1438 fStandaloneQuartersCount = 0; |
| 1376 fStandaloneShortQuarters = NULL; | 1439 fStandaloneShortQuarters = NULL; |
| 1377 fStandaloneShortQuartersCount = 0; | 1440 fStandaloneShortQuartersCount = 0; |
| 1378 fLeapMonthPatterns = NULL; | 1441 fLeapMonthPatterns = NULL; |
| 1379 fLeapMonthPatternsCount = 0; | 1442 fLeapMonthPatternsCount = 0; |
| 1380 fShortYearNames = NULL; | 1443 fShortYearNames = NULL; |
| 1381 fShortYearNamesCount = 0; | 1444 fShortYearNamesCount = 0; |
| 1445 fShortZodiacNames = NULL; |
| 1446 fShortZodiacNamesCount = 0; |
| 1382 fZoneStringsRowCount = 0; | 1447 fZoneStringsRowCount = 0; |
| 1383 fZoneStringsColCount = 0; | 1448 fZoneStringsColCount = 0; |
| 1384 fZoneStrings = NULL; | 1449 fZoneStrings = NULL; |
| 1385 fLocaleZoneStrings = NULL; | 1450 fLocaleZoneStrings = NULL; |
| 1386 uprv_memset(fCapitalization, 0, sizeof(fCapitalization)); | 1451 uprv_memset(fCapitalization, 0, sizeof(fCapitalization)); |
| 1387 | 1452 |
| 1388 // We need to preserve the requested locale for | 1453 // We need to preserve the requested locale for |
| 1389 // lazy ZoneStringFormat instantiation. ZoneStringFormat | 1454 // lazy ZoneStringFormat instantiation. ZoneStringFormat |
| 1390 // is region sensitive, thus, bundle locale bundle's locale | 1455 // is region sensitive, thus, bundle locale bundle's locale |
| 1391 // is not sufficient. | 1456 // is not sufficient. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 fLeapMonthPatterns = newUnicodeStringArray(kMonthPatternsCount); | 1488 fLeapMonthPatterns = newUnicodeStringArray(kMonthPatternsCount); |
| 1424 if (fLeapMonthPatterns) { | 1489 if (fLeapMonthPatterns) { |
| 1425 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternFormatWide
, calData.getByKey2(gMonthPatternsTag, gNamesWideTag, tempStatus), tempStatus); | 1490 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternFormatWide
, calData.getByKey2(gMonthPatternsTag, gNamesWideTag, tempStatus), tempStatus); |
| 1426 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternFormatAbbr
ev, calData.getByKey2(gMonthPatternsTag, gNamesAbbrTag, tempStatus), tempStatus)
; | 1491 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternFormatAbbr
ev, calData.getByKey2(gMonthPatternsTag, gNamesAbbrTag, tempStatus), tempStatus)
; |
| 1427 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternFormatNarr
ow, calData.getByKey2(gMonthPatternsTag, gNamesNarrowTag, tempStatus), tempStatu
s); | 1492 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternFormatNarr
ow, calData.getByKey2(gMonthPatternsTag, gNamesNarrowTag, tempStatus), tempStatu
s); |
| 1428 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternStandalone
Wide, calData.getByKey3(gMonthPatternsTag, gNamesStandaloneTag, gNamesWideTag, t
empStatus), tempStatus); | 1493 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternStandalone
Wide, calData.getByKey3(gMonthPatternsTag, gNamesStandaloneTag, gNamesWideTag, t
empStatus), tempStatus); |
| 1429 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternStandalone
Abbrev, calData.getByKey3(gMonthPatternsTag, gNamesStandaloneTag, gNamesAbbrTag,
tempStatus), tempStatus); | 1494 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternStandalone
Abbrev, calData.getByKey3(gMonthPatternsTag, gNamesStandaloneTag, gNamesAbbrTag,
tempStatus), tempStatus); |
| 1430 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternStandalone
Narrow, calData.getByKey3(gMonthPatternsTag, gNamesStandaloneTag, gNamesNarrowTa
g, tempStatus), tempStatus); | 1495 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternStandalone
Narrow, calData.getByKey3(gMonthPatternsTag, gNamesStandaloneTag, gNamesNarrowTa
g, tempStatus), tempStatus); |
| 1431 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternNumeric, c
alData.getByKey3(gMonthPatternsTag, gNamesNumericTag, gNamesAllTag, tempStatus),
tempStatus); | 1496 initLeapMonthPattern(fLeapMonthPatterns, kLeapMonthPatternNumeric, c
alData.getByKey3(gMonthPatternsTag, gNamesNumericTag, gNamesAllTag, tempStatus),
tempStatus); |
| 1432 if (U_SUCCESS(tempStatus)) { | 1497 if (U_SUCCESS(tempStatus)) { |
| 1498 // Hack to fix bad C inheritance for dangi monthPatterns (OK in
J); this should be handled by aliases in root, but isn't. |
| 1499 // The ordering of the following statements is important. |
| 1500 if (fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev].isEmpty())
{ |
| 1501 fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev].setTo(fLea
pMonthPatterns[kLeapMonthPatternFormatWide]); |
| 1502 }; |
| 1503 if (fLeapMonthPatterns[kLeapMonthPatternFormatNarrow].isEmpty())
{ |
| 1504 fLeapMonthPatterns[kLeapMonthPatternFormatNarrow].setTo(fLea
pMonthPatterns[kLeapMonthPatternStandaloneNarrow]); |
| 1505 }; |
| 1506 if (fLeapMonthPatterns[kLeapMonthPatternStandaloneWide].isEmpty(
)) { |
| 1507 fLeapMonthPatterns[kLeapMonthPatternStandaloneWide].setTo(fL
eapMonthPatterns[kLeapMonthPatternFormatWide]); |
| 1508 }; |
| 1509 if (fLeapMonthPatterns[kLeapMonthPatternStandaloneAbbrev].isEmpt
y()) { |
| 1510 fLeapMonthPatterns[kLeapMonthPatternStandaloneAbbrev].setTo(
fLeapMonthPatterns[kLeapMonthPatternFormatAbbrev]); |
| 1511 }; |
| 1512 // end of hack |
| 1433 fLeapMonthPatternsCount = kMonthPatternsCount; | 1513 fLeapMonthPatternsCount = kMonthPatternsCount; |
| 1434 } else { | 1514 } else { |
| 1435 delete[] fLeapMonthPatterns; | 1515 delete[] fLeapMonthPatterns; |
| 1436 fLeapMonthPatterns = NULL; | 1516 fLeapMonthPatterns = NULL; |
| 1437 } | 1517 } |
| 1438 } | 1518 } |
| 1439 } | 1519 } |
| 1440 | 1520 |
| 1441 tempStatus = U_ZERO_ERROR; | 1521 tempStatus = U_ZERO_ERROR; |
| 1442 UResourceBundle *cyclicNameSets= calData.getByKey(gCyclicNameSetsTag, tempSt
atus); | 1522 UResourceBundle *cyclicNameSets= calData.getByKey(gCyclicNameSetsTag, tempSt
atus); |
| 1443 if (U_SUCCESS(tempStatus) && cyclicNameSets != NULL) { | 1523 if (U_SUCCESS(tempStatus) && cyclicNameSets != NULL) { |
| 1444 UResourceBundle *nameSetYears = ures_getByKeyWithFallback(cyclicNameSets
, gNameSetYearsTag, NULL, &tempStatus); | 1524 UResourceBundle *nameSetYears = ures_getByKeyWithFallback(cyclicNameSets
, gNameSetYearsTag, NULL, &tempStatus); |
| 1445 if (U_SUCCESS(tempStatus)) { | 1525 if (U_SUCCESS(tempStatus)) { |
| 1446 UResourceBundle *nameSetYearsFmt = ures_getByKeyWithFallback(nameSet
Years, gNamesFormatTag, NULL, &tempStatus); | 1526 UResourceBundle *nameSetYearsFmt = ures_getByKeyWithFallback(nameSet
Years, gNamesFormatTag, NULL, &tempStatus); |
| 1447 if (U_SUCCESS(tempStatus)) { | 1527 if (U_SUCCESS(tempStatus)) { |
| 1448 UResourceBundle *nameSetYearsFmtAbbrev = ures_getByKeyWithFallba
ck(nameSetYearsFmt, gNamesAbbrTag, NULL, &tempStatus); | 1528 UResourceBundle *nameSetYearsFmtAbbrev = ures_getByKeyWithFallba
ck(nameSetYearsFmt, gNamesAbbrTag, NULL, &tempStatus); |
| 1449 if (U_SUCCESS(tempStatus)) { | 1529 if (U_SUCCESS(tempStatus)) { |
| 1450 initField(&fShortYearNames, fShortYearNamesCount, nameSetYea
rsFmtAbbrev, tempStatus); | 1530 initField(&fShortYearNames, fShortYearNamesCount, nameSetYea
rsFmtAbbrev, tempStatus); |
| 1451 ures_close(nameSetYearsFmtAbbrev); | 1531 ures_close(nameSetYearsFmtAbbrev); |
| 1452 } | 1532 } |
| 1453 ures_close(nameSetYearsFmt); | 1533 ures_close(nameSetYearsFmt); |
| 1454 } | 1534 } |
| 1455 ures_close(nameSetYears); | 1535 ures_close(nameSetYears); |
| 1456 } | 1536 } |
| 1537 UResourceBundle *nameSetZodiacs = ures_getByKeyWithFallback(cyclicNameSe
ts, gNameSetZodiacsTag, NULL, &tempStatus); |
| 1538 if (U_SUCCESS(tempStatus)) { |
| 1539 UResourceBundle *nameSetZodiacsFmt = ures_getByKeyWithFallback(nameS
etZodiacs, gNamesFormatTag, NULL, &tempStatus); |
| 1540 if (U_SUCCESS(tempStatus)) { |
| 1541 UResourceBundle *nameSetZodiacsFmtAbbrev = ures_getByKeyWithFall
back(nameSetZodiacsFmt, gNamesAbbrTag, NULL, &tempStatus); |
| 1542 if (U_SUCCESS(tempStatus)) { |
| 1543 initField(&fShortZodiacNames, fShortZodiacNamesCount, nameSe
tZodiacsFmtAbbrev, tempStatus); |
| 1544 ures_close(nameSetZodiacsFmtAbbrev); |
| 1545 } |
| 1546 ures_close(nameSetZodiacsFmt); |
| 1547 } |
| 1548 ures_close(nameSetZodiacs); |
| 1549 } |
| 1457 } | 1550 } |
| 1458 | 1551 |
| 1459 tempStatus = U_ZERO_ERROR; | 1552 tempStatus = U_ZERO_ERROR; |
| 1460 UResourceBundle *localeBundle = ures_open(NULL, locale.getName(), &tempStatu
s); | 1553 UResourceBundle *localeBundle = ures_open(NULL, locale.getName(), &tempStatu
s); |
| 1461 if (U_SUCCESS(tempStatus)) { | 1554 if (U_SUCCESS(tempStatus)) { |
| 1462 UResourceBundle *contextTransforms = ures_getByKeyWithFallback(localeBun
dle, gContextTransformsTag, NULL, &tempStatus); | 1555 UResourceBundle *contextTransforms = ures_getByKeyWithFallback(localeBun
dle, gContextTransformsTag, NULL, &tempStatus); |
| 1463 if (U_SUCCESS(tempStatus)) { | 1556 if (U_SUCCESS(tempStatus)) { |
| 1464 UResourceBundle *contextTransformUsage; | 1557 UResourceBundle *contextTransformUsage; |
| 1465 while ( (contextTransformUsage = ures_getNextResource(contextTransfo
rms, NULL, &tempStatus)) != NULL ) { | 1558 while ( (contextTransformUsage = ures_getNextResource(contextTransfo
rms, NULL, &tempStatus)) != NULL ) { |
| 1466 const int32_t * intVector = ures_getIntVector(contextTransformUs
age, &len, &status); | 1559 const int32_t * intVector = ures_getIntVector(contextTransformUs
age, &len, &status); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 DateFormatSymbols::getLocale(ULocDataLocaleType type, UErrorCode& status) const
{ | 1879 DateFormatSymbols::getLocale(ULocDataLocaleType type, UErrorCode& status) const
{ |
| 1787 U_LOCALE_BASED(locBased, *this); | 1880 U_LOCALE_BASED(locBased, *this); |
| 1788 return locBased.getLocale(type, status); | 1881 return locBased.getLocale(type, status); |
| 1789 } | 1882 } |
| 1790 | 1883 |
| 1791 U_NAMESPACE_END | 1884 U_NAMESPACE_END |
| 1792 | 1885 |
| 1793 #endif /* #if !UCONFIG_NO_FORMATTING */ | 1886 #endif /* #if !UCONFIG_NO_FORMATTING */ |
| 1794 | 1887 |
| 1795 //eof | 1888 //eof |
| OLD | NEW |