1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ********************************************************************************
5 * Copyright (C) 1997-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ********************************************************************************
11 * Modification History:
13 * Date Name Description
14 * 02/19/97 aliu Converted from java.
15 * 07/21/98 stephen Added getZoneIndex()
16 * Changed to match C++ conventions
17 ********************************************************************************
23 #include "unicode/utypes.h"
25 #if U_SHOW_CPLUSPLUS_API
27 #if !UCONFIG_NO_FORMATTING
29 #include "unicode/calendar.h"
30 #include "unicode/strenum.h"
31 #include "unicode/uobject.h"
32 #include "unicode/locid.h"
33 #include "unicode/udat.h"
34 #include "unicode/ures.h"
38 * \brief C++ API: Symbols for formatting dates.
43 /* forward declaration */
44 class SimpleDateFormat;
48 * DateFormatSymbols is a public class for encapsulating localizable date-time
49 * formatting data -- including timezone data. DateFormatSymbols is used by
50 * DateFormat and SimpleDateFormat.
52 * Rather than first creating a DateFormatSymbols to get a date-time formatter
53 * by using a SimpleDateFormat constructor, clients are encouraged to create a
54 * date-time formatter using the getTimeInstance(), getDateInstance(), or
55 * getDateTimeInstance() method in DateFormat. Each of these methods can return a
56 * date/time formatter initialized with a default format pattern along with the
57 * date-time formatting data for a given or default locale. After a formatter is
58 * created, clients may modify the format pattern using the setPattern function
59 * as so desired. For more information on using these formatter factory
60 * functions, see DateFormat.
62 * If clients decide to create a date-time formatter with a particular format
63 * pattern and locale, they can do so with new SimpleDateFormat(aPattern,
64 * new DateFormatSymbols(aLocale)). This will load the appropriate date-time
65 * formatting data from the locale.
67 * DateFormatSymbols objects are clonable. When clients obtain a
68 * DateFormatSymbols object, they can feel free to modify the date-time
69 * formatting data as necessary. For instance, clients can
70 * replace the localized date-time format pattern characters with the ones that
71 * they feel easy to remember. Or they can change the representative cities
72 * originally picked by default to using their favorite ones.
74 * DateFormatSymbols are not expected to be subclassed. Data for a calendar is
75 * loaded out of resource bundles. The 'type' parameter indicates the type of
76 * calendar, for example, "gregorian" or "japanese". If the type is not gregorian
77 * (or NULL, or an empty string) then the type is appended to the resource name,
78 * for example, 'Eras_japanese' instead of 'Eras'. If the resource 'Eras_japanese' did
79 * not exist (even in root), then this class will fall back to just 'Eras', that is,
80 * Gregorian data. Therefore, the calendar implementor MUST ensure that the root
81 * locale at least contains any resources that are to be particularized for the
84 class U_I18N_API DateFormatSymbols U_FINAL : public UObject {
87 * Construct a DateFormatSymbols object by loading format data from
88 * resources for the default locale, in the default calendar (Gregorian).
90 * NOTE: This constructor will never fail; if it cannot get resource
91 * data for the default locale, it will return a last-resort object
92 * based on hard-coded strings.
94 * @param status Status code. Failure
95 * results if the resources for the default cannot be
96 * found or cannot be loaded
99 DateFormatSymbols(UErrorCode& status);
102 * Construct a DateFormatSymbols object by loading format data from
103 * resources for the given locale, in the default calendar (Gregorian).
105 * @param locale Locale to load format data from.
106 * @param status Status code. Failure
107 * results if the resources for the locale cannot be
108 * found or cannot be loaded
111 DateFormatSymbols(const Locale& locale,
114 #ifndef U_HIDE_INTERNAL_API
116 * Construct a DateFormatSymbols object by loading format data from
117 * resources for the default locale, in the default calendar (Gregorian).
119 * NOTE: This constructor will never fail; if it cannot get resource
120 * data for the default locale, it will return a last-resort object
121 * based on hard-coded strings.
123 * @param type Type of calendar (as returned by Calendar::getType).
124 * Will be used to access the correct set of strings.
125 * (NULL or empty string defaults to "gregorian".)
126 * @param status Status code. Failure
127 * results if the resources for the default cannot be
128 * found or cannot be loaded
131 DateFormatSymbols(const char *type, UErrorCode& status);
134 * Construct a DateFormatSymbols object by loading format data from
135 * resources for the given locale, in the default calendar (Gregorian).
137 * @param locale Locale to load format data from.
138 * @param type Type of calendar (as returned by Calendar::getType).
139 * Will be used to access the correct set of strings.
140 * (NULL or empty string defaults to "gregorian".)
141 * @param status Status code. Failure
142 * results if the resources for the locale cannot be
143 * found or cannot be loaded
146 DateFormatSymbols(const Locale& locale,
149 #endif /* U_HIDE_INTERNAL_API */
155 DateFormatSymbols(const DateFormatSymbols&);
158 * Assignment operator.
161 DateFormatSymbols& operator=(const DateFormatSymbols&);
164 * Destructor. This is nonvirtual because this class is not designed to be
168 virtual ~DateFormatSymbols();
171 * Return true if another object is semantically equal to this one.
173 * @param other the DateFormatSymbols object to be compared with.
174 * @return true if other is semantically equal to this.
177 bool operator==(const DateFormatSymbols& other) const;
180 * Return true if another object is semantically unequal to this one.
182 * @param other the DateFormatSymbols object to be compared with.
183 * @return true if other is semantically unequal to this.
186 bool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
189 * Gets abbreviated era strings. For example: "AD" and "BC".
191 * @param count Filled in with length of the array.
192 * @return the era strings.
195 const UnicodeString* getEras(int32_t& count) const;
198 * Sets abbreviated era strings. For example: "AD" and "BC".
199 * @param eras Array of era strings (DateFormatSymbols retains ownership.)
200 * @param count Filled in with length of the array.
203 void setEras(const UnicodeString* eras, int32_t count);
206 * Gets era name strings. For example: "Anno Domini" and "Before Christ".
208 * @param count Filled in with length of the array.
209 * @return the era name strings.
212 const UnicodeString* getEraNames(int32_t& count) const;
215 * Sets era name strings. For example: "Anno Domini" and "Before Christ".
216 * @param eraNames Array of era name strings (DateFormatSymbols retains ownership.)
217 * @param count Filled in with length of the array.
220 void setEraNames(const UnicodeString* eraNames, int32_t count);
223 * Gets narrow era strings. For example: "A" and "B".
225 * @param count Filled in with length of the array.
226 * @return the narrow era strings.
229 const UnicodeString* getNarrowEras(int32_t& count) const;
232 * Sets narrow era strings. For example: "A" and "B".
233 * @param narrowEras Array of narrow era strings (DateFormatSymbols retains ownership.)
234 * @param count Filled in with length of the array.
237 void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
240 * Gets month strings. For example: "January", "February", etc.
241 * @param count Filled in with length of the array.
242 * @return the month strings. (DateFormatSymbols retains ownership.)
245 const UnicodeString* getMonths(int32_t& count) const;
248 * Sets month strings. For example: "January", "February", etc.
250 * @param months the new month strings. (not adopted; caller retains ownership)
251 * @param count Filled in with length of the array.
254 void setMonths(const UnicodeString* months, int32_t count);
257 * Gets short month strings. For example: "Jan", "Feb", etc.
259 * @param count Filled in with length of the array.
260 * @return the short month strings. (DateFormatSymbols retains ownership.)
263 const UnicodeString* getShortMonths(int32_t& count) const;
266 * Sets short month strings. For example: "Jan", "Feb", etc.
267 * @param count Filled in with length of the array.
268 * @param shortMonths the new short month strings. (not adopted; caller retains ownership)
271 void setShortMonths(const UnicodeString* shortMonths, int32_t count);
274 * Selector for date formatting context
280 #ifndef U_HIDE_DEPRECATED_API
282 * One more than the highest normal DtContextType value.
283 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
286 #endif // U_HIDE_DEPRECATED_API
290 * Selector for date formatting width
298 * Short width is currently only supported for weekday names.
302 #ifndef U_HIDE_DEPRECATED_API
304 * One more than the highest normal DtWidthType value.
305 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
308 #endif // U_HIDE_DEPRECATED_API
312 * Gets month strings by width and context. For example: "January", "February", etc.
313 * @param count Filled in with length of the array.
314 * @param context The formatting context, either FORMAT or STANDALONE
315 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
316 * @return the month strings. (DateFormatSymbols retains ownership.)
319 const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
322 * Sets month strings by width and context. For example: "January", "February", etc.
324 * @param months The new month strings. (not adopted; caller retains ownership)
325 * @param count Filled in with length of the array.
326 * @param context The formatting context, either FORMAT or STANDALONE
327 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
330 void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
333 * Gets wide weekday strings. For example: "Sunday", "Monday", etc.
334 * @param count Filled in with length of the array.
335 * @return the weekday strings. (DateFormatSymbols retains ownership.)
338 const UnicodeString* getWeekdays(int32_t& count) const;
342 * Sets wide weekday strings. For example: "Sunday", "Monday", etc.
343 * @param weekdays the new weekday strings. (not adopted; caller retains ownership)
344 * @param count Filled in with length of the array.
347 void setWeekdays(const UnicodeString* weekdays, int32_t count);
350 * Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
351 * misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
352 * @param count Filled in with length of the array.
353 * @return the abbreviated weekday strings. (DateFormatSymbols retains ownership.)
356 const UnicodeString* getShortWeekdays(int32_t& count) const;
359 * Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
360 * misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
361 * @param abbrevWeekdays the new abbreviated weekday strings. (not adopted; caller retains ownership)
362 * @param count Filled in with length of the array.
365 void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
368 * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
369 * @param count Filled in with length of the array.
370 * @param context The formatting context, either FORMAT or STANDALONE
371 * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
372 * @return the month strings. (DateFormatSymbols retains ownership.)
375 const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
378 * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc.
379 * @param weekdays The new weekday strings. (not adopted; caller retains ownership)
380 * @param count Filled in with length of the array.
381 * @param context The formatting context, either FORMAT or STANDALONE
382 * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
385 void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
388 * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
389 * @param count Filled in with length of the array.
390 * @param context The formatting context, either FORMAT or STANDALONE
391 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
392 * @return the quarter strings. (DateFormatSymbols retains ownership.)
395 const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
398 * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
400 * @param quarters The new quarter strings. (not adopted; caller retains ownership)
401 * @param count Filled in with length of the array.
402 * @param context The formatting context, either FORMAT or STANDALONE
403 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
406 void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
409 * Gets AM/PM strings. For example: "AM" and "PM".
410 * @param count Filled in with length of the array.
411 * @return the weekday strings. (DateFormatSymbols retains ownership.)
414 const UnicodeString* getAmPmStrings(int32_t& count) const;
417 * Sets ampm strings. For example: "AM" and "PM".
418 * @param ampms the new ampm strings. (not adopted; caller retains ownership)
419 * @param count Filled in with length of the array.
422 void setAmPmStrings(const UnicodeString* ampms, int32_t count);
424 #ifndef U_HIDE_INTERNAL_API
426 * This default time separator is used for formatting when the locale
427 * doesn't specify any time separator, and always recognized when parsing.
430 static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
433 * This alternate time separator is always recognized when parsing.
436 static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
439 * Gets the time separator string. For example: ":".
440 * @param result Output param which will receive the time separator string.
441 * @return A reference to 'result'.
444 UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
447 * Sets the time separator string. For example: ":".
448 * @param newTimeSeparator the new time separator string.
451 void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
452 #endif /* U_HIDE_INTERNAL_API */
455 * Gets cyclic year name strings if the calendar has them, by width and context.
456 * For example: "jia-zi", "yi-chou", etc.
457 * @param count Filled in with length of the array.
458 * @param context The usage context: FORMAT, STANDALONE.
459 * @param width The requested name width: WIDE, ABBREVIATED, NARROW.
460 * @return The year name strings (DateFormatSymbols retains ownership),
461 * or null if they are not available for this calendar.
464 const UnicodeString* getYearNames(int32_t& count,
465 DtContextType context, DtWidthType width) const;
468 * Sets cyclic year name strings by width and context. For example: "jia-zi", "yi-chou", etc.
470 * @param yearNames The new cyclic year name strings (not adopted; caller retains ownership).
471 * @param count The length of the array.
472 * @param context The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
473 * @param width The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
476 void setYearNames(const UnicodeString* yearNames, int32_t count,
477 DtContextType context, DtWidthType width);
480 * Gets calendar zodiac name strings if the calendar has them, by width and context.
481 * For example: "Rat", "Ox", "Tiger", etc.
482 * @param count Filled in with length of the array.
483 * @param context The usage context: FORMAT, STANDALONE.
484 * @param width The requested name width: WIDE, ABBREVIATED, NARROW.
485 * @return The zodiac name strings (DateFormatSymbols retains ownership),
486 * or null if they are not available for this calendar.
489 const UnicodeString* getZodiacNames(int32_t& count,
490 DtContextType context, DtWidthType width) const;
493 * Sets calendar zodiac name strings by width and context. For example: "Rat", "Ox", "Tiger", etc.
495 * @param zodiacNames The new zodiac name strings (not adopted; caller retains ownership).
496 * @param count The length of the array.
497 * @param context The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
498 * @param width The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
501 void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
502 DtContextType context, DtWidthType width);
504 #ifndef U_HIDE_INTERNAL_API
506 * Somewhat temporary constants for leap month pattern types, adequate for supporting
507 * just leap month patterns as needed for Chinese lunar calendar.
508 * Eventually we will add full support for different month pattern types (needed for
509 * other calendars such as Hindu) at which point this approach will be replaced by a
510 * more complete approach.
513 enum EMonthPatternType
515 kLeapMonthPatternFormatWide,
516 kLeapMonthPatternFormatAbbrev,
517 kLeapMonthPatternFormatNarrow,
518 kLeapMonthPatternStandaloneWide,
519 kLeapMonthPatternStandaloneAbbrev,
520 kLeapMonthPatternStandaloneNarrow,
521 kLeapMonthPatternNumeric,
526 * Somewhat temporary function for getting complete set of leap month patterns for all
527 * contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar
528 * does not have leap month patterns. Note, there is currently no setter for this.
529 * Eventually we will add full support for different month pattern types (needed for
530 * other calendars such as Hindu) at which point this approach will be replaced by a
531 * more complete approach.
532 * @param count Filled in with length of the array (may be 0).
533 * @return The leap month patterns (DateFormatSymbols retains ownership).
534 * May be NULL if there are no leap month patterns for this calendar.
537 const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
539 #endif /* U_HIDE_INTERNAL_API */
541 #ifndef U_HIDE_DEPRECATED_API
543 * Gets timezone strings. These strings are stored in a 2-dimensional array.
544 * @param rowCount Output param to receive number of rows.
545 * @param columnCount Output param to receive number of columns.
546 * @return The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)
547 * @deprecated ICU 3.6
549 const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
550 #endif /* U_HIDE_DEPRECATED_API */
553 * Sets timezone strings. These strings are stored in a 2-dimensional array.
554 * <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in
555 * a DateFormatSymbols. Therefore, the time zone strings set by this method
556 * have no effects in an instance of SimpleDateFormat for formatting time
558 * @param strings The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
559 * @param rowCount The number of rows (count of first index).
560 * @param columnCount The number of columns (count of second index).
563 void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
566 * Get the non-localized date-time pattern characters.
567 * @return the non-localized date-time pattern characters
570 static const char16_t * U_EXPORT2 getPatternUChars(void);
573 * Gets localized date-time pattern characters. For example: 'u', 't', etc.
575 * Note: ICU no longer provides localized date-time pattern characters for a locale
576 * starting ICU 3.8. This method returns the non-localized date-time pattern
577 * characters unless user defined localized data is set by setLocalPatternChars.
578 * @param result Output param which will receive the localized date-time pattern characters.
579 * @return A reference to 'result'.
582 UnicodeString& getLocalPatternChars(UnicodeString& result) const;
585 * Sets localized date-time pattern characters. For example: 'u', 't', etc.
586 * @param newLocalPatternChars the new localized date-time
587 * pattern characters.
590 void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
593 * Returns the locale for this object. Two flavors are available:
594 * valid and actual locale.
597 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
599 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
600 they are needed for .h file declarations. */
602 * Constants for capitalization context usage types.
605 enum ECapitalizationContextUsageType
607 #ifndef U_HIDE_INTERNAL_API
608 kCapContextUsageOther = 0,
609 kCapContextUsageMonthFormat, /* except narrow */
610 kCapContextUsageMonthStandalone, /* except narrow */
611 kCapContextUsageMonthNarrow,
612 kCapContextUsageDayFormat, /* except narrow */
613 kCapContextUsageDayStandalone, /* except narrow */
614 kCapContextUsageDayNarrow,
615 kCapContextUsageEraWide,
616 kCapContextUsageEraAbbrev,
617 kCapContextUsageEraNarrow,
618 kCapContextUsageZoneLong,
619 kCapContextUsageZoneShort,
620 kCapContextUsageMetazoneLong,
621 kCapContextUsageMetazoneShort,
622 #endif /* U_HIDE_INTERNAL_API */
623 kCapContextUsageTypeCount = 14
627 * ICU "poor man's RTTI", returns a UClassID for the actual class.
631 virtual UClassID getDynamicClassID() const override;
634 * ICU "poor man's RTTI", returns a UClassID for this class.
638 static UClassID U_EXPORT2 getStaticClassID();
642 friend class SimpleDateFormat;
643 friend class DateFormatSymbolsSingleSetter; // see udat.cpp
646 * Abbreviated era strings. For example: "AD" and "BC".
648 UnicodeString* fEras;
652 * Era name strings. For example: "Anno Domini" and "Before Christ".
654 UnicodeString* fEraNames;
655 int32_t fEraNamesCount;
658 * Narrow era strings. For example: "A" and "B".
660 UnicodeString* fNarrowEras;
661 int32_t fNarrowErasCount;
664 * Month strings. For example: "January", "February", etc.
666 UnicodeString* fMonths;
667 int32_t fMonthsCount;
670 * Short month strings. For example: "Jan", "Feb", etc.
672 UnicodeString* fShortMonths;
673 int32_t fShortMonthsCount;
676 * Narrow month strings. For example: "J", "F", etc.
678 UnicodeString* fNarrowMonths;
679 int32_t fNarrowMonthsCount;
682 * Standalone Month strings. For example: "January", "February", etc.
684 UnicodeString* fStandaloneMonths;
685 int32_t fStandaloneMonthsCount;
688 * Standalone Short month strings. For example: "Jan", "Feb", etc.
690 UnicodeString* fStandaloneShortMonths;
691 int32_t fStandaloneShortMonthsCount;
694 * Standalone Narrow month strings. For example: "J", "F", etc.
696 UnicodeString* fStandaloneNarrowMonths;
697 int32_t fStandaloneNarrowMonthsCount;
700 * CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc.
702 UnicodeString* fWeekdays;
703 int32_t fWeekdaysCount;
706 * CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
708 UnicodeString* fShortWeekdays;
709 int32_t fShortWeekdaysCount;
712 * CLDR-style format short weekday strings. For example: "Su", "Mo", etc.
714 UnicodeString* fShorterWeekdays;
715 int32_t fShorterWeekdaysCount;
718 * CLDR-style format narrow weekday strings. For example: "S", "M", etc.
720 UnicodeString* fNarrowWeekdays;
721 int32_t fNarrowWeekdaysCount;
724 * CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc.
726 UnicodeString* fStandaloneWeekdays;
727 int32_t fStandaloneWeekdaysCount;
730 * CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
732 UnicodeString* fStandaloneShortWeekdays;
733 int32_t fStandaloneShortWeekdaysCount;
736 * CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc.
738 UnicodeString* fStandaloneShorterWeekdays;
739 int32_t fStandaloneShorterWeekdaysCount;
742 * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
744 UnicodeString* fStandaloneNarrowWeekdays;
745 int32_t fStandaloneNarrowWeekdaysCount;
748 * Ampm strings. For example: "AM" and "PM".
750 UnicodeString* fAmPms;
754 * Narrow Ampm strings. For example: "a" and "p".
756 UnicodeString* fNarrowAmPms;
757 int32_t fNarrowAmPmsCount;
760 * Time separator string. For example: ":".
762 UnicodeString fTimeSeparator;
765 * Quarter strings. For example: "1st quarter", "2nd quarter", etc.
767 UnicodeString *fQuarters;
768 int32_t fQuartersCount;
771 * Short quarters. For example: "Q1", "Q2", etc.
773 UnicodeString *fShortQuarters;
774 int32_t fShortQuartersCount;
777 * Narrow quarters. For example: "1", "2", etc.
778 * (In many, but not all, locales, this is the same as "Q", but there are locales for which this isn't true.)
780 UnicodeString *fNarrowQuarters;
781 int32_t fNarrowQuartersCount;
784 * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc.
786 UnicodeString *fStandaloneQuarters;
787 int32_t fStandaloneQuartersCount;
790 * Standalone short quarter strings. For example: "Q1", "Q2", etc.
792 UnicodeString *fStandaloneShortQuarters;
793 int32_t fStandaloneShortQuartersCount;
796 * Standalone narrow quarter strings. For example: "1", "2", etc.
797 * (In many, but not all, locales, this is the same as "q", but there are locales for which this isn't true.)
799 UnicodeString *fStandaloneNarrowQuarters;
800 int32_t fStandaloneNarrowQuartersCount;
803 * All leap month patterns, for example "{0}bis".
805 UnicodeString *fLeapMonthPatterns;
806 int32_t fLeapMonthPatternsCount;
809 * Cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai";
810 * currently we only have data for format/abbreviated.
811 * For the others, just get from format/abbreviated, ignore set.
813 UnicodeString *fShortYearNames;
814 int32_t fShortYearNamesCount;
817 * Cyclic zodiac names, for example "Rat", "Ox", "Tiger", etc.;
818 * currently we only have data for format/abbreviated.
819 * For the others, just get from format/abbreviated, ignore set.
821 UnicodeString *fShortZodiacNames;
822 int32_t fShortZodiacNamesCount;
825 * Localized names of time zones in this locale. This is a
826 * two-dimensional array of strings of size n by m,
827 * where m is at least 5 and up to 7. Each of the n rows is an
828 * entry containing the localized names for a single TimeZone.
830 * Each such row contains (with i ranging from 0..n-1):
832 * zoneStrings[i][0] - time zone ID
833 * example: America/Los_Angeles
834 * zoneStrings[i][1] - long name of zone in standard time
835 * example: Pacific Standard Time
836 * zoneStrings[i][2] - short name of zone in standard time
838 * zoneStrings[i][3] - long name of zone in daylight savings time
839 * example: Pacific Daylight Time
840 * zoneStrings[i][4] - short name of zone in daylight savings time
842 * zoneStrings[i][5] - location name of zone
843 * example: United States (Los Angeles)
844 * zoneStrings[i][6] - long generic name of zone
845 * example: Pacific Time
846 * zoneStrings[i][7] - short generic of zone
849 * The zone ID is not localized; it corresponds to the ID
850 * value associated with a system time zone object. All other entries
851 * are localized names. If a zone does not implement daylight savings
852 * time, the daylight savings time names are ignored.
854 * Note:CLDR 1.5 introduced metazone and its historical mappings.
855 * This simple two-dimensional array is no longer sufficient to represent
856 * localized names and its historic changes. Since ICU 3.8.1, localized
857 * zone names extracted from ICU locale data is stored in a ZoneStringFormat
858 * instance. But we still need to support the old way of customizing
859 * localized zone names, so we keep this field for the purpose.
861 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
862 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
863 int32_t fZoneStringsRowCount;
864 int32_t fZoneStringsColCount;
866 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
869 * Localized date-time pattern characters. For example: use 'u' as 'y'.
871 UnicodeString fLocalPatternChars;
874 * Capitalization transforms. For each usage type, the first array element indicates
875 * whether to titlecase for uiListOrMenu context, the second indicates whether to
876 * titlecase for stand-alone context.
878 UBool fCapitalization[kCapContextUsageTypeCount][2];
881 * Abbreviated (== short) day period strings.
883 UnicodeString *fAbbreviatedDayPeriods;
884 int32_t fAbbreviatedDayPeriodsCount;
887 * Wide day period strings.
889 UnicodeString *fWideDayPeriods;
890 int32_t fWideDayPeriodsCount;
893 * Narrow day period strings.
895 UnicodeString *fNarrowDayPeriods;
896 int32_t fNarrowDayPeriodsCount;
899 * Stand-alone abbreviated (== short) day period strings.
901 UnicodeString *fStandaloneAbbreviatedDayPeriods;
902 int32_t fStandaloneAbbreviatedDayPeriodsCount;
905 * Stand-alone wide day period strings.
907 UnicodeString *fStandaloneWideDayPeriods;
908 int32_t fStandaloneWideDayPeriodsCount;
911 * Stand-alone narrow day period strings.
913 UnicodeString *fStandaloneNarrowDayPeriods;
914 int32_t fStandaloneNarrowDayPeriodsCount;
917 /** valid/actual locale information
918 * these are always ICU locales, so the length should not be a problem
920 char validLocale[ULOC_FULLNAME_CAPACITY];
921 char actualLocale[ULOC_FULLNAME_CAPACITY];
923 DateFormatSymbols(); // default constructor not implemented
926 * Called by the constructors to actually load data from the resources
928 * @param locale The locale to get symbols for.
929 * @param type Calendar Type (as from Calendar::getType())
930 * @param status Input/output parameter, set to success or
931 * failure code upon return.
932 * @param useLastResortData determine if use last resort data
934 void initializeData(const Locale& locale, const char *type,
935 UErrorCode& status, UBool useLastResortData = false);
938 * Copy or alias an array in another object, as appropriate.
940 * @param dstArray the copy destination array.
941 * @param dstCount fill in with the length of 'dstArray'.
942 * @param srcArray the source array to be copied.
943 * @param srcCount the length of items to be copied from the 'srcArray'.
945 static void assignArray(UnicodeString*& dstArray,
947 const UnicodeString* srcArray,
951 * Return true if the given arrays' contents are equal, or if the arrays are
952 * identical (pointers are equal).
954 * @param array1 one array to be compared with.
955 * @param array2 another array to be compared with.
956 * @param count the length of items to be copied.
957 * @return true if the given arrays' contents are equal, or if the arrays are
958 * identical (pointers are equal).
960 static UBool arrayCompare(const UnicodeString* array1,
961 const UnicodeString* array2,
965 * Create a copy, in fZoneStrings, of the given zone strings array. The
966 * member variables fZoneStringsRowCount and fZoneStringsColCount should be
967 * set already by the caller.
969 void createZoneStrings(const UnicodeString *const * otherStrings);
972 * Delete all the storage owned by this object.
977 * Copy all of the other's data to this.
978 * @param other the object to be copied.
980 void copyData(const DateFormatSymbols& other);
983 * Create zone strings array by locale if not yet available
985 void initZoneStringsArray(void);
988 * Delete just the zone strings.
990 void disposeZoneStrings(void);
993 * Returns the date format field index of the pattern character c,
994 * or UDAT_FIELD_COUNT if c is not a pattern character.
996 static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
999 * Returns true if f (with its pattern character repeated count times) is a numeric field.
1001 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
1004 * Returns true if c (repeated count times) is the pattern character for a numeric field.
1006 static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
1008 #ifndef U_HIDE_INTERNAL_API
1010 * Gets a DateFormatSymbols by locale.
1011 * Unlike the constructors which always use gregorian calendar, this
1012 * method uses the calendar in the locale. If the locale contains no
1013 * explicit calendar, this method uses the default calendar for that
1015 * @param locale the locale.
1016 * @param status error returned here.
1017 * @return the new DateFormatSymbols which the caller owns.
1018 * @internal For ICU use only.
1020 static DateFormatSymbols * U_EXPORT2 createForLocale(
1021 const Locale &locale, UErrorCode &status);
1022 #endif /* U_HIDE_INTERNAL_API */
1027 #endif /* #if !UCONFIG_NO_FORMATTING */
1029 #endif /* U_SHOW_CPLUSPLUS_API */