]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/unicode/dtfmtsym.h
ICU-64260.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / dtfmtsym.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
2ca993e8 3/*
b75a7d8f 4********************************************************************************
2ca993e8 5* Copyright (C) 1997-2016, International Business Machines
b75a7d8f
A
6* Corporation and others. All Rights Reserved.
7********************************************************************************
8*
9* File DTFMTSYM.H
10*
11* Modification History:
12*
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********************************************************************************
18*/
2ca993e8 19
b75a7d8f
A
20#ifndef DTFMTSYM_H
21#define DTFMTSYM_H
2ca993e8 22
b75a7d8f
A
23#include "unicode/utypes.h"
24
25#if !UCONFIG_NO_FORMATTING
26
46f4442e 27#include "unicode/calendar.h"
f3c0d7a5 28#include "unicode/strenum.h"
b75a7d8f
A
29#include "unicode/uobject.h"
30#include "unicode/locid.h"
51004dcb 31#include "unicode/udat.h"
374ca955 32#include "unicode/ures.h"
b75a7d8f 33
73c04bcf 34/**
2ca993e8 35 * \file
73c04bcf
A
36 * \brief C++ API: Symbols for formatting dates.
37 */
38
f3c0d7a5 39#if U_SHOW_CPLUSPLUS_API
b75a7d8f
A
40U_NAMESPACE_BEGIN
41
42/* forward declaration */
43class SimpleDateFormat;
73c04bcf 44class Hashtable;
b75a7d8f
A
45
46/**
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.
50 * <P>
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.
60 * <P>
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.
65 * <P>
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.
72 * <P>
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
81 * calendar type.
82 */
b331163b 83class U_I18N_API DateFormatSymbols U_FINAL : public UObject {
b75a7d8f
A
84public:
85 /**
86 * Construct a DateFormatSymbols object by loading format data from
87 * resources for the default locale, in the default calendar (Gregorian).
88 * <P>
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.
92 *
93 * @param status Status code. Failure
94 * results if the resources for the default cannot be
95 * found or cannot be loaded
96 * @stable ICU 2.0
97 */
98 DateFormatSymbols(UErrorCode& status);
99
100 /**
101 * Construct a DateFormatSymbols object by loading format data from
102 * resources for the given locale, in the default calendar (Gregorian).
103 *
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
108 * @stable ICU 2.0
109 */
110 DateFormatSymbols(const Locale& locale,
111 UErrorCode& status);
112
4388f060 113#ifndef U_HIDE_INTERNAL_API
b75a7d8f
A
114 /**
115 * Construct a DateFormatSymbols object by loading format data from
116 * resources for the default locale, in the default calendar (Gregorian).
117 * <P>
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.
121 *
2ca993e8 122 * @param type Type of calendar (as returned by Calendar::getType).
b75a7d8f
A
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
128 * @internal
129 */
130 DateFormatSymbols(const char *type, UErrorCode& status);
131
132 /**
133 * Construct a DateFormatSymbols object by loading format data from
134 * resources for the given locale, in the default calendar (Gregorian).
135 *
136 * @param locale Locale to load format data from.
2ca993e8 137 * @param type Type of calendar (as returned by Calendar::getType).
b75a7d8f
A
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
143 * @internal
144 */
145 DateFormatSymbols(const Locale& locale,
146 const char *type,
147 UErrorCode& status);
4388f060 148#endif /* U_HIDE_INTERNAL_API */
b75a7d8f
A
149
150 /**
151 * Copy constructor.
152 * @stable ICU 2.0
153 */
154 DateFormatSymbols(const DateFormatSymbols&);
155
156 /**
157 * Assignment operator.
158 * @stable ICU 2.0
159 */
160 DateFormatSymbols& operator=(const DateFormatSymbols&);
161
162 /**
163 * Destructor. This is nonvirtual because this class is not designed to be
164 * subclassed.
165 * @stable ICU 2.0
166 */
374ca955 167 virtual ~DateFormatSymbols();
b75a7d8f
A
168
169 /**
170 * Return true if another object is semantically equal to this one.
171 *
172 * @param other the DateFormatSymbols object to be compared with.
173 * @return true if other is semantically equal to this.
174 * @stable ICU 2.0
175 */
176 UBool operator==(const DateFormatSymbols& other) const;
177
178 /**
179 * Return true if another object is semantically unequal to this one.
180 *
181 * @param other the DateFormatSymbols object to be compared with.
182 * @return true if other is semantically unequal to this.
183 * @stable ICU 2.0
184 */
185 UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
186
187 /**
46f4442e 188 * Gets abbreviated era strings. For example: "AD" and "BC".
b75a7d8f
A
189 *
190 * @param count Filled in with length of the array.
191 * @return the era strings.
192 * @stable ICU 2.0
193 */
194 const UnicodeString* getEras(int32_t& count) const;
195
196 /**
46f4442e 197 * Sets abbreviated era strings. For example: "AD" and "BC".
b75a7d8f
A
198 * @param eras Array of era strings (DateFormatSymbols retains ownership.)
199 * @param count Filled in with length of the array.
200 * @stable ICU 2.0
201 */
202 void setEras(const UnicodeString* eras, int32_t count);
203
73c04bcf
A
204 /**
205 * Gets era name strings. For example: "Anno Domini" and "Before Christ".
206 *
207 * @param count Filled in with length of the array.
208 * @return the era name strings.
46f4442e 209 * @stable ICU 3.4
73c04bcf
A
210 */
211 const UnicodeString* getEraNames(int32_t& count) const;
212
213 /**
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.
46f4442e 217 * @stable ICU 3.6
73c04bcf
A
218 */
219 void setEraNames(const UnicodeString* eraNames, int32_t count);
220
46f4442e 221 /**
729e4ab9 222 * Gets narrow era strings. For example: "A" and "B".
46f4442e
A
223 *
224 * @param count Filled in with length of the array.
225 * @return the narrow era strings.
729e4ab9 226 * @stable ICU 4.2
46f4442e
A
227 */
228 const UnicodeString* getNarrowEras(int32_t& count) const;
229
230 /**
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.
729e4ab9 234 * @stable ICU 4.2
46f4442e
A
235 */
236 void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
237
b75a7d8f
A
238 /**
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.)
242 * @stable ICU 2.0
243 */
244 const UnicodeString* getMonths(int32_t& count) const;
245
246 /**
247 * Sets month strings. For example: "January", "February", etc.
248 *
249 * @param months the new month strings. (not adopted; caller retains ownership)
250 * @param count Filled in with length of the array.
251 * @stable ICU 2.0
252 */
253 void setMonths(const UnicodeString* months, int32_t count);
254
255 /**
256 * Gets short month strings. For example: "Jan", "Feb", etc.
257 *
258 * @param count Filled in with length of the array.
259 * @return the short month strings. (DateFormatSymbols retains ownership.)
260 * @stable ICU 2.0
261 */
262 const UnicodeString* getShortMonths(int32_t& count) const;
263
264 /**
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)
268 * @stable ICU 2.0
269 */
270 void setShortMonths(const UnicodeString* shortMonths, int32_t count);
271
73c04bcf
A
272 /**
273 * Selector for date formatting context
46f4442e 274 * @stable ICU 3.6
73c04bcf
A
275 */
276 enum DtContextType {
f3c0d7a5
A
277 FORMAT,
278 STANDALONE,
279#ifndef U_HIDE_DEPRECATED_API
280 /**
281 * One more than the highest normal DtContextType value.
282 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
283 */
284 DT_CONTEXT_COUNT
285#endif // U_HIDE_DEPRECATED_API
73c04bcf
A
286 };
287
288 /**
289 * Selector for date formatting width
46f4442e 290 * @stable ICU 3.6
73c04bcf
A
291 */
292 enum DtWidthType {
f3c0d7a5
A
293 ABBREVIATED,
294 WIDE,
295 NARROW,
296 /**
297 * Short width is currently only supported for weekday names.
298 * @stable ICU 51
299 */
300 SHORT,
301#ifndef U_HIDE_DEPRECATED_API
302 /**
303 * One more than the highest normal DtWidthType value.
304 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
305 */
306 DT_WIDTH_COUNT = 4
307#endif // U_HIDE_DEPRECATED_API
73c04bcf
A
308 };
309
310 /**
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.)
46f4442e 316 * @stable ICU 3.4
73c04bcf
A
317 */
318 const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
319
320 /**
321 * Sets month strings by width and context. For example: "January", "February", etc.
322 *
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.
46f4442e 327 * @stable ICU 3.6
73c04bcf
A
328 */
329 void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
330
b75a7d8f 331 /**
51004dcb 332 * Gets wide weekday strings. For example: "Sunday", "Monday", etc.
b75a7d8f
A
333 * @param count Filled in with length of the array.
334 * @return the weekday strings. (DateFormatSymbols retains ownership.)
335 * @stable ICU 2.0
336 */
337 const UnicodeString* getWeekdays(int32_t& count) const;
338
73c04bcf 339
b75a7d8f 340 /**
51004dcb 341 * Sets wide weekday strings. For example: "Sunday", "Monday", etc.
b75a7d8f
A
342 * @param weekdays the new weekday strings. (not adopted; caller retains ownership)
343 * @param count Filled in with length of the array.
344 * @stable ICU 2.0
345 */
346 void setWeekdays(const UnicodeString* weekdays, int32_t count);
347
348 /**
51004dcb
A
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.)
b75a7d8f 351 * @param count Filled in with length of the array.
51004dcb 352 * @return the abbreviated weekday strings. (DateFormatSymbols retains ownership.)
b75a7d8f
A
353 * @stable ICU 2.0
354 */
355 const UnicodeString* getShortWeekdays(int32_t& count) const;
356
357 /**
51004dcb
A
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.
b75a7d8f
A
362 * @stable ICU 2.0
363 */
51004dcb 364 void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
b75a7d8f 365
73c04bcf
A
366 /**
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
51004dcb 370 * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
73c04bcf 371 * @return the month strings. (DateFormatSymbols retains ownership.)
46f4442e 372 * @stable ICU 3.4
73c04bcf
A
373 */
374 const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
375
376 /**
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
51004dcb 381 * @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
46f4442e 382 * @stable ICU 3.6
73c04bcf
A
383 */
384 void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
385
386 /**
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.)
46f4442e 393 * @stable ICU 3.6
73c04bcf
A
394 */
395 const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
396
397 /**
398 * Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
399 *
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.
46f4442e 405 * @stable ICU 3.6
73c04bcf
A
406 */
407 void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
408
b75a7d8f
A
409 /**
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.)
413 * @stable ICU 2.0
414 */
415 const UnicodeString* getAmPmStrings(int32_t& count) const;
416
417 /**
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.
421 * @stable ICU 2.0
422 */
423 void setAmPmStrings(const UnicodeString* ampms, int32_t count);
424
b331163b
A
425#ifndef U_HIDE_INTERNAL_API
426 /**
427 * This default time separator is used for formatting when the locale
428 * doesn't specify any time separator, and always recognized when parsing.
429 * @internal
430 */
f3c0d7a5 431 static const char16_t DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
b331163b
A
432
433 /**
434 * This alternate time separator is always recognized when parsing.
435 * @internal
436 */
f3c0d7a5 437 static const char16_t ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
b331163b 438
b331163b
A
439 /**
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'.
2ca993e8 443 * @internal
b331163b
A
444 */
445 UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
446
447 /**
448 * Sets the time separator string. For example: ":".
449 * @param newTimeSeparator the new time separator string.
2ca993e8 450 * @internal
b331163b
A
451 */
452 void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
2ca993e8 453#endif /* U_HIDE_INTERNAL_API */
b331163b 454
b331163b
A
455 /**
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.
2ca993e8 463 * @stable ICU 54
b331163b
A
464 */
465 const UnicodeString* getYearNames(int32_t& count,
466 DtContextType context, DtWidthType width) const;
467
468 /**
469 * Sets cyclic year name strings by width and context. For example: "jia-zi", "yi-chou", etc.
470 *
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).
2ca993e8 475 * @stable ICU 54
b331163b
A
476 */
477 void setYearNames(const UnicodeString* yearNames, int32_t count,
478 DtContextType context, DtWidthType width);
479
480 /**
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.
2ca993e8 488 * @stable ICU 54
b331163b
A
489 */
490 const UnicodeString* getZodiacNames(int32_t& count,
491 DtContextType context, DtWidthType width) const;
492
493 /**
494 * Sets calendar zodiac name strings by width and context. For example: "Rat", "Ox", "Tiger", etc.
495 *
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).
2ca993e8 500 * @stable ICU 54
b331163b
A
501 */
502 void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
503 DtContextType context, DtWidthType width);
504
4388f060
A
505#ifndef U_HIDE_INTERNAL_API
506 /**
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.
512 * @internal
513 */
514 enum EMonthPatternType
515 {
516 kLeapMonthPatternFormatWide,
517 kLeapMonthPatternFormatAbbrev,
518 kLeapMonthPatternFormatNarrow,
519 kLeapMonthPatternStandaloneWide,
520 kLeapMonthPatternStandaloneAbbrev,
521 kLeapMonthPatternStandaloneNarrow,
522 kLeapMonthPatternNumeric,
523 kMonthPatternsCount
524 };
525
526 /**
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.
536 * @internal
537 */
538 const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
539
540#endif /* U_HIDE_INTERNAL_API */
541
542#ifndef U_HIDE_DEPRECATED_API
b75a7d8f
A
543 /**
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.)
73c04bcf 548 * @deprecated ICU 3.6
b75a7d8f
A
549 */
550 const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
4388f060 551#endif /* U_HIDE_DEPRECATED_API */
b75a7d8f
A
552
553 /**
554 * Sets timezone strings. These strings are stored in a 2-dimensional array.
4388f060
A
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
558 * zones.
b75a7d8f
A
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).
562 * @stable ICU 2.0
563 */
564 void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
565
566 /**
567 * Get the non-localized date-time pattern characters.
568 * @return the non-localized date-time pattern characters
569 * @stable ICU 2.0
570 */
f3c0d7a5 571 static const char16_t * U_EXPORT2 getPatternUChars(void);
b75a7d8f
A
572
573 /**
574 * Gets localized date-time pattern characters. For example: 'u', 't', etc.
46f4442e
A
575 * <p>
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.
b75a7d8f
A
579 * @param result Output param which will receive the localized date-time pattern characters.
580 * @return A reference to 'result'.
581 * @stable ICU 2.0
582 */
583 UnicodeString& getLocalPatternChars(UnicodeString& result) const;
584
585 /**
586 * Sets localized date-time pattern characters. For example: 'u', 't', etc.
587 * @param newLocalPatternChars the new localized date-time
588 * pattern characters.
589 * @stable ICU 2.0
590 */
591 void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
592
374ca955
A
593 /**
594 * Returns the locale for this object. Two flavors are available:
595 * valid and actual locale.
73c04bcf 596 * @stable ICU 2.8
374ca955
A
597 */
598 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
599
57a6839d
A
600 /* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
601 they are needed for .h file declarations. */
4388f060
A
602 /**
603 * Constants for capitalization context usage types.
604 * @internal
605 */
606 enum ECapitalizationContextUsageType
607 {
57a6839d
A
608#ifndef U_HIDE_INTERNAL_API
609 kCapContextUsageOther = 0,
4388f060
A
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,
57a6839d
A
623#endif /* U_HIDE_INTERNAL_API */
624 kCapContextUsageTypeCount = 14
4388f060 625 };
4388f060 626
b75a7d8f
A
627 /**
628 * ICU "poor man's RTTI", returns a UClassID for the actual class.
629 *
374ca955 630 * @stable ICU 2.2
b75a7d8f 631 */
374ca955 632 virtual UClassID getDynamicClassID() const;
b75a7d8f
A
633
634 /**
635 * ICU "poor man's RTTI", returns a UClassID for this class.
636 *
374ca955 637 * @stable ICU 2.2
b75a7d8f 638 */
374ca955 639 static UClassID U_EXPORT2 getStaticClassID();
b75a7d8f
A
640
641private:
b75a7d8f
A
642
643 friend class SimpleDateFormat;
644 friend class DateFormatSymbolsSingleSetter; // see udat.cpp
645
646 /**
46f4442e 647 * Abbreviated era strings. For example: "AD" and "BC".
b75a7d8f
A
648 */
649 UnicodeString* fEras;
650 int32_t fErasCount;
651
73c04bcf
A
652 /**
653 * Era name strings. For example: "Anno Domini" and "Before Christ".
654 */
655 UnicodeString* fEraNames;
656 int32_t fEraNamesCount;
657
46f4442e
A
658 /**
659 * Narrow era strings. For example: "A" and "B".
660 */
661 UnicodeString* fNarrowEras;
662 int32_t fNarrowErasCount;
663
b75a7d8f
A
664 /**
665 * Month strings. For example: "January", "February", etc.
666 */
667 UnicodeString* fMonths;
668 int32_t fMonthsCount;
669
670 /**
671 * Short month strings. For example: "Jan", "Feb", etc.
672 */
673 UnicodeString* fShortMonths;
674 int32_t fShortMonthsCount;
675
73c04bcf
A
676 /**
677 * Narrow month strings. For example: "J", "F", etc.
678 */
679 UnicodeString* fNarrowMonths;
680 int32_t fNarrowMonthsCount;
681
682 /**
683 * Standalone Month strings. For example: "January", "February", etc.
684 */
685 UnicodeString* fStandaloneMonths;
686 int32_t fStandaloneMonthsCount;
687
688 /**
689 * Standalone Short month strings. For example: "Jan", "Feb", etc.
690 */
691 UnicodeString* fStandaloneShortMonths;
692 int32_t fStandaloneShortMonthsCount;
693
694 /**
695 * Standalone Narrow month strings. For example: "J", "F", etc.
696 */
697 UnicodeString* fStandaloneNarrowMonths;
698 int32_t fStandaloneNarrowMonthsCount;
699
b75a7d8f 700 /**
51004dcb 701 * CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc.
b75a7d8f
A
702 */
703 UnicodeString* fWeekdays;
704 int32_t fWeekdaysCount;
705
706 /**
51004dcb 707 * CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
b75a7d8f
A
708 */
709 UnicodeString* fShortWeekdays;
710 int32_t fShortWeekdaysCount;
711
73c04bcf 712 /**
51004dcb
A
713 * CLDR-style format short weekday strings. For example: "Su", "Mo", etc.
714 */
715 UnicodeString* fShorterWeekdays;
716 int32_t fShorterWeekdaysCount;
717
718 /**
719 * CLDR-style format narrow weekday strings. For example: "S", "M", etc.
73c04bcf
A
720 */
721 UnicodeString* fNarrowWeekdays;
722 int32_t fNarrowWeekdaysCount;
723
724 /**
51004dcb 725 * CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc.
73c04bcf
A
726 */
727 UnicodeString* fStandaloneWeekdays;
728 int32_t fStandaloneWeekdaysCount;
729
730 /**
51004dcb 731 * CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
73c04bcf
A
732 */
733 UnicodeString* fStandaloneShortWeekdays;
734 int32_t fStandaloneShortWeekdaysCount;
735
51004dcb
A
736 /**
737 * CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc.
738 */
739 UnicodeString* fStandaloneShorterWeekdays;
740 int32_t fStandaloneShorterWeekdaysCount;
741
73c04bcf
A
742 /**
743 * Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
744 */
745 UnicodeString* fStandaloneNarrowWeekdays;
746 int32_t fStandaloneNarrowWeekdaysCount;
747
b75a7d8f
A
748 /**
749 * Ampm strings. For example: "AM" and "PM".
750 */
751 UnicodeString* fAmPms;
752 int32_t fAmPmsCount;
753
b331163b
A
754 /**
755 * Narrow Ampm strings. For example: "a" and "p".
756 */
757 UnicodeString* fNarrowAmPms;
758 int32_t fNarrowAmPmsCount;
759
760 /**
761 * Time separator string. For example: ":".
762 */
763 UnicodeString fTimeSeparator;
764
73c04bcf
A
765 /**
766 * Quarter strings. For example: "1st quarter", "2nd quarter", etc.
767 */
768 UnicodeString *fQuarters;
769 int32_t fQuartersCount;
770
771 /**
772 * Short quarters. For example: "Q1", "Q2", etc.
773 */
774 UnicodeString *fShortQuarters;
775 int32_t fShortQuartersCount;
776
777 /**
778 * Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc.
779 */
780 UnicodeString *fStandaloneQuarters;
781 int32_t fStandaloneQuartersCount;
782
783 /**
784 * Standalone short quarter strings. For example: "Q1", "Q2", etc.
785 */
786 UnicodeString *fStandaloneShortQuarters;
787 int32_t fStandaloneShortQuartersCount;
788
4388f060
A
789 /**
790 * All leap month patterns, for example "{0}bis".
791 */
792 UnicodeString *fLeapMonthPatterns;
793 int32_t fLeapMonthPatternsCount;
794
795 /**
b331163b
A
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.
4388f060 799 */
b331163b 800 UnicodeString *fShortYearNames;
4388f060
A
801 int32_t fShortYearNamesCount;
802
57a6839d 803 /**
b331163b
A
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.
57a6839d 807 */
b331163b 808 UnicodeString *fShortZodiacNames;
57a6839d
A
809 int32_t fShortZodiacNamesCount;
810
b75a7d8f 811 /**
729e4ab9
A
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.
816 *
817 * Each such row contains (with i ranging from 0..n-1):
818 *
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
824 * example: PST
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
828 * example: PDT
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
834 * example: PT
835 *
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.
840 *
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.
b75a7d8f 847 */
46f4442e
A
848 UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
849 UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
b75a7d8f
A
850 int32_t fZoneStringsRowCount;
851 int32_t fZoneStringsColCount;
46f4442e 852
46f4442e
A
853 Locale fZSFLocale; // Locale used for getting ZoneStringFormat
854
855 /**
4388f060 856 * Localized date-time pattern characters. For example: use 'u' as 'y'.
46f4442e 857 */
4388f060 858 UnicodeString fLocalPatternChars;
46f4442e
A
859
860 /**
4388f060
A
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.
46f4442e 864 */
4388f060 865 UBool fCapitalization[kCapContextUsageTypeCount][2];
b75a7d8f 866
2ca993e8
A
867 /**
868 * Abbreviated (== short) day period strings.
869 */
870 UnicodeString *fAbbreviatedDayPeriods;
871 int32_t fAbbreviatedDayPeriodsCount;
872
873 /**
874 * Wide day period strings.
875 */
876 UnicodeString *fWideDayPeriods;
877 int32_t fWideDayPeriodsCount;
878
879 /**
880 * Narrow day period strings.
881 */
882 UnicodeString *fNarrowDayPeriods;
883 int32_t fNarrowDayPeriodsCount;
884
885 /**
886 * Stand-alone abbreviated (== short) day period strings.
887 */
888 UnicodeString *fStandaloneAbbreviatedDayPeriods;
889 int32_t fStandaloneAbbreviatedDayPeriodsCount;
890
891 /**
892 * Stand-alone wide day period strings.
893 */
894 UnicodeString *fStandaloneWideDayPeriods;
895 int32_t fStandaloneWideDayPeriodsCount;
896
897 /**
898 * Stand-alone narrow day period strings.
899 */
900 UnicodeString *fStandaloneNarrowDayPeriods;
901 int32_t fStandaloneNarrowDayPeriodsCount;
902
374ca955
A
903private:
904 /** valid/actual locale information
905 * these are always ICU locales, so the length should not be a problem
b75a7d8f 906 */
374ca955
A
907 char validLocale[ULOC_FULLNAME_CAPACITY];
908 char actualLocale[ULOC_FULLNAME_CAPACITY];
b75a7d8f 909
b75a7d8f
A
910 DateFormatSymbols(); // default constructor not implemented
911
b75a7d8f
A
912 /**
913 * Called by the constructors to actually load data from the resources
914 *
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
920 */
4388f060 921 void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
b75a7d8f
A
922
923 /**
924 * Copy or alias an array in another object, as appropriate.
925 *
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'.
930 */
931 static void assignArray(UnicodeString*& dstArray,
932 int32_t& dstCount,
933 const UnicodeString* srcArray,
934 int32_t srcCount);
935
936 /**
937 * Return true if the given arrays' contents are equal, or if the arrays are
938 * identical (pointers are equal).
939 *
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).
945 */
946 static UBool arrayCompare(const UnicodeString* array1,
947 const UnicodeString* array2,
948 int32_t count);
949
950 /**
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.
954 */
955 void createZoneStrings(const UnicodeString *const * otherStrings);
956
b75a7d8f
A
957 /**
958 * Delete all the storage owned by this object.
959 */
960 void dispose(void);
961
962 /**
963 * Copy all of the other's data to this.
964 * @param other the object to be copied.
965 */
966 void copyData(const DateFormatSymbols& other);
967
73c04bcf 968 /**
46f4442e 969 * Create zone strings array by locale if not yet available
73c04bcf 970 */
46f4442e
A
971 void initZoneStringsArray(void);
972
73c04bcf 973 /**
46f4442e 974 * Delete just the zone strings.
73c04bcf 975 */
46f4442e 976 void disposeZoneStrings(void);
51004dcb
A
977
978 /**
979 * Returns the date format field index of the pattern character c,
980 * or UDAT_FIELD_COUNT if c is not a pattern character.
981 */
f3c0d7a5 982 static UDateFormatField U_EXPORT2 getPatternCharIndex(char16_t c);
51004dcb
A
983
984 /**
985 * Returns TRUE if f (with its pattern character repeated count times) is a numeric field.
986 */
987 static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
988
989 /**
990 * Returns TRUE if c (repeated count times) is the pattern character for a numeric field.
991 */
f3c0d7a5 992 static UBool U_EXPORT2 isNumericPatternChar(char16_t c, int32_t count);
b331163b
A
993public:
994#ifndef U_HIDE_INTERNAL_API
995 /**
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
1000 * locale.
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.
1005 */
1006 static DateFormatSymbols * U_EXPORT2 createForLocale(
1007 const Locale &locale, UErrorCode &status);
a62d09fc
A
1008
1009 /**
1010 * Apple addition
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.
1016 */
1017 UBool capitalizeForUsage(ECapitalizationContextUsageType usage, int32_t context) const;
b331163b 1018#endif /* U_HIDE_INTERNAL_API */
b75a7d8f
A
1019};
1020
a62d09fc
A
1021inline UBool
1022DateFormatSymbols::capitalizeForUsage(DateFormatSymbols::ECapitalizationContextUsageType usage, int32_t context) const
1023{
1024 return fCapitalization[usage][context];
1025}
1026
b75a7d8f 1027U_NAMESPACE_END
f3c0d7a5 1028#endif // U_SHOW_CPLUSPLUS_API
b75a7d8f
A
1029
1030#endif /* #if !UCONFIG_NO_FORMATTING */
1031
1032#endif // _DTFMTSYM
1033//eof