2 ********************************************************************************
3 * Copyright (C) 1997-2016, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************************
9 * Modification History:
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 ********************************************************************************
21 #include "unicode/utypes.h"
23 #if !UCONFIG_NO_FORMATTING
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"
33 * \brief C++ API: Symbols for formatting dates.
38 /* forward declaration */
39 class SimpleDateFormat
;
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.
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.
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.
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.
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
79 class U_I18N_API DateFormatSymbols U_FINAL
: public UObject
{
82 * Construct a DateFormatSymbols object by loading format data from
83 * resources for the default locale, in the default calendar (Gregorian).
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.
89 * @param status Status code. Failure
90 * results if the resources for the default cannot be
91 * found or cannot be loaded
94 DateFormatSymbols(UErrorCode
& status
);
97 * Construct a DateFormatSymbols object by loading format data from
98 * resources for the given locale, in the default calendar (Gregorian).
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
106 DateFormatSymbols(const Locale
& locale
,
109 #ifndef U_HIDE_INTERNAL_API
111 * Construct a DateFormatSymbols object by loading format data from
112 * resources for the default locale, in the default calendar (Gregorian).
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.
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
126 DateFormatSymbols(const char *type
, UErrorCode
& status
);
129 * Construct a DateFormatSymbols object by loading format data from
130 * resources for the given locale, in the default calendar (Gregorian).
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
141 DateFormatSymbols(const Locale
& locale
,
144 #endif /* U_HIDE_INTERNAL_API */
150 DateFormatSymbols(const DateFormatSymbols
&);
153 * Assignment operator.
156 DateFormatSymbols
& operator=(const DateFormatSymbols
&);
159 * Destructor. This is nonvirtual because this class is not designed to be
163 virtual ~DateFormatSymbols();
166 * Return true if another object is semantically equal to this one.
168 * @param other the DateFormatSymbols object to be compared with.
169 * @return true if other is semantically equal to this.
172 UBool
operator==(const DateFormatSymbols
& other
) const;
175 * Return true if another object is semantically unequal to this one.
177 * @param other the DateFormatSymbols object to be compared with.
178 * @return true if other is semantically unequal to this.
181 UBool
operator!=(const DateFormatSymbols
& other
) const { return !operator==(other
); }
184 * Gets abbreviated era strings. For example: "AD" and "BC".
186 * @param count Filled in with length of the array.
187 * @return the era strings.
190 const UnicodeString
* getEras(int32_t& count
) const;
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.
198 void setEras(const UnicodeString
* eras
, int32_t count
);
201 * Gets era name strings. For example: "Anno Domini" and "Before Christ".
203 * @param count Filled in with length of the array.
204 * @return the era name strings.
207 const UnicodeString
* getEraNames(int32_t& count
) const;
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.
215 void setEraNames(const UnicodeString
* eraNames
, int32_t count
);
218 * Gets narrow era strings. For example: "A" and "B".
220 * @param count Filled in with length of the array.
221 * @return the narrow era strings.
224 const UnicodeString
* getNarrowEras(int32_t& count
) const;
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.
232 void setNarrowEras(const UnicodeString
* narrowEras
, int32_t count
);
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.)
240 const UnicodeString
* getMonths(int32_t& count
) const;
243 * Sets month strings. For example: "January", "February", etc.
245 * @param months the new month strings. (not adopted; caller retains ownership)
246 * @param count Filled in with length of the array.
249 void setMonths(const UnicodeString
* months
, int32_t count
);
252 * Gets short month strings. For example: "Jan", "Feb", etc.
254 * @param count Filled in with length of the array.
255 * @return the short month strings. (DateFormatSymbols retains ownership.)
258 const UnicodeString
* getShortMonths(int32_t& count
) const;
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)
266 void setShortMonths(const UnicodeString
* shortMonths
, int32_t count
);
269 * Selector for date formatting context
279 * Selector for date formatting width
287 * Short width is currently only supported for weekday names.
297 * Gets month strings by width and context. For example: "January", "February", etc.
298 * @param count Filled in with length of the array.
299 * @param context The formatting context, either FORMAT or STANDALONE
300 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
301 * @return the month strings. (DateFormatSymbols retains ownership.)
304 const UnicodeString
* getMonths(int32_t& count
, DtContextType context
, DtWidthType width
) const;
307 * Sets month strings by width and context. For example: "January", "February", etc.
309 * @param months The new month strings. (not adopted; caller retains ownership)
310 * @param count Filled in with length of the array.
311 * @param context The formatting context, either FORMAT or STANDALONE
312 * @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
315 void setMonths(const UnicodeString
* months
, int32_t count
, DtContextType context
, DtWidthType width
);
318 * Gets wide weekday strings. For example: "Sunday", "Monday", etc.
319 * @param count Filled in with length of the array.
320 * @return the weekday strings. (DateFormatSymbols retains ownership.)
323 const UnicodeString
* getWeekdays(int32_t& count
) const;
327 * Sets wide weekday strings. For example: "Sunday", "Monday", etc.
328 * @param weekdays the new weekday strings. (not adopted; caller retains ownership)
329 * @param count Filled in with length of the array.
332 void setWeekdays(const UnicodeString
* weekdays
, int32_t count
);
335 * Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
336 * misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
337 * @param count Filled in with length of the array.
338 * @return the abbreviated weekday strings. (DateFormatSymbols retains ownership.)
341 const UnicodeString
* getShortWeekdays(int32_t& count
) const;
344 * Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
345 * misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
346 * @param abbrevWeekdays the new abbreviated weekday strings. (not adopted; caller retains ownership)
347 * @param count Filled in with length of the array.
350 void setShortWeekdays(const UnicodeString
* abbrevWeekdays
, int32_t count
);
353 * Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
354 * @param count Filled in with length of the array.
355 * @param context The formatting context, either FORMAT or STANDALONE
356 * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
357 * @return the month strings. (DateFormatSymbols retains ownership.)
360 const UnicodeString
* getWeekdays(int32_t& count
, DtContextType context
, DtWidthType width
) const;
363 * Sets weekday strings by width and context. For example: "Sunday", "Monday", etc.
364 * @param weekdays The new weekday strings. (not adopted; caller retains ownership)
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, ABBREVIATED, SHORT, or NARROW
370 void setWeekdays(const UnicodeString
* weekdays
, int32_t count
, DtContextType context
, DtWidthType width
);
373 * Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
374 * @param count Filled in with length of the array.
375 * @param context The formatting context, either FORMAT or STANDALONE
376 * @param width The width of returned strings, either WIDE or ABBREVIATED. There
377 * are no NARROW quarters.
378 * @return the quarter strings. (DateFormatSymbols retains ownership.)
381 const UnicodeString
* getQuarters(int32_t& count
, DtContextType context
, DtWidthType width
) const;
384 * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
386 * @param quarters The new quarter strings. (not adopted; caller retains ownership)
387 * @param count Filled in with length of the array.
388 * @param context The formatting context, either FORMAT or STANDALONE
389 * @param width The width of returned strings, either WIDE or ABBREVIATED. There
390 * are no NARROW quarters.
393 void setQuarters(const UnicodeString
* quarters
, int32_t count
, DtContextType context
, DtWidthType width
);
396 * Gets AM/PM strings. For example: "AM" and "PM".
397 * @param count Filled in with length of the array.
398 * @return the weekday strings. (DateFormatSymbols retains ownership.)
401 const UnicodeString
* getAmPmStrings(int32_t& count
) const;
404 * Sets ampm strings. For example: "AM" and "PM".
405 * @param ampms the new ampm strings. (not adopted; caller retains ownership)
406 * @param count Filled in with length of the array.
409 void setAmPmStrings(const UnicodeString
* ampms
, int32_t count
);
411 #ifndef U_HIDE_INTERNAL_API
413 * This default time separator is used for formatting when the locale
414 * doesn't specify any time separator, and always recognized when parsing.
417 static const UChar DEFAULT_TIME_SEPARATOR
= 0x003a; // ':'
420 * This alternate time separator is always recognized when parsing.
423 static const UChar ALTERNATE_TIME_SEPARATOR
= 0x002e; // '.'
426 * Gets the time separator string. For example: ":".
427 * @param result Output param which will receive the time separator string.
428 * @return A reference to 'result'.
431 UnicodeString
& getTimeSeparatorString(UnicodeString
& result
) const;
434 * Sets the time separator string. For example: ":".
435 * @param newTimeSeparator the new time separator string.
438 void setTimeSeparatorString(const UnicodeString
& newTimeSeparator
);
439 #endif /* U_HIDE_INTERNAL_API */
442 * Gets cyclic year name strings if the calendar has them, by width and context.
443 * For example: "jia-zi", "yi-chou", etc.
444 * @param count Filled in with length of the array.
445 * @param context The usage context: FORMAT, STANDALONE.
446 * @param width The requested name width: WIDE, ABBREVIATED, NARROW.
447 * @return The year name strings (DateFormatSymbols retains ownership),
448 * or null if they are not available for this calendar.
451 const UnicodeString
* getYearNames(int32_t& count
,
452 DtContextType context
, DtWidthType width
) const;
455 * Sets cyclic year name strings by width and context. For example: "jia-zi", "yi-chou", etc.
457 * @param yearNames The new cyclic year name strings (not adopted; caller retains ownership).
458 * @param count The length of the array.
459 * @param context The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
460 * @param width The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
463 void setYearNames(const UnicodeString
* yearNames
, int32_t count
,
464 DtContextType context
, DtWidthType width
);
467 * Gets calendar zodiac name strings if the calendar has them, by width and context.
468 * For example: "Rat", "Ox", "Tiger", etc.
469 * @param count Filled in with length of the array.
470 * @param context The usage context: FORMAT, STANDALONE.
471 * @param width The requested name width: WIDE, ABBREVIATED, NARROW.
472 * @return The zodiac name strings (DateFormatSymbols retains ownership),
473 * or null if they are not available for this calendar.
476 const UnicodeString
* getZodiacNames(int32_t& count
,
477 DtContextType context
, DtWidthType width
) const;
480 * Sets calendar zodiac name strings by width and context. For example: "Rat", "Ox", "Tiger", etc.
482 * @param zodiacNames The new zodiac name strings (not adopted; caller retains ownership).
483 * @param count The length of the array.
484 * @param context The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
485 * @param width The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
488 void setZodiacNames(const UnicodeString
* zodiacNames
, int32_t count
,
489 DtContextType context
, DtWidthType width
);
491 #ifndef U_HIDE_INTERNAL_API
493 * Somewhat temporary constants for leap month pattern types, adequate for supporting
494 * just leap month patterns as needed for Chinese lunar calendar.
495 * Eventually we will add full support for different month pattern types (needed for
496 * other calendars such as Hindu) at which point this approach will be replaced by a
497 * more complete approach.
500 enum EMonthPatternType
502 kLeapMonthPatternFormatWide
,
503 kLeapMonthPatternFormatAbbrev
,
504 kLeapMonthPatternFormatNarrow
,
505 kLeapMonthPatternStandaloneWide
,
506 kLeapMonthPatternStandaloneAbbrev
,
507 kLeapMonthPatternStandaloneNarrow
,
508 kLeapMonthPatternNumeric
,
513 * Somewhat temporary function for getting complete set of leap month patterns for all
514 * contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar
515 * does not have leap month patterns. Note, there is currently no setter for this.
516 * Eventually we will add full support for different month pattern types (needed for
517 * other calendars such as Hindu) at which point this approach will be replaced by a
518 * more complete approach.
519 * @param count Filled in with length of the array (may be 0).
520 * @return The leap month patterns (DateFormatSymbols retains ownership).
521 * May be NULL if there are no leap month patterns for this calendar.
524 const UnicodeString
* getLeapMonthPatterns(int32_t& count
) const;
526 #endif /* U_HIDE_INTERNAL_API */
528 #ifndef U_HIDE_DEPRECATED_API
530 * Gets timezone strings. These strings are stored in a 2-dimensional array.
531 * @param rowCount Output param to receive number of rows.
532 * @param columnCount Output param to receive number of columns.
533 * @return The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)
534 * @deprecated ICU 3.6
536 const UnicodeString
** getZoneStrings(int32_t& rowCount
, int32_t& columnCount
) const;
537 #endif /* U_HIDE_DEPRECATED_API */
540 * Sets timezone strings. These strings are stored in a 2-dimensional array.
541 * <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in
542 * a DateFormatSymbols. Therefore, the time zone strings set by this mthod
543 * have no effects in an instance of SimpleDateFormat for formatting time
545 * @param strings The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
546 * @param rowCount The number of rows (count of first index).
547 * @param columnCount The number of columns (count of second index).
550 void setZoneStrings(const UnicodeString
* const* strings
, int32_t rowCount
, int32_t columnCount
);
553 * Get the non-localized date-time pattern characters.
554 * @return the non-localized date-time pattern characters
557 static const UChar
* U_EXPORT2
getPatternUChars(void);
560 * Gets localized date-time pattern characters. For example: 'u', 't', etc.
562 * Note: ICU no longer provides localized date-time pattern characters for a locale
563 * starting ICU 3.8. This method returns the non-localized date-time pattern
564 * characters unless user defined localized data is set by setLocalPatternChars.
565 * @param result Output param which will receive the localized date-time pattern characters.
566 * @return A reference to 'result'.
569 UnicodeString
& getLocalPatternChars(UnicodeString
& result
) const;
572 * Sets localized date-time pattern characters. For example: 'u', 't', etc.
573 * @param newLocalPatternChars the new localized date-time
574 * pattern characters.
577 void setLocalPatternChars(const UnicodeString
& newLocalPatternChars
);
580 * Returns the locale for this object. Two flavors are available:
581 * valid and actual locale.
584 Locale
getLocale(ULocDataLocaleType type
, UErrorCode
& status
) const;
586 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
587 they are needed for .h file declarations. */
589 * Constants for capitalization context usage types.
592 enum ECapitalizationContextUsageType
594 #ifndef U_HIDE_INTERNAL_API
595 kCapContextUsageOther
= 0,
596 kCapContextUsageMonthFormat
, /* except narrow */
597 kCapContextUsageMonthStandalone
, /* except narrow */
598 kCapContextUsageMonthNarrow
,
599 kCapContextUsageDayFormat
, /* except narrow */
600 kCapContextUsageDayStandalone
, /* except narrow */
601 kCapContextUsageDayNarrow
,
602 kCapContextUsageEraWide
,
603 kCapContextUsageEraAbbrev
,
604 kCapContextUsageEraNarrow
,
605 kCapContextUsageZoneLong
,
606 kCapContextUsageZoneShort
,
607 kCapContextUsageMetazoneLong
,
608 kCapContextUsageMetazoneShort
,
609 #endif /* U_HIDE_INTERNAL_API */
610 kCapContextUsageTypeCount
= 14
614 * ICU "poor man's RTTI", returns a UClassID for the actual class.
618 virtual UClassID
getDynamicClassID() const;
621 * ICU "poor man's RTTI", returns a UClassID for this class.
625 static UClassID U_EXPORT2
getStaticClassID();
629 friend class SimpleDateFormat
;
630 friend class DateFormatSymbolsSingleSetter
; // see udat.cpp
633 * Abbreviated era strings. For example: "AD" and "BC".
635 UnicodeString
* fEras
;
639 * Era name strings. For example: "Anno Domini" and "Before Christ".
641 UnicodeString
* fEraNames
;
642 int32_t fEraNamesCount
;
645 * Narrow era strings. For example: "A" and "B".
647 UnicodeString
* fNarrowEras
;
648 int32_t fNarrowErasCount
;
651 * Month strings. For example: "January", "February", etc.
653 UnicodeString
* fMonths
;
654 int32_t fMonthsCount
;
657 * Short month strings. For example: "Jan", "Feb", etc.
659 UnicodeString
* fShortMonths
;
660 int32_t fShortMonthsCount
;
663 * Narrow month strings. For example: "J", "F", etc.
665 UnicodeString
* fNarrowMonths
;
666 int32_t fNarrowMonthsCount
;
669 * Standalone Month strings. For example: "January", "February", etc.
671 UnicodeString
* fStandaloneMonths
;
672 int32_t fStandaloneMonthsCount
;
675 * Standalone Short month strings. For example: "Jan", "Feb", etc.
677 UnicodeString
* fStandaloneShortMonths
;
678 int32_t fStandaloneShortMonthsCount
;
681 * Standalone Narrow month strings. For example: "J", "F", etc.
683 UnicodeString
* fStandaloneNarrowMonths
;
684 int32_t fStandaloneNarrowMonthsCount
;
687 * CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc.
689 UnicodeString
* fWeekdays
;
690 int32_t fWeekdaysCount
;
693 * CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
695 UnicodeString
* fShortWeekdays
;
696 int32_t fShortWeekdaysCount
;
699 * CLDR-style format short weekday strings. For example: "Su", "Mo", etc.
701 UnicodeString
* fShorterWeekdays
;
702 int32_t fShorterWeekdaysCount
;
705 * CLDR-style format narrow weekday strings. For example: "S", "M", etc.
707 UnicodeString
* fNarrowWeekdays
;
708 int32_t fNarrowWeekdaysCount
;
711 * CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc.
713 UnicodeString
* fStandaloneWeekdays
;
714 int32_t fStandaloneWeekdaysCount
;
717 * CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
719 UnicodeString
* fStandaloneShortWeekdays
;
720 int32_t fStandaloneShortWeekdaysCount
;
723 * CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc.
725 UnicodeString
* fStandaloneShorterWeekdays
;
726 int32_t fStandaloneShorterWeekdaysCount
;
729 * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
731 UnicodeString
* fStandaloneNarrowWeekdays
;
732 int32_t fStandaloneNarrowWeekdaysCount
;
735 * Ampm strings. For example: "AM" and "PM".
737 UnicodeString
* fAmPms
;
741 * Narrow Ampm strings. For example: "a" and "p".
743 UnicodeString
* fNarrowAmPms
;
744 int32_t fNarrowAmPmsCount
;
747 * Time separator string. For example: ":".
749 UnicodeString fTimeSeparator
;
752 * Quarter strings. For example: "1st quarter", "2nd quarter", etc.
754 UnicodeString
*fQuarters
;
755 int32_t fQuartersCount
;
758 * Short quarters. For example: "Q1", "Q2", etc.
760 UnicodeString
*fShortQuarters
;
761 int32_t fShortQuartersCount
;
764 * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc.
766 UnicodeString
*fStandaloneQuarters
;
767 int32_t fStandaloneQuartersCount
;
770 * Standalone short quarter strings. For example: "Q1", "Q2", etc.
772 UnicodeString
*fStandaloneShortQuarters
;
773 int32_t fStandaloneShortQuartersCount
;
776 * All leap month patterns, for example "{0}bis".
778 UnicodeString
*fLeapMonthPatterns
;
779 int32_t fLeapMonthPatternsCount
;
782 * Cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai";
783 * currently we only have data for format/abbreviated.
784 * For the others, just get from format/abbreviated, ignore set.
786 UnicodeString
*fShortYearNames
;
787 int32_t fShortYearNamesCount
;
790 * Cyclic zodiac names, for example "Rat", "Ox", "Tiger", etc.;
791 * currently we only have data for format/abbreviated.
792 * For the others, just get from format/abbreviated, ignore set.
794 UnicodeString
*fShortZodiacNames
;
795 int32_t fShortZodiacNamesCount
;
798 * Localized names of time zones in this locale. This is a
799 * two-dimensional array of strings of size n by m,
800 * where m is at least 5 and up to 7. Each of the n rows is an
801 * entry containing the localized names for a single TimeZone.
803 * Each such row contains (with i ranging from 0..n-1):
805 * zoneStrings[i][0] - time zone ID
806 * example: America/Los_Angeles
807 * zoneStrings[i][1] - long name of zone in standard time
808 * example: Pacific Standard Time
809 * zoneStrings[i][2] - short name of zone in standard time
811 * zoneStrings[i][3] - long name of zone in daylight savings time
812 * example: Pacific Daylight Time
813 * zoneStrings[i][4] - short name of zone in daylight savings time
815 * zoneStrings[i][5] - location name of zone
816 * example: United States (Los Angeles)
817 * zoneStrings[i][6] - long generic name of zone
818 * example: Pacific Time
819 * zoneStrings[i][7] - short generic of zone
822 * The zone ID is not localized; it corresponds to the ID
823 * value associated with a system time zone object. All other entries
824 * are localized names. If a zone does not implement daylight savings
825 * time, the daylight savings time names are ignored.
827 * Note:CLDR 1.5 introduced metazone and its historical mappings.
828 * This simple two-dimensional array is no longer sufficient to represent
829 * localized names and its historic changes. Since ICU 3.8.1, localized
830 * zone names extracted from ICU locale data is stored in a ZoneStringFormat
831 * instance. But we still need to support the old way of customizing
832 * localized zone names, so we keep this field for the purpose.
834 UnicodeString
**fZoneStrings
; // Zone string array set by setZoneStrings
835 UnicodeString
**fLocaleZoneStrings
; // Zone string array created by the locale
836 int32_t fZoneStringsRowCount
;
837 int32_t fZoneStringsColCount
;
839 Locale fZSFLocale
; // Locale used for getting ZoneStringFormat
842 * Localized date-time pattern characters. For example: use 'u' as 'y'.
844 UnicodeString fLocalPatternChars
;
847 * Capitalization transforms. For each usage type, the first array element indicates
848 * whether to titlecase for uiListOrMenu context, the second indicates whether to
849 * titlecase for stand-alone context.
851 UBool fCapitalization
[kCapContextUsageTypeCount
][2];
854 * Abbreviated (== short) day period strings.
856 UnicodeString
*fAbbreviatedDayPeriods
;
857 int32_t fAbbreviatedDayPeriodsCount
;
860 * Wide day period strings.
862 UnicodeString
*fWideDayPeriods
;
863 int32_t fWideDayPeriodsCount
;
866 * Narrow day period strings.
868 UnicodeString
*fNarrowDayPeriods
;
869 int32_t fNarrowDayPeriodsCount
;
872 * Stand-alone abbreviated (== short) day period strings.
874 UnicodeString
*fStandaloneAbbreviatedDayPeriods
;
875 int32_t fStandaloneAbbreviatedDayPeriodsCount
;
878 * Stand-alone wide day period strings.
880 UnicodeString
*fStandaloneWideDayPeriods
;
881 int32_t fStandaloneWideDayPeriodsCount
;
884 * Stand-alone narrow day period strings.
886 UnicodeString
*fStandaloneNarrowDayPeriods
;
887 int32_t fStandaloneNarrowDayPeriodsCount
;
890 /** valid/actual locale information
891 * these are always ICU locales, so the length should not be a problem
893 char validLocale
[ULOC_FULLNAME_CAPACITY
];
894 char actualLocale
[ULOC_FULLNAME_CAPACITY
];
896 DateFormatSymbols(); // default constructor not implemented
899 * Called by the constructors to actually load data from the resources
901 * @param locale The locale to get symbols for.
902 * @param type Calendar Type (as from Calendar::getType())
903 * @param status Input/output parameter, set to success or
904 * failure code upon return.
905 * @param useLastResortData determine if use last resort data
907 void initializeData(const Locale
& locale
, const char *type
, UErrorCode
& status
, UBool useLastResortData
= FALSE
);
910 * Copy or alias an array in another object, as appropriate.
912 * @param dstArray the copy destination array.
913 * @param dstCount fill in with the lenth of 'dstArray'.
914 * @param srcArray the source array to be copied.
915 * @param srcCount the length of items to be copied from the 'srcArray'.
917 static void assignArray(UnicodeString
*& dstArray
,
919 const UnicodeString
* srcArray
,
923 * Return true if the given arrays' contents are equal, or if the arrays are
924 * identical (pointers are equal).
926 * @param array1 one array to be compared with.
927 * @param array2 another array to be compared with.
928 * @param count the length of items to be copied.
929 * @return true if the given arrays' contents are equal, or if the arrays are
930 * identical (pointers are equal).
932 static UBool
arrayCompare(const UnicodeString
* array1
,
933 const UnicodeString
* array2
,
937 * Create a copy, in fZoneStrings, of the given zone strings array. The
938 * member variables fZoneStringsRowCount and fZoneStringsColCount should be
939 * set already by the caller.
941 void createZoneStrings(const UnicodeString
*const * otherStrings
);
944 * Delete all the storage owned by this object.
949 * Copy all of the other's data to this.
950 * @param other the object to be copied.
952 void copyData(const DateFormatSymbols
& other
);
955 * Create zone strings array by locale if not yet available
957 void initZoneStringsArray(void);
960 * Delete just the zone strings.
962 void disposeZoneStrings(void);
965 * Returns the date format field index of the pattern character c,
966 * or UDAT_FIELD_COUNT if c is not a pattern character.
968 static UDateFormatField U_EXPORT2
getPatternCharIndex(UChar c
);
971 * Returns TRUE if f (with its pattern character repeated count times) is a numeric field.
973 static UBool U_EXPORT2
isNumericField(UDateFormatField f
, int32_t count
);
976 * Returns TRUE if c (repeated count times) is the pattern character for a numeric field.
978 static UBool U_EXPORT2
isNumericPatternChar(UChar c
, int32_t count
);
980 #ifndef U_HIDE_INTERNAL_API
982 * Gets a DateFormatSymbols by locale.
983 * Unlike the constructors which always use gregorian calendar, this
984 * method uses the calendar in the locale. If the locale contains no
985 * explicit calendar, this method uses the default calendar for that
987 * @param locale the locale.
988 * @param status error returned here.
989 * @return the new DateFormatSymbols which the caller owns.
990 * @internal For ICU use only.
992 static DateFormatSymbols
* U_EXPORT2
createForLocale(
993 const Locale
&locale
, UErrorCode
&status
);
997 * Get whether to capitalize based on usage.
998 * @param usage the usage.
999 * @param context 0 for menu, 1 for standalone
1000 * @return TRUE to capitalize, FALSE otherwise
1001 * @internal For ICU use only.
1003 UBool
capitalizeForUsage(ECapitalizationContextUsageType usage
, int32_t context
) const;
1004 #endif /* U_HIDE_INTERNAL_API */
1008 DateFormatSymbols::capitalizeForUsage(DateFormatSymbols::ECapitalizationContextUsageType usage
, int32_t context
) const
1010 return fCapitalization
[usage
][context
];
1015 #endif /* #if !UCONFIG_NO_FORMATTING */