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 !UCONFIG_NO_FORMATTING
27 #include "unicode/calendar.h"
28 #include "unicode/strenum.h"
29 #include "unicode/uobject.h"
30 #include "unicode/locid.h"
31 #include "unicode/udat.h"
32 #include "unicode/ures.h"
36 * \brief C++ API: Symbols for formatting dates.
39 #if U_SHOW_CPLUSPLUS_API
42 /* forward declaration */
43 class SimpleDateFormat
;
47 * DateFormatSymbols is a public class for encapsulating localizable date-time
48 * formatting data -- including timezone data. DateFormatSymbols is used by
49 * DateFormat and SimpleDateFormat.
51 * Rather than first creating a DateFormatSymbols to get a date-time formatter
52 * by using a SimpleDateFormat constructor, clients are encouraged to create a
53 * date-time formatter using the getTimeInstance(), getDateInstance(), or
54 * getDateTimeInstance() method in DateFormat. Each of these methods can return a
55 * date/time formatter initialized with a default format pattern along with the
56 * date-time formatting data for a given or default locale. After a formatter is
57 * created, clients may modify the format pattern using the setPattern function
58 * as so desired. For more information on using these formatter factory
59 * functions, see DateFormat.
61 * If clients decide to create a date-time formatter with a particular format
62 * pattern and locale, they can do so with new SimpleDateFormat(aPattern,
63 * new DateFormatSymbols(aLocale)). This will load the appropriate date-time
64 * formatting data from the locale.
66 * DateFormatSymbols objects are clonable. When clients obtain a
67 * DateFormatSymbols object, they can feel free to modify the date-time
68 * formatting data as necessary. For instance, clients can
69 * replace the localized date-time format pattern characters with the ones that
70 * they feel easy to remember. Or they can change the representative cities
71 * originally picked by default to using their favorite ones.
73 * DateFormatSymbols are not expected to be subclassed. Data for a calendar is
74 * loaded out of resource bundles. The 'type' parameter indicates the type of
75 * calendar, for example, "gregorian" or "japanese". If the type is not gregorian
76 * (or NULL, or an empty string) then the type is appended to the resource name,
77 * for example, 'Eras_japanese' instead of 'Eras'. If the resource 'Eras_japanese' did
78 * not exist (even in root), then this class will fall back to just 'Eras', that is,
79 * Gregorian data. Therefore, the calendar implementor MUST ensure that the root
80 * locale at least contains any resources that are to be particularized for the
83 class U_I18N_API DateFormatSymbols U_FINAL
: public UObject
{
86 * Construct a DateFormatSymbols object by loading format data from
87 * resources for the default locale, in the default calendar (Gregorian).
89 * NOTE: This constructor will never fail; if it cannot get resource
90 * data for the default locale, it will return a last-resort object
91 * based on hard-coded strings.
93 * @param status Status code. Failure
94 * results if the resources for the default cannot be
95 * found or cannot be loaded
98 DateFormatSymbols(UErrorCode
& status
);
101 * Construct a DateFormatSymbols object by loading format data from
102 * resources for the given locale, in the default calendar (Gregorian).
104 * @param locale Locale to load format data from.
105 * @param status Status code. Failure
106 * results if the resources for the locale cannot be
107 * found or cannot be loaded
110 DateFormatSymbols(const Locale
& locale
,
113 #ifndef U_HIDE_INTERNAL_API
115 * Construct a DateFormatSymbols object by loading format data from
116 * resources for the default locale, in the default calendar (Gregorian).
118 * NOTE: This constructor will never fail; if it cannot get resource
119 * data for the default locale, it will return a last-resort object
120 * based on hard-coded strings.
122 * @param type Type of calendar (as returned by Calendar::getType).
123 * Will be used to access the correct set of strings.
124 * (NULL or empty string defaults to "gregorian".)
125 * @param status Status code. Failure
126 * results if the resources for the default cannot be
127 * found or cannot be loaded
130 DateFormatSymbols(const char *type
, UErrorCode
& status
);
133 * Construct a DateFormatSymbols object by loading format data from
134 * resources for the given locale, in the default calendar (Gregorian).
136 * @param locale Locale to load format data from.
137 * @param type Type of calendar (as returned by Calendar::getType).
138 * Will be used to access the correct set of strings.
139 * (NULL or empty string defaults to "gregorian".)
140 * @param status Status code. Failure
141 * results if the resources for the locale cannot be
142 * found or cannot be loaded
145 DateFormatSymbols(const Locale
& locale
,
148 #endif /* U_HIDE_INTERNAL_API */
154 DateFormatSymbols(const DateFormatSymbols
&);
157 * Assignment operator.
160 DateFormatSymbols
& operator=(const DateFormatSymbols
&);
163 * Destructor. This is nonvirtual because this class is not designed to be
167 virtual ~DateFormatSymbols();
170 * Return true if another object is semantically equal to this one.
172 * @param other the DateFormatSymbols object to be compared with.
173 * @return true if other is semantically equal to this.
176 UBool
operator==(const DateFormatSymbols
& other
) const;
179 * Return true if another object is semantically unequal to this one.
181 * @param other the DateFormatSymbols object to be compared with.
182 * @return true if other is semantically unequal to this.
185 UBool
operator!=(const DateFormatSymbols
& other
) const { return !operator==(other
); }
188 * Gets abbreviated era strings. For example: "AD" and "BC".
190 * @param count Filled in with length of the array.
191 * @return the era strings.
194 const UnicodeString
* getEras(int32_t& count
) const;
197 * Sets abbreviated era strings. For example: "AD" and "BC".
198 * @param eras Array of era strings (DateFormatSymbols retains ownership.)
199 * @param count Filled in with length of the array.
202 void setEras(const UnicodeString
* eras
, int32_t count
);
205 * Gets era name strings. For example: "Anno Domini" and "Before Christ".
207 * @param count Filled in with length of the array.
208 * @return the era name strings.
211 const UnicodeString
* getEraNames(int32_t& count
) const;
214 * Sets era name strings. For example: "Anno Domini" and "Before Christ".
215 * @param eraNames Array of era name strings (DateFormatSymbols retains ownership.)
216 * @param count Filled in with length of the array.
219 void setEraNames(const UnicodeString
* eraNames
, int32_t count
);
222 * Gets narrow era strings. For example: "A" and "B".
224 * @param count Filled in with length of the array.
225 * @return the narrow era strings.
228 const UnicodeString
* getNarrowEras(int32_t& count
) const;
231 * Sets narrow era strings. For example: "A" and "B".
232 * @param narrowEras Array of narrow era strings (DateFormatSymbols retains ownership.)
233 * @param count Filled in with length of the array.
236 void setNarrowEras(const UnicodeString
* narrowEras
, int32_t count
);
239 * Gets month strings. For example: "January", "February", etc.
240 * @param count Filled in with length of the array.
241 * @return the month strings. (DateFormatSymbols retains ownership.)
244 const UnicodeString
* getMonths(int32_t& count
) const;
247 * Sets month strings. For example: "January", "February", etc.
249 * @param months the new month strings. (not adopted; caller retains ownership)
250 * @param count Filled in with length of the array.
253 void setMonths(const UnicodeString
* months
, int32_t count
);
256 * Gets short month strings. For example: "Jan", "Feb", etc.
258 * @param count Filled in with length of the array.
259 * @return the short month strings. (DateFormatSymbols retains ownership.)
262 const UnicodeString
* getShortMonths(int32_t& count
) const;
265 * Sets short month strings. For example: "Jan", "Feb", etc.
266 * @param count Filled in with length of the array.
267 * @param shortMonths the new short month strings. (not adopted; caller retains ownership)
270 void setShortMonths(const UnicodeString
* shortMonths
, int32_t count
);
273 * Selector for date formatting context
279 #ifndef U_HIDE_DEPRECATED_API
281 * One more than the highest normal DtContextType value.
282 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
285 #endif // U_HIDE_DEPRECATED_API
289 * Selector for date formatting width
297 * Short width is currently only supported for weekday names.
301 #ifndef U_HIDE_DEPRECATED_API
303 * One more than the highest normal DtWidthType value.
304 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
307 #endif // U_HIDE_DEPRECATED_API
311 * Gets month strings by width and context. For example: "January", "February", etc.
312 * @param count Filled in with length of the array.
313 * @param context The formatting context, either FORMAT or STANDALONE
314 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
315 * @return the month strings. (DateFormatSymbols retains ownership.)
318 const UnicodeString
* getMonths(int32_t& count
, DtContextType context
, DtWidthType width
) const;
321 * Sets month strings by width and context. For example: "January", "February", etc.
323 * @param months The new month strings. (not adopted; caller retains ownership)
324 * @param count Filled in with length of the array.
325 * @param context The formatting context, either FORMAT or STANDALONE
326 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
329 void setMonths(const UnicodeString
* months
, int32_t count
, DtContextType context
, DtWidthType width
);
332 * Gets wide weekday strings. For example: "Sunday", "Monday", etc.
333 * @param count Filled in with length of the array.
334 * @return the weekday strings. (DateFormatSymbols retains ownership.)
337 const UnicodeString
* getWeekdays(int32_t& count
) const;
341 * Sets wide weekday strings. For example: "Sunday", "Monday", etc.
342 * @param weekdays the new weekday strings. (not adopted; caller retains ownership)
343 * @param count Filled in with length of the array.
346 void setWeekdays(const UnicodeString
* weekdays
, int32_t count
);
349 * Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
350 * misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
351 * @param count Filled in with length of the array.
352 * @return the abbreviated weekday strings. (DateFormatSymbols retains ownership.)
355 const UnicodeString
* getShortWeekdays(int32_t& count
) const;
358 * Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
359 * misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
360 * @param abbrevWeekdays the new abbreviated weekday strings. (not adopted; caller retains ownership)
361 * @param count Filled in with length of the array.
364 void setShortWeekdays(const UnicodeString
* abbrevWeekdays
, int32_t count
);
367 * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
368 * @param count Filled in with length of the array.
369 * @param context The formatting context, either FORMAT or STANDALONE
370 * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
371 * @return the month strings. (DateFormatSymbols retains ownership.)
374 const UnicodeString
* getWeekdays(int32_t& count
, DtContextType context
, DtWidthType width
) const;
377 * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc.
378 * @param weekdays The new weekday strings. (not adopted; caller retains ownership)
379 * @param count Filled in with length of the array.
380 * @param context The formatting context, either FORMAT or STANDALONE
381 * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
384 void setWeekdays(const UnicodeString
* weekdays
, int32_t count
, DtContextType context
, DtWidthType width
);
387 * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
388 * @param count Filled in with length of the array.
389 * @param context The formatting context, either FORMAT or STANDALONE
390 * @param width The width of returned strings, either WIDE or ABBREVIATED. There
391 * are no NARROW quarters.
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 or ABBREVIATED. There
404 * are no NARROW quarters.
407 void setQuarters(const UnicodeString
* quarters
, int32_t count
, DtContextType context
, DtWidthType width
);
410 * Gets AM/PM strings. For example: "AM" and "PM".
411 * @param count Filled in with length of the array.
412 * @return the weekday strings. (DateFormatSymbols retains ownership.)
415 const UnicodeString
* getAmPmStrings(int32_t& count
) const;
418 * Sets ampm strings. For example: "AM" and "PM".
419 * @param ampms the new ampm strings. (not adopted; caller retains ownership)
420 * @param count Filled in with length of the array.
423 void setAmPmStrings(const UnicodeString
* ampms
, int32_t count
);
425 #ifndef U_HIDE_INTERNAL_API
427 * This default time separator is used for formatting when the locale
428 * doesn't specify any time separator, and always recognized when parsing.
431 static const char16_t DEFAULT_TIME_SEPARATOR
= 0x003a; // ':'
434 * This alternate time separator is always recognized when parsing.
437 static const char16_t ALTERNATE_TIME_SEPARATOR
= 0x002e; // '.'
440 * Gets the time separator string. For example: ":".
441 * @param result Output param which will receive the time separator string.
442 * @return A reference to 'result'.
445 UnicodeString
& getTimeSeparatorString(UnicodeString
& result
) const;
448 * Sets the time separator string. For example: ":".
449 * @param newTimeSeparator the new time separator string.
452 void setTimeSeparatorString(const UnicodeString
& newTimeSeparator
);
453 #endif /* U_HIDE_INTERNAL_API */
456 * Gets cyclic year name strings if the calendar has them, by width and context.
457 * For example: "jia-zi", "yi-chou", etc.
458 * @param count Filled in with length of the array.
459 * @param context The usage context: FORMAT, STANDALONE.
460 * @param width The requested name width: WIDE, ABBREVIATED, NARROW.
461 * @return The year name strings (DateFormatSymbols retains ownership),
462 * or null if they are not available for this calendar.
465 const UnicodeString
* getYearNames(int32_t& count
,
466 DtContextType context
, DtWidthType width
) const;
469 * Sets cyclic year name strings by width and context. For example: "jia-zi", "yi-chou", etc.
471 * @param yearNames The new cyclic year name strings (not adopted; caller retains ownership).
472 * @param count The length of the array.
473 * @param context The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
474 * @param width The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
477 void setYearNames(const UnicodeString
* yearNames
, int32_t count
,
478 DtContextType context
, DtWidthType width
);
481 * Gets calendar zodiac name strings if the calendar has them, by width and context.
482 * For example: "Rat", "Ox", "Tiger", etc.
483 * @param count Filled in with length of the array.
484 * @param context The usage context: FORMAT, STANDALONE.
485 * @param width The requested name width: WIDE, ABBREVIATED, NARROW.
486 * @return The zodiac name strings (DateFormatSymbols retains ownership),
487 * or null if they are not available for this calendar.
490 const UnicodeString
* getZodiacNames(int32_t& count
,
491 DtContextType context
, DtWidthType width
) const;
494 * Sets calendar zodiac name strings by width and context. For example: "Rat", "Ox", "Tiger", etc.
496 * @param zodiacNames The new zodiac name strings (not adopted; caller retains ownership).
497 * @param count The length of the array.
498 * @param context The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
499 * @param width The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
502 void setZodiacNames(const UnicodeString
* zodiacNames
, int32_t count
,
503 DtContextType context
, DtWidthType width
);
505 #ifndef U_HIDE_INTERNAL_API
507 * Somewhat temporary constants for leap month pattern types, adequate for supporting
508 * just leap month patterns as needed for Chinese lunar calendar.
509 * Eventually we will add full support for different month pattern types (needed for
510 * other calendars such as Hindu) at which point this approach will be replaced by a
511 * more complete approach.
514 enum EMonthPatternType
516 kLeapMonthPatternFormatWide
,
517 kLeapMonthPatternFormatAbbrev
,
518 kLeapMonthPatternFormatNarrow
,
519 kLeapMonthPatternStandaloneWide
,
520 kLeapMonthPatternStandaloneAbbrev
,
521 kLeapMonthPatternStandaloneNarrow
,
522 kLeapMonthPatternNumeric
,
527 * Somewhat temporary function for getting complete set of leap month patterns for all
528 * contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar
529 * does not have leap month patterns. Note, there is currently no setter for this.
530 * Eventually we will add full support for different month pattern types (needed for
531 * other calendars such as Hindu) at which point this approach will be replaced by a
532 * more complete approach.
533 * @param count Filled in with length of the array (may be 0).
534 * @return The leap month patterns (DateFormatSymbols retains ownership).
535 * May be NULL if there are no leap month patterns for this calendar.
538 const UnicodeString
* getLeapMonthPatterns(int32_t& count
) const;
540 #endif /* U_HIDE_INTERNAL_API */
542 #ifndef U_HIDE_DEPRECATED_API
544 * Gets timezone strings. These strings are stored in a 2-dimensional array.
545 * @param rowCount Output param to receive number of rows.
546 * @param columnCount Output param to receive number of columns.
547 * @return The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)
548 * @deprecated ICU 3.6
550 const UnicodeString
** getZoneStrings(int32_t& rowCount
, int32_t& columnCount
) const;
551 #endif /* U_HIDE_DEPRECATED_API */
554 * Sets timezone strings. These strings are stored in a 2-dimensional array.
555 * <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in
556 * a DateFormatSymbols. Therefore, the time zone strings set by this mthod
557 * have no effects in an instance of SimpleDateFormat for formatting time
559 * @param strings The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
560 * @param rowCount The number of rows (count of first index).
561 * @param columnCount The number of columns (count of second index).
564 void setZoneStrings(const UnicodeString
* const* strings
, int32_t rowCount
, int32_t columnCount
);
567 * Get the non-localized date-time pattern characters.
568 * @return the non-localized date-time pattern characters
571 static const char16_t * U_EXPORT2
getPatternUChars(void);
574 * Gets localized date-time pattern characters. For example: 'u', 't', etc.
576 * Note: ICU no longer provides localized date-time pattern characters for a locale
577 * starting ICU 3.8. This method returns the non-localized date-time pattern
578 * characters unless user defined localized data is set by setLocalPatternChars.
579 * @param result Output param which will receive the localized date-time pattern characters.
580 * @return A reference to 'result'.
583 UnicodeString
& getLocalPatternChars(UnicodeString
& result
) const;
586 * Sets localized date-time pattern characters. For example: 'u', 't', etc.
587 * @param newLocalPatternChars the new localized date-time
588 * pattern characters.
591 void setLocalPatternChars(const UnicodeString
& newLocalPatternChars
);
594 * Returns the locale for this object. Two flavors are available:
595 * valid and actual locale.
598 Locale
getLocale(ULocDataLocaleType type
, UErrorCode
& status
) const;
600 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
601 they are needed for .h file declarations. */
603 * Constants for capitalization context usage types.
606 enum ECapitalizationContextUsageType
608 #ifndef U_HIDE_INTERNAL_API
609 kCapContextUsageOther
= 0,
610 kCapContextUsageMonthFormat
, /* except narrow */
611 kCapContextUsageMonthStandalone
, /* except narrow */
612 kCapContextUsageMonthNarrow
,
613 kCapContextUsageDayFormat
, /* except narrow */
614 kCapContextUsageDayStandalone
, /* except narrow */
615 kCapContextUsageDayNarrow
,
616 kCapContextUsageEraWide
,
617 kCapContextUsageEraAbbrev
,
618 kCapContextUsageEraNarrow
,
619 kCapContextUsageZoneLong
,
620 kCapContextUsageZoneShort
,
621 kCapContextUsageMetazoneLong
,
622 kCapContextUsageMetazoneShort
,
623 #endif /* U_HIDE_INTERNAL_API */
624 kCapContextUsageTypeCount
= 14
628 * ICU "poor man's RTTI", returns a UClassID for the actual class.
632 virtual UClassID
getDynamicClassID() const;
635 * ICU "poor man's RTTI", returns a UClassID for this class.
639 static UClassID U_EXPORT2
getStaticClassID();
643 friend class SimpleDateFormat
;
644 friend class DateFormatSymbolsSingleSetter
; // see udat.cpp
647 * Abbreviated era strings. For example: "AD" and "BC".
649 UnicodeString
* fEras
;
653 * Era name strings. For example: "Anno Domini" and "Before Christ".
655 UnicodeString
* fEraNames
;
656 int32_t fEraNamesCount
;
659 * Narrow era strings. For example: "A" and "B".
661 UnicodeString
* fNarrowEras
;
662 int32_t fNarrowErasCount
;
665 * Month strings. For example: "January", "February", etc.
667 UnicodeString
* fMonths
;
668 int32_t fMonthsCount
;
671 * Short month strings. For example: "Jan", "Feb", etc.
673 UnicodeString
* fShortMonths
;
674 int32_t fShortMonthsCount
;
677 * Narrow month strings. For example: "J", "F", etc.
679 UnicodeString
* fNarrowMonths
;
680 int32_t fNarrowMonthsCount
;
683 * Standalone Month strings. For example: "January", "February", etc.
685 UnicodeString
* fStandaloneMonths
;
686 int32_t fStandaloneMonthsCount
;
689 * Standalone Short month strings. For example: "Jan", "Feb", etc.
691 UnicodeString
* fStandaloneShortMonths
;
692 int32_t fStandaloneShortMonthsCount
;
695 * Standalone Narrow month strings. For example: "J", "F", etc.
697 UnicodeString
* fStandaloneNarrowMonths
;
698 int32_t fStandaloneNarrowMonthsCount
;
701 * CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc.
703 UnicodeString
* fWeekdays
;
704 int32_t fWeekdaysCount
;
707 * CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
709 UnicodeString
* fShortWeekdays
;
710 int32_t fShortWeekdaysCount
;
713 * CLDR-style format short weekday strings. For example: "Su", "Mo", etc.
715 UnicodeString
* fShorterWeekdays
;
716 int32_t fShorterWeekdaysCount
;
719 * CLDR-style format narrow weekday strings. For example: "S", "M", etc.
721 UnicodeString
* fNarrowWeekdays
;
722 int32_t fNarrowWeekdaysCount
;
725 * CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc.
727 UnicodeString
* fStandaloneWeekdays
;
728 int32_t fStandaloneWeekdaysCount
;
731 * CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
733 UnicodeString
* fStandaloneShortWeekdays
;
734 int32_t fStandaloneShortWeekdaysCount
;
737 * CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc.
739 UnicodeString
* fStandaloneShorterWeekdays
;
740 int32_t fStandaloneShorterWeekdaysCount
;
743 * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
745 UnicodeString
* fStandaloneNarrowWeekdays
;
746 int32_t fStandaloneNarrowWeekdaysCount
;
749 * Ampm strings. For example: "AM" and "PM".
751 UnicodeString
* fAmPms
;
755 * Narrow Ampm strings. For example: "a" and "p".
757 UnicodeString
* fNarrowAmPms
;
758 int32_t fNarrowAmPmsCount
;
761 * Time separator string. For example: ":".
763 UnicodeString fTimeSeparator
;
766 * Quarter strings. For example: "1st quarter", "2nd quarter", etc.
768 UnicodeString
*fQuarters
;
769 int32_t fQuartersCount
;
772 * Short quarters. For example: "Q1", "Q2", etc.
774 UnicodeString
*fShortQuarters
;
775 int32_t fShortQuartersCount
;
778 * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc.
780 UnicodeString
*fStandaloneQuarters
;
781 int32_t fStandaloneQuartersCount
;
784 * Standalone short quarter strings. For example: "Q1", "Q2", etc.
786 UnicodeString
*fStandaloneShortQuarters
;
787 int32_t fStandaloneShortQuartersCount
;
790 * All leap month patterns, for example "{0}bis".
792 UnicodeString
*fLeapMonthPatterns
;
793 int32_t fLeapMonthPatternsCount
;
796 * Cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai";
797 * currently we only have data for format/abbreviated.
798 * For the others, just get from format/abbreviated, ignore set.
800 UnicodeString
*fShortYearNames
;
801 int32_t fShortYearNamesCount
;
804 * Cyclic zodiac names, for example "Rat", "Ox", "Tiger", etc.;
805 * currently we only have data for format/abbreviated.
806 * For the others, just get from format/abbreviated, ignore set.
808 UnicodeString
*fShortZodiacNames
;
809 int32_t fShortZodiacNamesCount
;
812 * Localized names of time zones in this locale. This is a
813 * two-dimensional array of strings of size n by m,
814 * where m is at least 5 and up to 7. Each of the n rows is an
815 * entry containing the localized names for a single TimeZone.
817 * Each such row contains (with i ranging from 0..n-1):
819 * zoneStrings[i][0] - time zone ID
820 * example: America/Los_Angeles
821 * zoneStrings[i][1] - long name of zone in standard time
822 * example: Pacific Standard Time
823 * zoneStrings[i][2] - short name of zone in standard time
825 * zoneStrings[i][3] - long name of zone in daylight savings time
826 * example: Pacific Daylight Time
827 * zoneStrings[i][4] - short name of zone in daylight savings time
829 * zoneStrings[i][5] - location name of zone
830 * example: United States (Los Angeles)
831 * zoneStrings[i][6] - long generic name of zone
832 * example: Pacific Time
833 * zoneStrings[i][7] - short generic of zone
836 * The zone ID is not localized; it corresponds to the ID
837 * value associated with a system time zone object. All other entries
838 * are localized names. If a zone does not implement daylight savings
839 * time, the daylight savings time names are ignored.
841 * Note:CLDR 1.5 introduced metazone and its historical mappings.
842 * This simple two-dimensional array is no longer sufficient to represent
843 * localized names and its historic changes. Since ICU 3.8.1, localized
844 * zone names extracted from ICU locale data is stored in a ZoneStringFormat
845 * instance. But we still need to support the old way of customizing
846 * localized zone names, so we keep this field for the purpose.
848 UnicodeString
**fZoneStrings
; // Zone string array set by setZoneStrings
849 UnicodeString
**fLocaleZoneStrings
; // Zone string array created by the locale
850 int32_t fZoneStringsRowCount
;
851 int32_t fZoneStringsColCount
;
853 Locale fZSFLocale
; // Locale used for getting ZoneStringFormat
856 * Localized date-time pattern characters. For example: use 'u' as 'y'.
858 UnicodeString fLocalPatternChars
;
861 * Capitalization transforms. For each usage type, the first array element indicates
862 * whether to titlecase for uiListOrMenu context, the second indicates whether to
863 * titlecase for stand-alone context.
865 UBool fCapitalization
[kCapContextUsageTypeCount
][2];
868 * Abbreviated (== short) day period strings.
870 UnicodeString
*fAbbreviatedDayPeriods
;
871 int32_t fAbbreviatedDayPeriodsCount
;
874 * Wide day period strings.
876 UnicodeString
*fWideDayPeriods
;
877 int32_t fWideDayPeriodsCount
;
880 * Narrow day period strings.
882 UnicodeString
*fNarrowDayPeriods
;
883 int32_t fNarrowDayPeriodsCount
;
886 * Stand-alone abbreviated (== short) day period strings.
888 UnicodeString
*fStandaloneAbbreviatedDayPeriods
;
889 int32_t fStandaloneAbbreviatedDayPeriodsCount
;
892 * Stand-alone wide day period strings.
894 UnicodeString
*fStandaloneWideDayPeriods
;
895 int32_t fStandaloneWideDayPeriodsCount
;
898 * Stand-alone narrow day period strings.
900 UnicodeString
*fStandaloneNarrowDayPeriods
;
901 int32_t fStandaloneNarrowDayPeriodsCount
;
904 /** valid/actual locale information
905 * these are always ICU locales, so the length should not be a problem
907 char validLocale
[ULOC_FULLNAME_CAPACITY
];
908 char actualLocale
[ULOC_FULLNAME_CAPACITY
];
910 DateFormatSymbols(); // default constructor not implemented
913 * Called by the constructors to actually load data from the resources
915 * @param locale The locale to get symbols for.
916 * @param type Calendar Type (as from Calendar::getType())
917 * @param status Input/output parameter, set to success or
918 * failure code upon return.
919 * @param useLastResortData determine if use last resort data
921 void initializeData(const Locale
& locale
, const char *type
, UErrorCode
& status
, UBool useLastResortData
= FALSE
);
924 * Copy or alias an array in another object, as appropriate.
926 * @param dstArray the copy destination array.
927 * @param dstCount fill in with the lenth of 'dstArray'.
928 * @param srcArray the source array to be copied.
929 * @param srcCount the length of items to be copied from the 'srcArray'.
931 static void assignArray(UnicodeString
*& dstArray
,
933 const UnicodeString
* srcArray
,
937 * Return true if the given arrays' contents are equal, or if the arrays are
938 * identical (pointers are equal).
940 * @param array1 one array to be compared with.
941 * @param array2 another array to be compared with.
942 * @param count the length of items to be copied.
943 * @return true if the given arrays' contents are equal, or if the arrays are
944 * identical (pointers are equal).
946 static UBool
arrayCompare(const UnicodeString
* array1
,
947 const UnicodeString
* array2
,
951 * Create a copy, in fZoneStrings, of the given zone strings array. The
952 * member variables fZoneStringsRowCount and fZoneStringsColCount should be
953 * set already by the caller.
955 void createZoneStrings(const UnicodeString
*const * otherStrings
);
958 * Delete all the storage owned by this object.
963 * Copy all of the other's data to this.
964 * @param other the object to be copied.
966 void copyData(const DateFormatSymbols
& other
);
969 * Create zone strings array by locale if not yet available
971 void initZoneStringsArray(void);
974 * Delete just the zone strings.
976 void disposeZoneStrings(void);
979 * Returns the date format field index of the pattern character c,
980 * or UDAT_FIELD_COUNT if c is not a pattern character.
982 static UDateFormatField U_EXPORT2
getPatternCharIndex(char16_t c
);
985 * Returns TRUE if f (with its pattern character repeated count times) is a numeric field.
987 static UBool U_EXPORT2
isNumericField(UDateFormatField f
, int32_t count
);
990 * Returns TRUE if c (repeated count times) is the pattern character for a numeric field.
992 static UBool U_EXPORT2
isNumericPatternChar(char16_t c
, int32_t count
);
994 #ifndef U_HIDE_INTERNAL_API
996 * Gets a DateFormatSymbols by locale.
997 * Unlike the constructors which always use gregorian calendar, this
998 * method uses the calendar in the locale. If the locale contains no
999 * explicit calendar, this method uses the default calendar for that
1001 * @param locale the locale.
1002 * @param status error returned here.
1003 * @return the new DateFormatSymbols which the caller owns.
1004 * @internal For ICU use only.
1006 static DateFormatSymbols
* U_EXPORT2
createForLocale(
1007 const Locale
&locale
, UErrorCode
&status
);
1011 * Get whether to capitalize based on usage.
1012 * @param usage the usage.
1013 * @param context 0 for menu, 1 for standalone
1014 * @return TRUE to capitalize, FALSE otherwise
1015 * @internal For ICU use only.
1017 UBool
capitalizeForUsage(ECapitalizationContextUsageType usage
, int32_t context
) const;
1018 #endif /* U_HIDE_INTERNAL_API */
1022 DateFormatSymbols::capitalizeForUsage(DateFormatSymbols::ECapitalizationContextUsageType usage
, int32_t context
) const
1024 return fCapitalization
[usage
][context
];
1028 #endif // U_SHOW_CPLUSPLUS_API
1030 #endif /* #if !UCONFIG_NO_FORMATTING */