1 /* 2 ******************************************************************************** 3 * Copyright (C) 1997-2012, International Business Machines 4 * Corporation and others. All Rights Reserved. 5 ******************************************************************************** 6 * 7 * File DTFMTSYM.H 8 * 9 * Modification History: 10 * 11 * Date Name Description 12 * 02/19/97 aliu Converted from java. 13 * 07/21/98 stephen Added getZoneIndex() 14 * Changed to match C++ conventions 15 ******************************************************************************** 16 */ 17 18 #ifndef DTFMTSYM_H 19 #define DTFMTSYM_H 20 21 #include "unicode/utypes.h" 22 23 #if !UCONFIG_NO_FORMATTING 24 25 #include "unicode/calendar.h" 26 #include "unicode/uobject.h" 27 #include "unicode/locid.h" 28 #include "unicode/udat.h" 29 #include "unicode/ures.h" 30 31 /** 32 * \file 33 * \brief C++ API: Symbols for formatting dates. 34 */ 35 36 U_NAMESPACE_BEGIN 37 38 /* forward declaration */ 39 class SimpleDateFormat; 40 class Hashtable; 41 42 /** 43 * DateFormatSymbols is a public class for encapsulating localizable date-time 44 * formatting data -- including timezone data. DateFormatSymbols is used by 45 * DateFormat and SimpleDateFormat. 46 * <P> 47 * Rather than first creating a DateFormatSymbols to get a date-time formatter 48 * by using a SimpleDateFormat constructor, clients are encouraged to create a 49 * date-time formatter using the getTimeInstance(), getDateInstance(), or 50 * getDateTimeInstance() method in DateFormat. Each of these methods can return a 51 * date/time formatter initialized with a default format pattern along with the 52 * date-time formatting data for a given or default locale. After a formatter is 53 * created, clients may modify the format pattern using the setPattern function 54 * as so desired. For more information on using these formatter factory 55 * functions, see DateFormat. 56 * <P> 57 * If clients decide to create a date-time formatter with a particular format 58 * pattern and locale, they can do so with new SimpleDateFormat(aPattern, 59 * new DateFormatSymbols(aLocale)). This will load the appropriate date-time 60 * formatting data from the locale. 61 * <P> 62 * DateFormatSymbols objects are clonable. When clients obtain a 63 * DateFormatSymbols object, they can feel free to modify the date-time 64 * formatting data as necessary. For instance, clients can 65 * replace the localized date-time format pattern characters with the ones that 66 * they feel easy to remember. Or they can change the representative cities 67 * originally picked by default to using their favorite ones. 68 * <P> 69 * DateFormatSymbols are not expected to be subclassed. Data for a calendar is 70 * loaded out of resource bundles. The 'type' parameter indicates the type of 71 * calendar, for example, "gregorian" or "japanese". If the type is not gregorian 72 * (or NULL, or an empty string) then the type is appended to the resource name, 73 * for example, 'Eras_japanese' instead of 'Eras'. If the resource 'Eras_japanese' did 74 * not exist (even in root), then this class will fall back to just 'Eras', that is, 75 * Gregorian data. Therefore, the calendar implementor MUST ensure that the root 76 * locale at least contains any resources that are to be particularized for the 77 * calendar type. 78 */ 79 class U_I18N_API DateFormatSymbols : public UObject { 80 public: 81 /** 82 * Construct a DateFormatSymbols object by loading format data from 83 * resources for the default locale, in the default calendar (Gregorian). 84 * <P> 85 * NOTE: This constructor will never fail; if it cannot get resource 86 * data for the default locale, it will return a last-resort object 87 * based on hard-coded strings. 88 * 89 * @param status Status code. Failure 90 * results if the resources for the default cannot be 91 * found or cannot be loaded 92 * @stable ICU 2.0 93 */ 94 DateFormatSymbols(UErrorCode& status); 95 96 /** 97 * Construct a DateFormatSymbols object by loading format data from 98 * resources for the given locale, in the default calendar (Gregorian). 99 * 100 * @param locale Locale to load format data from. 101 * @param status Status code. Failure 102 * results if the resources for the locale cannot be 103 * found or cannot be loaded 104 * @stable ICU 2.0 105 */ 106 DateFormatSymbols(const Locale& locale, 107 UErrorCode& status); 108 109 #ifndef U_HIDE_INTERNAL_API 110 /** 111 * Construct a DateFormatSymbols object by loading format data from 112 * resources for the default locale, in the default calendar (Gregorian). 113 * <P> 114 * NOTE: This constructor will never fail; if it cannot get resource 115 * data for the default locale, it will return a last-resort object 116 * based on hard-coded strings. 117 * 118 * @param type Type of calendar (as returned by Calendar::getType). 119 * Will be used to access the correct set of strings. 120 * (NULL or empty string defaults to "gregorian".) 121 * @param status Status code. Failure 122 * results if the resources for the default cannot be 123 * found or cannot be loaded 124 * @internal 125 */ 126 DateFormatSymbols(const char *type, UErrorCode& status); 127 128 /** 129 * Construct a DateFormatSymbols object by loading format data from 130 * resources for the given locale, in the default calendar (Gregorian). 131 * 132 * @param locale Locale to load format data from. 133 * @param type Type of calendar (as returned by Calendar::getType). 134 * Will be used to access the correct set of strings. 135 * (NULL or empty string defaults to "gregorian".) 136 * @param status Status code. Failure 137 * results if the resources for the locale cannot be 138 * found or cannot be loaded 139 * @internal 140 */ 141 DateFormatSymbols(const Locale& locale, 142 const char *type, 143 UErrorCode& status); 144 #endif /* U_HIDE_INTERNAL_API */ 145 146 /** 147 * Copy constructor. 148 * @stable ICU 2.0 149 */ 150 DateFormatSymbols(const DateFormatSymbols&); 151 152 /** 153 * Assignment operator. 154 * @stable ICU 2.0 155 */ 156 DateFormatSymbols& operator=(const DateFormatSymbols&); 157 158 /** 159 * Destructor. This is nonvirtual because this class is not designed to be 160 * subclassed. 161 * @stable ICU 2.0 162 */ 163 virtual ~DateFormatSymbols(); 164 165 /** 166 * Return true if another object is semantically equal to this one. 167 * 168 * @param other the DateFormatSymbols object to be compared with. 169 * @return true if other is semantically equal to this. 170 * @stable ICU 2.0 171 */ 172 UBool operator==(const DateFormatSymbols& other) const; 173 174 /** 175 * Return true if another object is semantically unequal to this one. 176 * 177 * @param other the DateFormatSymbols object to be compared with. 178 * @return true if other is semantically unequal to this. 179 * @stable ICU 2.0 180 */ 181 UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); } 182 183 /** 184 * Gets abbreviated era strings. For example: "AD" and "BC". 185 * 186 * @param count Filled in with length of the array. 187 * @return the era strings. 188 * @stable ICU 2.0 189 */ 190 const UnicodeString* getEras(int32_t& count) const; 191 192 /** 193 * Sets abbreviated era strings. For example: "AD" and "BC". 194 * @param eras Array of era strings (DateFormatSymbols retains ownership.) 195 * @param count Filled in with length of the array. 196 * @stable ICU 2.0 197 */ 198 void setEras(const UnicodeString* eras, int32_t count); 199 200 /** 201 * Gets era name strings. For example: "Anno Domini" and "Before Christ". 202 * 203 * @param count Filled in with length of the array. 204 * @return the era name strings. 205 * @stable ICU 3.4 206 */ 207 const UnicodeString* getEraNames(int32_t& count) const; 208 209 /** 210 * Sets era name strings. For example: "Anno Domini" and "Before Christ". 211 * @param eraNames Array of era name strings (DateFormatSymbols retains ownership.) 212 * @param count Filled in with length of the array. 213 * @stable ICU 3.6 214 */ 215 void setEraNames(const UnicodeString* eraNames, int32_t count); 216 217 /** 218 * Gets narrow era strings. For example: "A" and "B". 219 * 220 * @param count Filled in with length of the array. 221 * @return the narrow era strings. 222 * @stable ICU 4.2 223 */ 224 const UnicodeString* getNarrowEras(int32_t& count) const; 225 226 /** 227 * Sets narrow era strings. For example: "A" and "B". 228 * @param narrowEras Array of narrow era strings (DateFormatSymbols retains ownership.) 229 * @param count Filled in with length of the array. 230 * @stable ICU 4.2 231 */ 232 void setNarrowEras(const UnicodeString* narrowEras, int32_t count); 233 234 /** 235 * Gets month strings. For example: "January", "February", etc. 236 * @param count Filled in with length of the array. 237 * @return the month strings. (DateFormatSymbols retains ownership.) 238 * @stable ICU 2.0 239 */ 240 const UnicodeString* getMonths(int32_t& count) const; 241 242 /** 243 * Sets month strings. For example: "January", "February", etc. 244 * 245 * @param months the new month strings. (not adopted; caller retains ownership) 246 * @param count Filled in with length of the array. 247 * @stable ICU 2.0 248 */ 249 void setMonths(const UnicodeString* months, int32_t count); 250 251 /** 252 * Gets short month strings. For example: "Jan", "Feb", etc. 253 * 254 * @param count Filled in with length of the array. 255 * @return the short month strings. (DateFormatSymbols retains ownership.) 256 * @stable ICU 2.0 257 */ 258 const UnicodeString* getShortMonths(int32_t& count) const; 259 260 /** 261 * Sets short month strings. For example: "Jan", "Feb", etc. 262 * @param count Filled in with length of the array. 263 * @param shortMonths the new short month strings. (not adopted; caller retains ownership) 264 * @stable ICU 2.0 265 */ 266 void setShortMonths(const UnicodeString* shortMonths, int32_t count); 267 268 /** 269 * Selector for date formatting context 270 * @stable ICU 3.6 271 */ 272 enum DtContextType { 273 FORMAT, 274 STANDALONE, 275 DT_CONTEXT_COUNT 276 }; 277 278 /** 279 * Selector for date formatting width 280 * @stable ICU 3.6 281 */ 282 enum DtWidthType { 283 ABBREVIATED, 284 WIDE, 285 NARROW, 286 DT_WIDTH_COUNT 287 }; 288 289 /** 290 * Gets month strings by width and context. For example: "January", "February", etc. 291 * @param count Filled in with length of the array. 292 * @param context The formatting context, either FORMAT or STANDALONE 293 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW. 294 * @return the month strings. (DateFormatSymbols retains ownership.) 295 * @stable ICU 3.4 296 */ 297 const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const; 298 299 /** 300 * Sets month strings by width and context. For example: "January", "February", etc. 301 * 302 * @param months The new month strings. (not adopted; caller retains ownership) 303 * @param count Filled in with length of the array. 304 * @param context The formatting context, either FORMAT or STANDALONE 305 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW. 306 * @stable ICU 3.6 307 */ 308 void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width); 309 310 /** 311 * Gets weekday strings. For example: "Sunday", "Monday", etc. 312 * @param count Filled in with length of the array. 313 * @return the weekday strings. (DateFormatSymbols retains ownership.) 314 * @stable ICU 2.0 315 */ 316 const UnicodeString* getWeekdays(int32_t& count) const; 317 318 319 /** 320 * Sets weekday strings. For example: "Sunday", "Monday", etc. 321 * @param weekdays the new weekday strings. (not adopted; caller retains ownership) 322 * @param count Filled in with length of the array. 323 * @stable ICU 2.0 324 */ 325 void setWeekdays(const UnicodeString* weekdays, int32_t count); 326 327 /** 328 * Gets short weekday strings. For example: "Sun", "Mon", etc. 329 * @param count Filled in with length of the array. 330 * @return the short weekday strings. (DateFormatSymbols retains ownership.) 331 * @stable ICU 2.0 332 */ 333 const UnicodeString* getShortWeekdays(int32_t& count) const; 334 335 /** 336 * Sets short weekday strings. For example: "Sun", "Mon", etc. 337 * @param shortWeekdays the new short weekday strings. (not adopted; caller retains ownership) 338 * @param count Filled in with length of the array. 339 * @stable ICU 2.0 340 */ 341 void setShortWeekdays(const UnicodeString* shortWeekdays, int32_t count); 342 343 /** 344 * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc. 345 * @param count Filled in with length of the array. 346 * @param context The formatting context, either FORMAT or STANDALONE 347 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW 348 * @return the month strings. (DateFormatSymbols retains ownership.) 349 * @stable ICU 3.4 350 */ 351 const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const; 352 353 /** 354 * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc. 355 * @param weekdays The new weekday strings. (not adopted; caller retains ownership) 356 * @param count Filled in with length of the array. 357 * @param context The formatting context, either FORMAT or STANDALONE 358 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW 359 * @stable ICU 3.6 360 */ 361 void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width); 362 363 /** 364 * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc. 365 * @param count Filled in with length of the array. 366 * @param context The formatting context, either FORMAT or STANDALONE 367 * @param width The width of returned strings, either WIDE or ABBREVIATED. There 368 * are no NARROW quarters. 369 * @return the quarter strings. (DateFormatSymbols retains ownership.) 370 * @stable ICU 3.6 371 */ 372 const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const; 373 374 /** 375 * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc. 376 * 377 * @param quarters The new quarter strings. (not adopted; caller retains ownership) 378 * @param count Filled in with length of the array. 379 * @param context The formatting context, either FORMAT or STANDALONE 380 * @param width The width of returned strings, either WIDE or ABBREVIATED. There 381 * are no NARROW quarters. 382 * @stable ICU 3.6 383 */ 384 void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width); 385 386 /** 387 * Gets AM/PM strings. For example: "AM" and "PM". 388 * @param count Filled in with length of the array. 389 * @return the weekday strings. (DateFormatSymbols retains ownership.) 390 * @stable ICU 2.0 391 */ 392 const UnicodeString* getAmPmStrings(int32_t& count) const; 393 394 /** 395 * Sets ampm strings. For example: "AM" and "PM". 396 * @param ampms the new ampm strings. (not adopted; caller retains ownership) 397 * @param count Filled in with length of the array. 398 * @stable ICU 2.0 399 */ 400 void setAmPmStrings(const UnicodeString* ampms, int32_t count); 401 402 #ifndef U_HIDE_INTERNAL_API 403 /** 404 * Somewhat temporary constants for leap month pattern types, adequate for supporting 405 * just leap month patterns as needed for Chinese lunar calendar. 406 * Eventually we will add full support for different month pattern types (needed for 407 * other calendars such as Hindu) at which point this approach will be replaced by a 408 * more complete approach. 409 * @internal 410 */ 411 enum EMonthPatternType 412 { 413 kLeapMonthPatternFormatWide, 414 kLeapMonthPatternFormatAbbrev, 415 kLeapMonthPatternFormatNarrow, 416 kLeapMonthPatternStandaloneWide, 417 kLeapMonthPatternStandaloneAbbrev, 418 kLeapMonthPatternStandaloneNarrow, 419 kLeapMonthPatternNumeric, 420 kMonthPatternsCount 421 }; 422 423 /** 424 * Somewhat temporary function for getting complete set of leap month patterns for all 425 * contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar 426 * does not have leap month patterns. Note, there is currently no setter for this. 427 * Eventually we will add full support for different month pattern types (needed for 428 * other calendars such as Hindu) at which point this approach will be replaced by a 429 * more complete approach. 430 * @param count Filled in with length of the array (may be 0). 431 * @return The leap month patterns (DateFormatSymbols retains ownership). 432 * May be NULL if there are no leap month patterns for this calendar. 433 * @internal 434 */ 435 const UnicodeString* getLeapMonthPatterns(int32_t& count) const; 436 437 #endif /* U_HIDE_INTERNAL_API */ 438 439 #ifndef U_HIDE_DEPRECATED_API 440 /** 441 * Gets timezone strings. These strings are stored in a 2-dimensional array. 442 * @param rowCount Output param to receive number of rows. 443 * @param columnCount Output param to receive number of columns. 444 * @return The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.) 445 * @deprecated ICU 3.6 446 */ 447 const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const; 448 #endif /* U_HIDE_DEPRECATED_API */ 449 450 /** 451 * Sets timezone strings. These strings are stored in a 2-dimensional array. 452 * <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in 453 * a DateFormatSymbols. Therefore, the time zone strings set by this mthod 454 * have no effects in an instance of SimpleDateFormat for formatting time 455 * zones. 456 * @param strings The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership) 457 * @param rowCount The number of rows (count of first index). 458 * @param columnCount The number of columns (count of second index). 459 * @stable ICU 2.0 460 */ 461 void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount); 462 463 /** 464 * Get the non-localized date-time pattern characters. 465 * @return the non-localized date-time pattern characters 466 * @stable ICU 2.0 467 */ 468 static const UChar * U_EXPORT2 getPatternUChars(void); 469 470 /** 471 * Gets localized date-time pattern characters. For example: 'u', 't', etc. 472 * <p> 473 * Note: ICU no longer provides localized date-time pattern characters for a locale 474 * starting ICU 3.8. This method returns the non-localized date-time pattern 475 * characters unless user defined localized data is set by setLocalPatternChars. 476 * @param result Output param which will receive the localized date-time pattern characters. 477 * @return A reference to 'result'. 478 * @stable ICU 2.0 479 */ 480 UnicodeString& getLocalPatternChars(UnicodeString& result) const; 481 482 /** 483 * Sets localized date-time pattern characters. For example: 'u', 't', etc. 484 * @param newLocalPatternChars the new localized date-time 485 * pattern characters. 486 * @stable ICU 2.0 487 */ 488 void setLocalPatternChars(const UnicodeString& newLocalPatternChars); 489 490 /** 491 * Returns the locale for this object. Two flavors are available: 492 * valid and actual locale. 493 * @stable ICU 2.8 494 */ 495 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const; 496 497 #ifndef U_HIDE_INTERNAL_API 498 /** 499 * Constants for capitalization context usage types. 500 * @internal 501 */ 502 enum ECapitalizationContextUsageType 503 { 504 kCapContextUsageOther, 505 kCapContextUsageMonthFormat, /* except narrow */ 506 kCapContextUsageMonthStandalone, /* except narrow */ 507 kCapContextUsageMonthNarrow, 508 kCapContextUsageDayFormat, /* except narrow */ 509 kCapContextUsageDayStandalone, /* except narrow */ 510 kCapContextUsageDayNarrow, 511 kCapContextUsageEraWide, 512 kCapContextUsageEraAbbrev, 513 kCapContextUsageEraNarrow, 514 kCapContextUsageZoneLong, 515 kCapContextUsageZoneShort, 516 kCapContextUsageMetazoneLong, 517 kCapContextUsageMetazoneShort, 518 kCapContextUsageTypeCount 519 }; 520 #endif /* U_HIDE_INTERNAL_API */ 521 522 /** 523 * ICU "poor man's RTTI", returns a UClassID for the actual class. 524 * 525 * @stable ICU 2.2 526 */ 527 virtual UClassID getDynamicClassID() const; 528 529 /** 530 * ICU "poor man's RTTI", returns a UClassID for this class. 531 * 532 * @stable ICU 2.2 533 */ 534 static UClassID U_EXPORT2 getStaticClassID(); 535 536 private: 537 538 friend class SimpleDateFormat; 539 friend class DateFormatSymbolsSingleSetter; // see udat.cpp 540 541 /** 542 * Abbreviated era strings. For example: "AD" and "BC". 543 */ 544 UnicodeString* fEras; 545 int32_t fErasCount; 546 547 /** 548 * Era name strings. For example: "Anno Domini" and "Before Christ". 549 */ 550 UnicodeString* fEraNames; 551 int32_t fEraNamesCount; 552 553 /** 554 * Narrow era strings. For example: "A" and "B". 555 */ 556 UnicodeString* fNarrowEras; 557 int32_t fNarrowErasCount; 558 559 /** 560 * Month strings. For example: "January", "February", etc. 561 */ 562 UnicodeString* fMonths; 563 int32_t fMonthsCount; 564 565 /** 566 * Short month strings. For example: "Jan", "Feb", etc. 567 */ 568 UnicodeString* fShortMonths; 569 int32_t fShortMonthsCount; 570 571 /** 572 * Narrow month strings. For example: "J", "F", etc. 573 */ 574 UnicodeString* fNarrowMonths; 575 int32_t fNarrowMonthsCount; 576 577 /** 578 * Standalone Month strings. For example: "January", "February", etc. 579 */ 580 UnicodeString* fStandaloneMonths; 581 int32_t fStandaloneMonthsCount; 582 583 /** 584 * Standalone Short month strings. For example: "Jan", "Feb", etc. 585 */ 586 UnicodeString* fStandaloneShortMonths; 587 int32_t fStandaloneShortMonthsCount; 588 589 /** 590 * Standalone Narrow month strings. For example: "J", "F", etc. 591 */ 592 UnicodeString* fStandaloneNarrowMonths; 593 int32_t fStandaloneNarrowMonthsCount; 594 595 /** 596 * Weekday strings. For example: "Sunday", "Monday", etc. 597 */ 598 UnicodeString* fWeekdays; 599 int32_t fWeekdaysCount; 600 601 /** 602 * Short weekday strings. For example: "Sun", "Mon", etc. 603 */ 604 UnicodeString* fShortWeekdays; 605 int32_t fShortWeekdaysCount; 606 607 /** 608 * Narrow weekday strings. For example: "Sun", "Mon", etc. 609 */ 610 UnicodeString* fNarrowWeekdays; 611 int32_t fNarrowWeekdaysCount; 612 613 /** 614 * Standalone Weekday strings. For example: "Sunday", "Monday", etc. 615 */ 616 UnicodeString* fStandaloneWeekdays; 617 int32_t fStandaloneWeekdaysCount; 618 619 /** 620 * Standalone Short weekday strings. For example: "Sun", "Mon", etc. 621 */ 622 UnicodeString* fStandaloneShortWeekdays; 623 int32_t fStandaloneShortWeekdaysCount; 624 625 /** 626 * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc. 627 */ 628 UnicodeString* fStandaloneNarrowWeekdays; 629 int32_t fStandaloneNarrowWeekdaysCount; 630 631 /** 632 * Ampm strings. For example: "AM" and "PM". 633 */ 634 UnicodeString* fAmPms; 635 int32_t fAmPmsCount; 636 637 /** 638 * Quarter strings. For example: "1st quarter", "2nd quarter", etc. 639 */ 640 UnicodeString *fQuarters; 641 int32_t fQuartersCount; 642 643 /** 644 * Short quarters. For example: "Q1", "Q2", etc. 645 */ 646 UnicodeString *fShortQuarters; 647 int32_t fShortQuartersCount; 648 649 /** 650 * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc. 651 */ 652 UnicodeString *fStandaloneQuarters; 653 int32_t fStandaloneQuartersCount; 654 655 /** 656 * Standalone short quarter strings. For example: "Q1", "Q2", etc. 657 */ 658 UnicodeString *fStandaloneShortQuarters; 659 int32_t fStandaloneShortQuartersCount; 660 661 /** 662 * All leap month patterns, for example "{0}bis". 663 */ 664 UnicodeString *fLeapMonthPatterns; 665 int32_t fLeapMonthPatternsCount; 666 667 /** 668 * (Format) Short cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai" 669 */ 670 UnicodeString* fShortYearNames; 671 int32_t fShortYearNamesCount; 672 673 /** 674 * Localized names of time zones in this locale. This is a 675 * two-dimensional array of strings of size n by m, 676 * where m is at least 5 and up to 7. Each of the n rows is an 677 * entry containing the localized names for a single TimeZone. 678 * 679 * Each such row contains (with i ranging from 0..n-1): 680 * 681 * zoneStrings[i][0] - time zone ID 682 * example: America/Los_Angeles 683 * zoneStrings[i][1] - long name of zone in standard time 684 * example: Pacific Standard Time 685 * zoneStrings[i][2] - short name of zone in standard time 686 * example: PST 687 * zoneStrings[i][3] - long name of zone in daylight savings time 688 * example: Pacific Daylight Time 689 * zoneStrings[i][4] - short name of zone in daylight savings time 690 * example: PDT 691 * zoneStrings[i][5] - location name of zone 692 * example: United States (Los Angeles) 693 * zoneStrings[i][6] - long generic name of zone 694 * example: Pacific Time 695 * zoneStrings[i][7] - short generic of zone 696 * example: PT 697 * 698 * The zone ID is not localized; it corresponds to the ID 699 * value associated with a system time zone object. All other entries 700 * are localized names. If a zone does not implement daylight savings 701 * time, the daylight savings time names are ignored. 702 * 703 * Note:CLDR 1.5 introduced metazone and its historical mappings. 704 * This simple two-dimensional array is no longer sufficient to represent 705 * localized names and its historic changes. Since ICU 3.8.1, localized 706 * zone names extracted from ICU locale data is stored in a ZoneStringFormat 707 * instance. But we still need to support the old way of customizing 708 * localized zone names, so we keep this field for the purpose. 709 */ 710 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings 711 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale 712 int32_t fZoneStringsRowCount; 713 int32_t fZoneStringsColCount; 714 715 Locale fZSFLocale; // Locale used for getting ZoneStringFormat 716 717 /** 718 * Localized date-time pattern characters. For example: use 'u' as 'y'. 719 */ 720 UnicodeString fLocalPatternChars; 721 722 #ifndef U_HIDE_INTERNAL_API 723 /** 724 * Capitalization transforms. For each usage type, the first array element indicates 725 * whether to titlecase for uiListOrMenu context, the second indicates whether to 726 * titlecase for stand-alone context. 727 */ 728 UBool fCapitalization[kCapContextUsageTypeCount][2]; 729 #endif 730 731 732 private: 733 /** valid/actual locale information 734 * these are always ICU locales, so the length should not be a problem 735 */ 736 char validLocale[ULOC_FULLNAME_CAPACITY]; 737 char actualLocale[ULOC_FULLNAME_CAPACITY]; 738 739 DateFormatSymbols(); // default constructor not implemented 740 741 /** 742 * Called by the constructors to actually load data from the resources 743 * 744 * @param locale The locale to get symbols for. 745 * @param type Calendar Type (as from Calendar::getType()) 746 * @param status Input/output parameter, set to success or 747 * failure code upon return. 748 * @param useLastResortData determine if use last resort data 749 */ 750 void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE); 751 752 /** 753 * Copy or alias an array in another object, as appropriate. 754 * 755 * @param dstArray the copy destination array. 756 * @param dstCount fill in with the lenth of 'dstArray'. 757 * @param srcArray the source array to be copied. 758 * @param srcCount the length of items to be copied from the 'srcArray'. 759 */ 760 static void assignArray(UnicodeString*& dstArray, 761 int32_t& dstCount, 762 const UnicodeString* srcArray, 763 int32_t srcCount); 764 765 /** 766 * Return true if the given arrays' contents are equal, or if the arrays are 767 * identical (pointers are equal). 768 * 769 * @param array1 one array to be compared with. 770 * @param array2 another array to be compared with. 771 * @param count the length of items to be copied. 772 * @return true if the given arrays' contents are equal, or if the arrays are 773 * identical (pointers are equal). 774 */ 775 static UBool arrayCompare(const UnicodeString* array1, 776 const UnicodeString* array2, 777 int32_t count); 778 779 /** 780 * Create a copy, in fZoneStrings, of the given zone strings array. The 781 * member variables fZoneStringsRowCount and fZoneStringsColCount should be 782 * set already by the caller. 783 */ 784 void createZoneStrings(const UnicodeString *const * otherStrings); 785 786 /** 787 * Delete all the storage owned by this object. 788 */ 789 void dispose(void); 790 791 /** 792 * Copy all of the other's data to this. 793 * @param other the object to be copied. 794 */ 795 void copyData(const DateFormatSymbols& other); 796 797 /** 798 * Create zone strings array by locale if not yet available 799 */ 800 void initZoneStringsArray(void); 801 802 /** 803 * Delete just the zone strings. 804 */ 805 void disposeZoneStrings(void); 806 807 /** 808 * Returns the date format field index of the pattern character c, 809 * or UDAT_FIELD_COUNT if c is not a pattern character. 810 */ 811 static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c); 812 813 /** 814 * Returns TRUE if f (with its pattern character repeated count times) is a numeric field. 815 */ 816 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count); 817 818 /** 819 * Returns TRUE if c (repeated count times) is the pattern character for a numeric field. 820 */ 821 static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count); 822 }; 823 824 U_NAMESPACE_END 825 826 #endif /* #if !UCONFIG_NO_FORMATTING */ 827 828 #endif // _DTFMTSYM 829 //eof 830