]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/unicode/udat.h
ICU-66108.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / udat.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
b75a7d8f 3/*
46f4442e 4 *******************************************************************************
2ca993e8 5 * Copyright (C) 1996-2016, International Business Machines
46f4442e
A
6 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
b75a7d8f
A
8*/
9
10#ifndef UDAT_H
11#define UDAT_H
12
13#include "unicode/utypes.h"
14
15#if !UCONFIG_NO_FORMATTING
16
729e4ab9 17#include "unicode/localpointer.h"
b75a7d8f
A
18#include "unicode/ucal.h"
19#include "unicode/unum.h"
51004dcb 20#include "unicode/udisplaycontext.h"
b331163b 21#include "unicode/ufieldpositer.h"
b75a7d8f
A
22/**
23 * \file
24 * \brief C API: DateFormat
25 *
26 * <h2> Date Format C API</h2>
27 *
28 * Date Format C API consists of functions that convert dates and
29 * times from their internal representations to textual form and back again in a
30 * language-independent manner. Converting from the internal representation (milliseconds
31 * since midnight, January 1, 1970) to text is known as "formatting," and converting
32 * from text to millis is known as "parsing." We currently define only one concrete
33 * structure UDateFormat, which can handle pretty much all normal
34 * date formatting and parsing actions.
35 * <P>
36 * Date Format helps you to format and parse dates for any locale. Your code can
37 * be completely independent of the locale conventions for months, days of the
38 * week, or even the calendar format: lunar vs. solar.
39 * <P>
40 * To format a date for the current Locale with default time and date style,
41 * use one of the static factory methods:
42 * <pre>
43 * \code
44 * UErrorCode status = U_ZERO_ERROR;
45 * UChar *myString;
46 * int32_t myStrlen = 0;
47 * UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, -1, &status);
48 * myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, NULL, &status);
49 * if (status==U_BUFFER_OVERFLOW_ERROR){
50 * status=U_ZERO_ERROR;
51 * myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
52 * udat_format(dfmt, myDate, myString, myStrlen+1, NULL, &status);
53 * }
54 * \endcode
55 * </pre>
56 * If you are formatting multiple numbers, it is more efficient to get the
57 * format and use it multiple times so that the system doesn't have to fetch the
58 * information about the local language and country conventions multiple times.
59 * <pre>
60 * \code
61 * UErrorCode status = U_ZERO_ERROR;
62 * int32_t i, myStrlen = 0;
63 * UChar* myString;
64 * char buffer[1024];
65 * UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
66 * UDateFormat* df = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, 0, &status);
67 * for (i = 0; i < 3; i++) {
68 * myStrlen = udat_format(df, myDateArr[i], NULL, myStrlen, NULL, &status);
69 * if(status == U_BUFFER_OVERFLOW_ERROR){
70 * status = U_ZERO_ERROR;
71 * myString = (UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
72 * udat_format(df, myDateArr[i], myString, myStrlen+1, NULL, &status);
73 * printf("%s\n", u_austrcpy(buffer, myString) );
74 * free(myString);
75 * }
76 * }
77 * \endcode
78 * </pre>
79 * To get specific fields of a date, you can use UFieldPosition to
80 * get specific fields.
81 * <pre>
82 * \code
83 * UErrorCode status = U_ZERO_ERROR;
84 * UFieldPosition pos;
85 * UChar *myString;
86 * int32_t myStrlen = 0;
87 * char buffer[1024];
88 *
89 * pos.field = 1; // Same as the DateFormat::EField enum
90 * UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, -1, NULL, 0, &status);
91 * myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, &pos, &status);
92 * if (status==U_BUFFER_OVERFLOW_ERROR){
93 * status=U_ZERO_ERROR;
94 * myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
95 * udat_format(dfmt, myDate, myString, myStrlen+1, &pos, &status);
96 * }
97 * printf("date format: %s\n", u_austrcpy(buffer, myString));
98 * buffer[pos.endIndex] = 0; // NULL terminate the string.
99 * printf("UFieldPosition position equals %s\n", &buffer[pos.beginIndex]);
100 * \endcode
101 * </pre>
102 * To format a date for a different Locale, specify it in the call to
103 * udat_open()
104 * <pre>
105 * \code
106 * UDateFormat* df = udat_open(UDAT_SHORT, UDAT_SHORT, "fr_FR", NULL, -1, NULL, 0, &status);
107 * \endcode
108 * </pre>
109 * You can use a DateFormat API udat_parse() to parse.
110 * <pre>
111 * \code
112 * UErrorCode status = U_ZERO_ERROR;
113 * int32_t parsepos=0;
114 * UDate myDate = udat_parse(df, myString, u_strlen(myString), &parsepos, &status);
115 * \endcode
116 * </pre>
117 * You can pass in different options for the arguments for date and time style
118 * to control the length of the result; from SHORT to MEDIUM to LONG to FULL.
119 * The exact result depends on the locale, but generally:
120 * see UDateFormatStyle for more details
121 * <ul type=round>
122 * <li> UDAT_SHORT is completely numeric, such as 12/13/52 or 3:30pm
123 * <li> UDAT_MEDIUM is longer, such as Jan 12, 1952
124 * <li> UDAT_LONG is longer, such as January 12, 1952 or 3:30:32pm
125 * <li> UDAT_FULL is pretty completely specified, such as
126 * Tuesday, April 12, 1952 AD or 3:30:42pm PST.
127 * </ul>
128 * You can also set the time zone on the format if you wish.
129 * <P>
130 * You can also use forms of the parse and format methods with Parse Position and
131 * UFieldPosition to allow you to
132 * <ul type=round>
133 * <li> Progressively parse through pieces of a string.
134 * <li> Align any particular field, or find out where it is for selection
135 * on the screen.
136 * </ul>
57a6839d
A
137 * <p><strong>Date and Time Patterns:</strong></p>
138 *
139 * <p>Date and time formats are specified by <em>date and time pattern</em> strings.
140 * Within date and time pattern strings, all unquoted ASCII letters [A-Za-z] are reserved
141 * as pattern letters representing calendar fields. <code>UDateFormat</code> supports
142 * the date and time formatting algorithm and pattern letters defined by
143 * <a href="http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table">UTS#35
144 * Unicode Locale Data Markup Language (LDML)</a> and further documented for ICU in the
145 * <a href="https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table">ICU
146 * User Guide</a>.</p>
b75a7d8f
A
147 */
148
149/** A date formatter.
150 * For usage in C programs.
151 * @stable ICU 2.6
152 */
153typedef void* UDateFormat;
154
2ca993e8 155/** The possible date/time format styles
b75a7d8f
A
156 * @stable ICU 2.6
157 */
158typedef enum UDateFormatStyle {
159 /** Full style */
160 UDAT_FULL,
161 /** Long style */
162 UDAT_LONG,
163 /** Medium style */
164 UDAT_MEDIUM,
165 /** Short style */
166 UDAT_SHORT,
167 /** Default style */
168 UDAT_DEFAULT = UDAT_MEDIUM,
46f4442e
A
169
170 /** Bitfield for relative date */
171 UDAT_RELATIVE = (1 << 7),
2ca993e8 172
46f4442e 173 UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,
2ca993e8 174
46f4442e 175 UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,
2ca993e8 176
46f4442e 177 UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,
2ca993e8 178
46f4442e 179 UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,
2ca993e8
A
180
181
b75a7d8f
A
182 /** No style */
183 UDAT_NONE = -1,
b75a7d8f 184
4388f060 185 /**
51004dcb
A
186 * Use the pattern given in the parameter to udat_open
187 * @see udat_open
57a6839d 188 * @stable ICU 50
4388f060 189 */
51004dcb 190 UDAT_PATTERN = -2,
4388f060 191
57a6839d 192#ifndef U_HIDE_INTERNAL_API
51004dcb
A
193 /** @internal alias to UDAT_PATTERN */
194 UDAT_IGNORE = UDAT_PATTERN
57a6839d 195#endif /* U_HIDE_INTERNAL_API */
51004dcb
A
196} UDateFormatStyle;
197
57a6839d 198/* Skeletons for dates. */
46f4442e
A
199
200/**
51004dcb 201 * Constant for date skeleton with year.
46f4442e
A
202 * @stable ICU 4.0
203 */
51004dcb 204#define UDAT_YEAR "y"
51004dcb
A
205/**
206 * Constant for date skeleton with quarter.
57a6839d 207 * @stable ICU 51
51004dcb
A
208 */
209#define UDAT_QUARTER "QQQQ"
210/**
211 * Constant for date skeleton with abbreviated quarter.
57a6839d 212 * @stable ICU 51
51004dcb
A
213 */
214#define UDAT_ABBR_QUARTER "QQQ"
46f4442e 215/**
51004dcb
A
216 * Constant for date skeleton with year and quarter.
217 * @stable ICU 4.0
218 */
219#define UDAT_YEAR_QUARTER "yQQQQ"
220/**
221 * Constant for date skeleton with year and abbreviated quarter.
222 * @stable ICU 4.0
223 */
224#define UDAT_YEAR_ABBR_QUARTER "yQQQ"
225/**
226 * Constant for date skeleton with month.
227 * @stable ICU 4.0
228 */
229#define UDAT_MONTH "MMMM"
230/**
231 * Constant for date skeleton with abbreviated month.
232 * @stable ICU 4.0
233 */
234#define UDAT_ABBR_MONTH "MMM"
235/**
236 * Constant for date skeleton with numeric month.
237 * @stable ICU 4.0
238 */
239#define UDAT_NUM_MONTH "M"
240/**
241 * Constant for date skeleton with year and month.
729e4ab9 242 * @stable ICU 4.0
46f4442e 243 */
46f4442e 244#define UDAT_YEAR_MONTH "yMMMM"
51004dcb
A
245/**
246 * Constant for date skeleton with year and abbreviated month.
247 * @stable ICU 4.0
248 */
46f4442e 249#define UDAT_YEAR_ABBR_MONTH "yMMM"
51004dcb
A
250/**
251 * Constant for date skeleton with year and numeric month.
252 * @stable ICU 4.0
253 */
254#define UDAT_YEAR_NUM_MONTH "yM"
255/**
256 * Constant for date skeleton with day.
257 * @stable ICU 4.0
258 */
259#define UDAT_DAY "d"
260/**
261 * Constant for date skeleton with year, month, and day.
262 * Used in combinations date + time, date + time + zone, or time + zone.
263 * @stable ICU 4.0
264 */
46f4442e 265#define UDAT_YEAR_MONTH_DAY "yMMMMd"
51004dcb
A
266/**
267 * Constant for date skeleton with year, abbreviated month, and day.
268 * Used in combinations date + time, date + time + zone, or time + zone.
269 * @stable ICU 4.0
270 */
46f4442e 271#define UDAT_YEAR_ABBR_MONTH_DAY "yMMMd"
51004dcb
A
272/**
273 * Constant for date skeleton with year, numeric month, and day.
274 * Used in combinations date + time, date + time + zone, or time + zone.
275 * @stable ICU 4.0
276 */
46f4442e 277#define UDAT_YEAR_NUM_MONTH_DAY "yMd"
51004dcb
A
278/**
279 * Constant for date skeleton with weekday.
57a6839d 280 * @stable ICU 51
51004dcb
A
281 */
282#define UDAT_WEEKDAY "EEEE"
283/**
284 * Constant for date skeleton with abbreviated weekday.
57a6839d 285 * @stable ICU 51
51004dcb
A
286 */
287#define UDAT_ABBR_WEEKDAY "E"
51004dcb
A
288/**
289 * Constant for date skeleton with year, month, weekday, and day.
290 * Used in combinations date + time, date + time + zone, or time + zone.
291 * @stable ICU 4.0
292 */
293#define UDAT_YEAR_MONTH_WEEKDAY_DAY "yMMMMEEEEd"
294/**
295 * Constant for date skeleton with year, abbreviated month, weekday, and day.
296 * Used in combinations date + time, date + time + zone, or time + zone.
297 * @stable ICU 4.0
298 */
2ca993e8 299#define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd"
51004dcb
A
300/**
301 * Constant for date skeleton with year, numeric month, weekday, and day.
302 * Used in combinations date + time, date + time + zone, or time + zone.
303 * @stable ICU 4.0
304 */
305#define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd"
306/**
307 * Constant for date skeleton with long month and day.
308 * Used in combinations date + time, date + time + zone, or time + zone.
309 * @stable ICU 4.0
310 */
311#define UDAT_MONTH_DAY "MMMMd"
312/**
313 * Constant for date skeleton with abbreviated month and day.
314 * Used in combinations date + time, date + time + zone, or time + zone.
315 * @stable ICU 4.0
316 */
317#define UDAT_ABBR_MONTH_DAY "MMMd"
318/**
319 * Constant for date skeleton with numeric month and day.
320 * Used in combinations date + time, date + time + zone, or time + zone.
321 * @stable ICU 4.0
322 */
323#define UDAT_NUM_MONTH_DAY "Md"
324/**
325 * Constant for date skeleton with month, weekday, and day.
326 * Used in combinations date + time, date + time + zone, or time + zone.
327 * @stable ICU 4.0
328 */
329#define UDAT_MONTH_WEEKDAY_DAY "MMMMEEEEd"
330/**
331 * Constant for date skeleton with abbreviated month, weekday, and day.
332 * Used in combinations date + time, date + time + zone, or time + zone.
333 * @stable ICU 4.0
334 */
335#define UDAT_ABBR_MONTH_WEEKDAY_DAY "MMMEd"
336/**
337 * Constant for date skeleton with numeric month, weekday, and day.
338 * Used in combinations date + time, date + time + zone, or time + zone.
339 * @stable ICU 4.0
340 */
341#define UDAT_NUM_MONTH_WEEKDAY_DAY "MEd"
342
57a6839d 343/* Skeletons for times. */
51004dcb
A
344
345/**
346 * Constant for date skeleton with hour, with the locale's preferred hour format (12 or 24).
347 * @stable ICU 4.0
348 */
349#define UDAT_HOUR "j"
51004dcb
A
350/**
351 * Constant for date skeleton with hour in 24-hour presentation.
57a6839d 352 * @stable ICU 51
51004dcb
A
353 */
354#define UDAT_HOUR24 "H"
355/**
356 * Constant for date skeleton with minute.
57a6839d 357 * @stable ICU 51
51004dcb
A
358 */
359#define UDAT_MINUTE "m"
51004dcb
A
360/**
361 * Constant for date skeleton with hour and minute, with the locale's preferred hour format (12 or 24).
362 * Used in combinations date + time, date + time + zone, or time + zone.
363 * @stable ICU 4.0
364 */
365#define UDAT_HOUR_MINUTE "jm"
366/**
367 * Constant for date skeleton with hour and minute in 24-hour presentation.
368 * Used in combinations date + time, date + time + zone, or time + zone.
369 * @stable ICU 4.0
370 */
371#define UDAT_HOUR24_MINUTE "Hm"
51004dcb
A
372/**
373 * Constant for date skeleton with second.
57a6839d 374 * @stable ICU 51
51004dcb
A
375 */
376#define UDAT_SECOND "s"
51004dcb
A
377/**
378 * Constant for date skeleton with hour, minute, and second,
379 * with the locale's preferred hour format (12 or 24).
380 * Used in combinations date + time, date + time + zone, or time + zone.
381 * @stable ICU 4.0
382 */
383#define UDAT_HOUR_MINUTE_SECOND "jms"
384/**
385 * Constant for date skeleton with hour, minute, and second in
386 * 24-hour presentation.
387 * Used in combinations date + time, date + time + zone, or time + zone.
388 * @stable ICU 4.0
389 */
390#define UDAT_HOUR24_MINUTE_SECOND "Hms"
391/**
392 * Constant for date skeleton with minute and second.
393 * Used in combinations date + time, date + time + zone, or time + zone.
394 * @stable ICU 4.0
395 */
396#define UDAT_MINUTE_SECOND "ms"
397
57a6839d 398/* Skeletons for time zones. */
51004dcb 399
51004dcb
A
400/**
401 * Constant for <i>generic location format</i>, such as Los Angeles Time;
402 * used in combinations date + time + zone, or time + zone.
403 * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
404 * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
57a6839d 405 * @stable ICU 51
51004dcb
A
406 */
407#define UDAT_LOCATION_TZ "VVVV"
408/**
409 * Constant for <i>generic non-location format</i>, such as Pacific Time;
410 * used in combinations date + time + zone, or time + zone.
411 * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
412 * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
57a6839d 413 * @stable ICU 51
51004dcb
A
414 */
415#define UDAT_GENERIC_TZ "vvvv"
416/**
417 * Constant for <i>generic non-location format</i>, abbreviated if possible, such as PT;
418 * used in combinations date + time + zone, or time + zone.
419 * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
420 * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
57a6839d 421 * @stable ICU 51
51004dcb
A
422 */
423#define UDAT_ABBR_GENERIC_TZ "v"
424/**
425 * Constant for <i>specific non-location format</i>, such as Pacific Daylight Time;
426 * used in combinations date + time + zone, or time + zone.
427 * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
428 * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
57a6839d 429 * @stable ICU 51
51004dcb
A
430 */
431#define UDAT_SPECIFIC_TZ "zzzz"
432/**
433 * Constant for <i>specific non-location format</i>, abbreviated if possible, such as PDT;
434 * used in combinations date + time + zone, or time + zone.
435 * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
436 * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
57a6839d 437 * @stable ICU 51
51004dcb
A
438 */
439#define UDAT_ABBR_SPECIFIC_TZ "z"
440/**
441 * Constant for <i>localized GMT/UTC format</i>, such as GMT+8:00 or HPG-8:00;
442 * used in combinations date + time + zone, or time + zone.
443 * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
444 * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
57a6839d 445 * @stable ICU 51
51004dcb
A
446 */
447#define UDAT_ABBR_UTC_TZ "ZZZZ"
46f4442e 448
57a6839d 449/* deprecated skeleton constants */
46f4442e 450
2ca993e8 451#ifndef U_HIDE_DEPRECATED_API
51004dcb
A
452/**
453 * Constant for date skeleton with standalone month.
454 * @deprecated ICU 50 Use UDAT_MONTH instead.
455 */
456#define UDAT_STANDALONE_MONTH "LLLL"
457/**
458 * Constant for date skeleton with standalone abbreviated month.
459 * @deprecated ICU 50 Use UDAT_ABBR_MONTH instead.
460 */
461#define UDAT_ABBR_STANDALONE_MONTH "LLL"
462
463/**
464 * Constant for date skeleton with hour, minute, and generic timezone.
465 * @deprecated ICU 50 Use instead UDAT_HOUR_MINUTE UDAT_ABBR_GENERIC_TZ or some other timezone presentation.
466 */
467#define UDAT_HOUR_MINUTE_GENERIC_TZ "jmv"
468/**
469 * Constant for date skeleton with hour, minute, and timezone.
470 * @deprecated ICU 50 Use instead UDAT_HOUR_MINUTE UDAT_ABBR_SPECIFIC_TZ or some other timezone presentation.
471 */
472#define UDAT_HOUR_MINUTE_TZ "jmz"
473/**
474 * Constant for date skeleton with hour and generic timezone.
475 * @deprecated ICU 50 Use instead UDAT_HOUR UDAT_ABBR_GENERIC_TZ or some other timezone presentation.
476 */
477#define UDAT_HOUR_GENERIC_TZ "jv"
478/**
479 * Constant for date skeleton with hour and timezone.
480 * @deprecated ICU 50 Use instead UDAT_HOUR UDAT_ABBR_SPECIFIC_TZ or some other timezone presentation.
481 */
482#define UDAT_HOUR_TZ "jz"
483#endif /* U_HIDE_DEPRECATED_API */
46f4442e 484
1546d4af
A
485#ifndef U_HIDE_INTERNAL_API
486/**
487 * Constant for Unicode string name of new (in 2019) Japanese calendar era,
488 * root/English abbreviated version (ASCII-range characters).
489 * @internal
490 */
491#define JP_ERA_2019_ROOT "Reiwa"
492/**
493 * Constant for Unicode string name of new (in 2019) Japanese calendar era,
494 * Japanese abbreviated version (Han, or fullwidth Latin for testing).
495 * @internal
496 */
497#define JP_ERA_2019_JA "\\u4EE4\\u548C"
498/**
499 * Constant for Unicode string name of new (in 2019) Japanese calendar era,
500 * root and Japanese narrow version (ASCII-range characters).
501 * @internal
502 */
503#define JP_ERA_2019_NARROW "R"
504#endif // U_HIDE_INTERNAL_API
505
374ca955
A
506/**
507 * FieldPosition and UFieldPosition selectors for format fields
508 * defined by DateFormat and UDateFormat.
73c04bcf 509 * @stable ICU 3.0
374ca955
A
510 */
511typedef enum UDateFormatField {
512 /**
513 * FieldPosition and UFieldPosition selector for 'G' field alignment,
514 * corresponding to the UCAL_ERA field.
73c04bcf 515 * @stable ICU 3.0
374ca955
A
516 */
517 UDAT_ERA_FIELD = 0,
518
519 /**
520 * FieldPosition and UFieldPosition selector for 'y' field alignment,
521 * corresponding to the UCAL_YEAR field.
73c04bcf 522 * @stable ICU 3.0
374ca955
A
523 */
524 UDAT_YEAR_FIELD = 1,
525
526 /**
527 * FieldPosition and UFieldPosition selector for 'M' field alignment,
528 * corresponding to the UCAL_MONTH field.
73c04bcf 529 * @stable ICU 3.0
374ca955
A
530 */
531 UDAT_MONTH_FIELD = 2,
532
533 /**
534 * FieldPosition and UFieldPosition selector for 'd' field alignment,
535 * corresponding to the UCAL_DATE field.
73c04bcf 536 * @stable ICU 3.0
374ca955
A
537 */
538 UDAT_DATE_FIELD = 3,
539
540 /**
541 * FieldPosition and UFieldPosition selector for 'k' field alignment,
542 * corresponding to the UCAL_HOUR_OF_DAY field.
543 * UDAT_HOUR_OF_DAY1_FIELD is used for the one-based 24-hour clock.
544 * For example, 23:59 + 01:00 results in 24:59.
73c04bcf 545 * @stable ICU 3.0
374ca955
A
546 */
547 UDAT_HOUR_OF_DAY1_FIELD = 4,
548
549 /**
550 * FieldPosition and UFieldPosition selector for 'H' field alignment,
551 * corresponding to the UCAL_HOUR_OF_DAY field.
552 * UDAT_HOUR_OF_DAY0_FIELD is used for the zero-based 24-hour clock.
553 * For example, 23:59 + 01:00 results in 00:59.
73c04bcf 554 * @stable ICU 3.0
374ca955
A
555 */
556 UDAT_HOUR_OF_DAY0_FIELD = 5,
557
558 /**
559 * FieldPosition and UFieldPosition selector for 'm' field alignment,
560 * corresponding to the UCAL_MINUTE field.
73c04bcf 561 * @stable ICU 3.0
374ca955
A
562 */
563 UDAT_MINUTE_FIELD = 6,
564
565 /**
566 * FieldPosition and UFieldPosition selector for 's' field alignment,
567 * corresponding to the UCAL_SECOND field.
73c04bcf 568 * @stable ICU 3.0
374ca955
A
569 */
570 UDAT_SECOND_FIELD = 7,
571
572 /**
573 * FieldPosition and UFieldPosition selector for 'S' field alignment,
574 * corresponding to the UCAL_MILLISECOND field.
51004dcb
A
575 *
576 * Note: Time formats that use 'S' can display a maximum of three
577 * significant digits for fractional seconds, corresponding to millisecond
578 * resolution and a fractional seconds sub-pattern of SSS. If the
579 * sub-pattern is S or SS, the fractional seconds value will be truncated
580 * (not rounded) to the number of display places specified. If the
581 * fractional seconds sub-pattern is longer than SSS, the additional
582 * display places will be filled with zeros.
73c04bcf 583 * @stable ICU 3.0
374ca955
A
584 */
585 UDAT_FRACTIONAL_SECOND_FIELD = 8,
586
587 /**
588 * FieldPosition and UFieldPosition selector for 'E' field alignment,
589 * corresponding to the UCAL_DAY_OF_WEEK field.
73c04bcf 590 * @stable ICU 3.0
374ca955
A
591 */
592 UDAT_DAY_OF_WEEK_FIELD = 9,
593
594 /**
595 * FieldPosition and UFieldPosition selector for 'D' field alignment,
596 * corresponding to the UCAL_DAY_OF_YEAR field.
73c04bcf 597 * @stable ICU 3.0
374ca955
A
598 */
599 UDAT_DAY_OF_YEAR_FIELD = 10,
600
601 /**
602 * FieldPosition and UFieldPosition selector for 'F' field alignment,
603 * corresponding to the UCAL_DAY_OF_WEEK_IN_MONTH field.
73c04bcf 604 * @stable ICU 3.0
374ca955
A
605 */
606 UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11,
607
608 /**
609 * FieldPosition and UFieldPosition selector for 'w' field alignment,
610 * corresponding to the UCAL_WEEK_OF_YEAR field.
73c04bcf 611 * @stable ICU 3.0
374ca955
A
612 */
613 UDAT_WEEK_OF_YEAR_FIELD = 12,
614
615 /**
616 * FieldPosition and UFieldPosition selector for 'W' field alignment,
617 * corresponding to the UCAL_WEEK_OF_MONTH field.
73c04bcf 618 * @stable ICU 3.0
374ca955
A
619 */
620 UDAT_WEEK_OF_MONTH_FIELD = 13,
621
622 /**
623 * FieldPosition and UFieldPosition selector for 'a' field alignment,
624 * corresponding to the UCAL_AM_PM field.
73c04bcf 625 * @stable ICU 3.0
374ca955
A
626 */
627 UDAT_AM_PM_FIELD = 14,
628
629 /**
630 * FieldPosition and UFieldPosition selector for 'h' field alignment,
631 * corresponding to the UCAL_HOUR field.
632 * UDAT_HOUR1_FIELD is used for the one-based 12-hour clock.
633 * For example, 11:30 PM + 1 hour results in 12:30 AM.
73c04bcf 634 * @stable ICU 3.0
374ca955
A
635 */
636 UDAT_HOUR1_FIELD = 15,
637
638 /**
639 * FieldPosition and UFieldPosition selector for 'K' field alignment,
640 * corresponding to the UCAL_HOUR field.
641 * UDAT_HOUR0_FIELD is used for the zero-based 12-hour clock.
642 * For example, 11:30 PM + 1 hour results in 00:30 AM.
73c04bcf 643 * @stable ICU 3.0
374ca955
A
644 */
645 UDAT_HOUR0_FIELD = 16,
646
647 /**
648 * FieldPosition and UFieldPosition selector for 'z' field alignment,
649 * corresponding to the UCAL_ZONE_OFFSET and
650 * UCAL_DST_OFFSET fields.
73c04bcf 651 * @stable ICU 3.0
374ca955
A
652 */
653 UDAT_TIMEZONE_FIELD = 17,
654
655 /**
656 * FieldPosition and UFieldPosition selector for 'Y' field alignment,
657 * corresponding to the UCAL_YEAR_WOY field.
73c04bcf 658 * @stable ICU 3.0
374ca955
A
659 */
660 UDAT_YEAR_WOY_FIELD = 18,
661
662 /**
663 * FieldPosition and UFieldPosition selector for 'e' field alignment,
664 * corresponding to the UCAL_DOW_LOCAL field.
73c04bcf 665 * @stable ICU 3.0
374ca955
A
666 */
667 UDAT_DOW_LOCAL_FIELD = 19,
668
669 /**
670 * FieldPosition and UFieldPosition selector for 'u' field alignment,
671 * corresponding to the UCAL_EXTENDED_YEAR field.
73c04bcf 672 * @stable ICU 3.0
374ca955
A
673 */
674 UDAT_EXTENDED_YEAR_FIELD = 20,
675
676 /**
677 * FieldPosition and UFieldPosition selector for 'g' field alignment,
678 * corresponding to the UCAL_JULIAN_DAY field.
73c04bcf 679 * @stable ICU 3.0
374ca955
A
680 */
681 UDAT_JULIAN_DAY_FIELD = 21,
682
683 /**
684 * FieldPosition and UFieldPosition selector for 'A' field alignment,
685 * corresponding to the UCAL_MILLISECONDS_IN_DAY field.
73c04bcf 686 * @stable ICU 3.0
374ca955
A
687 */
688 UDAT_MILLISECONDS_IN_DAY_FIELD = 22,
689
690 /**
691 * FieldPosition and UFieldPosition selector for 'Z' field alignment,
692 * corresponding to the UCAL_ZONE_OFFSET and
693 * UCAL_DST_OFFSET fields.
73c04bcf 694 * @stable ICU 3.0
374ca955
A
695 */
696 UDAT_TIMEZONE_RFC_FIELD = 23,
697
73c04bcf
A
698 /**
699 * FieldPosition and UFieldPosition selector for 'v' field alignment,
700 * corresponding to the UCAL_ZONE_OFFSET field.
46f4442e 701 * @stable ICU 3.4
73c04bcf
A
702 */
703 UDAT_TIMEZONE_GENERIC_FIELD = 24,
704 /**
705 * FieldPosition selector for 'c' field alignment,
729e4ab9 706 * corresponding to the {@link #UCAL_DOW_LOCAL} field.
73c04bcf 707 * This displays the stand alone day name, if available.
46f4442e 708 * @stable ICU 3.4
73c04bcf
A
709 */
710 UDAT_STANDALONE_DAY_FIELD = 25,
729e4ab9 711
73c04bcf
A
712 /**
713 * FieldPosition selector for 'L' field alignment,
729e4ab9 714 * corresponding to the {@link #UCAL_MONTH} field.
73c04bcf 715 * This displays the stand alone month name, if available.
46f4442e 716 * @stable ICU 3.4
73c04bcf
A
717 */
718 UDAT_STANDALONE_MONTH_FIELD = 26,
719
720 /**
721 * FieldPosition selector for "Q" field alignment,
722 * corresponding to quarters. This is implemented
46f4442e 723 * using the {@link #UCAL_MONTH} field. This
73c04bcf 724 * displays the quarter.
46f4442e 725 * @stable ICU 3.6
73c04bcf
A
726 */
727 UDAT_QUARTER_FIELD = 27,
728
374ca955 729 /**
73c04bcf
A
730 * FieldPosition selector for the "q" field alignment,
731 * corresponding to stand-alone quarters. This is
46f4442e 732 * implemented using the {@link #UCAL_MONTH} field.
73c04bcf 733 * This displays the stand-alone quarter.
46f4442e 734 * @stable ICU 3.6
73c04bcf
A
735 */
736 UDAT_STANDALONE_QUARTER_FIELD = 28,
737
46f4442e
A
738 /**
739 * FieldPosition and UFieldPosition selector for 'V' field alignment,
740 * corresponding to the UCAL_ZONE_OFFSET field.
741 * @stable ICU 3.8
742 */
743 UDAT_TIMEZONE_SPECIAL_FIELD = 29,
744
4388f060
A
745 /**
746 * FieldPosition selector for "U" field alignment,
747 * corresponding to cyclic year names. This is implemented
748 * using the {@link #UCAL_YEAR} field. This displays
749 * the cyclic year name, if available.
51004dcb 750 * @stable ICU 49
4388f060
A
751 */
752 UDAT_YEAR_NAME_FIELD = 30,
753
51004dcb
A
754 /**
755 * FieldPosition selector for 'O' field alignment,
756 * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSETfields.
757 * This displays the localized GMT format.
57a6839d 758 * @stable ICU 51
51004dcb
A
759 */
760 UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD = 31,
761
762 /**
763 * FieldPosition selector for 'X' field alignment,
764 * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSETfields.
765 * This displays the ISO 8601 local time offset format or UTC indicator ("Z").
57a6839d 766 * @stable ICU 51
51004dcb
A
767 */
768 UDAT_TIMEZONE_ISO_FIELD = 32,
769
770 /**
771 * FieldPosition selector for 'x' field alignment,
57a6839d 772 * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSET fields.
51004dcb 773 * This displays the ISO 8601 local time offset format.
57a6839d 774 * @stable ICU 51
51004dcb
A
775 */
776 UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33,
51004dcb 777
57a6839d 778#ifndef U_HIDE_INTERNAL_API
51004dcb 779 /**
57a6839d
A
780 * FieldPosition and UFieldPosition selector for 'r' field alignment,
781 * no directly corresponding UCAL_ field.
782 * @internal ICU 53
783 */
784 UDAT_RELATED_YEAR_FIELD = 34,
2ca993e8 785#endif /* U_HIDE_INTERNAL_API */
57a6839d 786
b331163b 787 /**
2ca993e8
A
788 * FieldPosition selector for 'b' field alignment.
789 * Displays midnight and noon for 12am and 12pm, respectively, if available;
790 * otherwise fall back to AM / PM.
f3c0d7a5 791 * @stable ICU 57
2ca993e8
A
792 */
793 UDAT_AM_PM_MIDNIGHT_NOON_FIELD = 35,
794
795 /* FieldPosition selector for 'B' field alignment.
796 * Displays flexible day periods, such as "in the morning", if available.
f3c0d7a5 797 * @stable ICU 57
2ca993e8
A
798 */
799 UDAT_FLEXIBLE_DAY_PERIOD_FIELD = 36,
2ca993e8
A
800
801#ifndef U_HIDE_INTERNAL_API
802 /**
803 * FieldPosition and UFieldPosition selector for time separator,
804 * no corresponding UCAL_ field. No pattern character is currently
805 * defined for this.
806 * @internal
b331163b 807 */
2ca993e8
A
808 UDAT_TIME_SEPARATOR_FIELD = 37,
809#endif /* U_HIDE_INTERNAL_API */
b331163b 810
f3c0d7a5
A
811#ifndef U_HIDE_DEPRECATED_API
812 /**
729e4ab9 813 * Number of FieldPosition and UFieldPosition selectors for
374ca955
A
814 * DateFormat and UDateFormat.
815 * Valid selectors range from 0 to UDAT_FIELD_COUNT-1.
f3c0d7a5 816 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
374ca955 817 */
2ca993e8 818 UDAT_FIELD_COUNT = 38
f3c0d7a5 819#endif /* U_HIDE_DEPRECATED_API */
374ca955
A
820} UDateFormatField;
821
729e4ab9 822
2ca993e8
A
823#ifndef U_HIDE_INTERNAL_API
824/**
825 * Is a pattern character defined for UDAT_TIME_SEPARATOR_FIELD?
826 * In ICU 55 it was COLON, but that was withdrawn in ICU 56.
827 * @internal ICU 56
828 */
829#define UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR 0
830#endif /* U_HIDE_INTERNAL_API */
831
832
729e4ab9
A
833/**
834 * Maps from a UDateFormatField to the corresponding UCalendarDateFields.
835 * Note: since the mapping is many-to-one, there is no inverse mapping.
836 * @param field the UDateFormatField.
837 * @return the UCalendarDateField. This will be UCAL_FIELD_COUNT in case
838 * of error (e.g., the input field is UDAT_FIELD_COUNT).
839 * @stable ICU 4.4
840 */
f3c0d7a5 841U_CAPI UCalendarDateFields U_EXPORT2
729e4ab9
A
842udat_toCalendarDateField(UDateFormatField field);
843
844
340931cb
A
845#ifndef U_HIDE_INTERNAL_API
846/**
847 * Maps from a pattern character to the corresponding UDateFormatField.
848 * @return the UDateFormatField. This will be UDAT_FIELD_COUNT if the
849 * specified character does not correspond to any UDateFormatField value.
850 * @internal Apple <rdar://problem/62136559>
851 */
852U_CAPI UDateFormatField U_EXPORT2
853udat_patternCharToDateFormatField(UChar patternChar);
854#endif /* U_HIDE_INTERNAL_API */
855
856
b75a7d8f
A
857/**
858 * Open a new UDateFormat for formatting and parsing dates and times.
374ca955
A
859 * A UDateFormat may be used to format dates in calls to {@link #udat_format },
860 * and to parse dates in calls to {@link #udat_parse }.
861 * @param timeStyle The style used to format times; one of UDAT_FULL, UDAT_LONG,
46f4442e 862 * UDAT_MEDIUM, UDAT_SHORT, UDAT_DEFAULT, or UDAT_NONE (relative time styles
4388f060 863 * are not currently supported).
51004dcb 864 * When the pattern parameter is used, pass in UDAT_PATTERN for both timeStyle and dateStyle.
374ca955 865 * @param dateStyle The style used to format dates; one of UDAT_FULL, UDAT_LONG,
46f4442e 866 * UDAT_MEDIUM, UDAT_SHORT, UDAT_DEFAULT, UDAT_FULL_RELATIVE, UDAT_LONG_RELATIVE,
51004dcb
A
867 * UDAT_MEDIUM_RELATIVE, UDAT_SHORT_RELATIVE, or UDAT_NONE.
868 * When the pattern parameter is used, pass in UDAT_PATTERN for both timeStyle and dateStyle.
869 * As currently implemented,
4388f060
A
870 * relative date formatting only affects a limited range of calendar days before or
871 * after the current date, based on the CLDR &lt;field type="day"&gt;/&lt;relative&gt; data: For
872 * example, in English, "Yesterday", "Today", and "Tomorrow". Outside of this range,
873 * dates are formatted using the corresponding non-relative style.
b75a7d8f
A
874 * @param locale The locale specifying the formatting conventions
875 * @param tzID A timezone ID specifying the timezone to use. If 0, use
876 * the default timezone.
877 * @param tzIDLength The length of tzID, or -1 if null-terminated.
878 * @param pattern A pattern specifying the format to use.
879 * @param patternLength The number of characters in the pattern, or -1 if null-terminated.
880 * @param status A pointer to an UErrorCode to receive any errors
881 * @return A pointer to a UDateFormat to use for formatting dates and times, or 0 if
882 * an error occurred.
883 * @stable ICU 2.0
884 */
f3c0d7a5 885U_CAPI UDateFormat* U_EXPORT2
b75a7d8f
A
886udat_open(UDateFormatStyle timeStyle,
887 UDateFormatStyle dateStyle,
888 const char *locale,
889 const UChar *tzID,
890 int32_t tzIDLength,
891 const UChar *pattern,
892 int32_t patternLength,
893 UErrorCode *status);
894
895
896/**
897* Close a UDateFormat.
898* Once closed, a UDateFormat may no longer be used.
899* @param format The formatter to close.
900* @stable ICU 2.0
901*/
f3c0d7a5 902U_CAPI void U_EXPORT2
b75a7d8f
A
903udat_close(UDateFormat* format);
904
57a6839d 905
57a6839d
A
906/**
907 * DateFormat boolean attributes
2ca993e8 908 *
b331163b 909 * @stable ICU 53
57a6839d
A
910 */
911typedef enum UDateFormatBooleanAttribute {
57a6839d
A
912 /**
913 * indicates whether whitespace is allowed. Includes trailing dot tolerance.
b331163b 914 * @stable ICU 53
57a6839d
A
915 */
916 UDAT_PARSE_ALLOW_WHITESPACE = 0,
917 /**
918 * indicates tolerance of numeric data when String data may be assumed. eg: UDAT_YEAR_NAME_FIELD,
b331163b
A
919 * UDAT_STANDALONE_MONTH_FIELD, UDAT_DAY_OF_WEEK_FIELD
920 * @stable ICU 53
57a6839d
A
921 */
922 UDAT_PARSE_ALLOW_NUMERIC = 1,
923 /**
924 * indicates tolerance of a partial literal match
2ca993e8 925 * e.g. accepting "--mon-02-march-2011" for a pattern of "'--: 'EEE-WW-MMMM-yyyy"
f3c0d7a5 926 * @stable ICU 56
2ca993e8
A
927 */
928 UDAT_PARSE_PARTIAL_LITERAL_MATCH = 2,
929 /**
930 * indicates tolerance of pattern mismatch between input data and specified format pattern.
931 * e.g. accepting "September" for a month pattern of MMM ("Sep")
f3c0d7a5 932 * @stable ICU 56
57a6839d 933 */
57a6839d 934 UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3,
f3c0d7a5
A
935
936 /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
937 * it is needed for layout of DateFormat object. */
340931cb 938#ifndef U_FORCE_HIDE_DEPRECATED_API
57a6839d 939 /**
f3c0d7a5
A
940 * One more than the highest normal UDateFormatBooleanAttribute value.
941 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
57a6839d
A
942 */
943 UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4
340931cb 944#endif // U_FORCE_HIDE_DEPRECATED_API
57a6839d
A
945} UDateFormatBooleanAttribute;
946
57a6839d
A
947/**
948 * Get a boolean attribute associated with a UDateFormat.
949 * An example would be a true value for a key of UDAT_PARSE_ALLOW_WHITESPACE indicating allowing whitespace leniency.
950 * If the formatter does not understand the attribute, -1 is returned.
951 * @param fmt The formatter to query.
952 * @param attr The attribute to query; e.g. UDAT_PARSE_ALLOW_WHITESPACE.
953 * @param status A pointer to an UErrorCode to receive any errors
954 * @return The value of attr.
b331163b 955 * @stable ICU 53
57a6839d 956 */
f3c0d7a5 957U_CAPI UBool U_EXPORT2
57a6839d
A
958udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute attr, UErrorCode* status);
959
960/**
961 * Set a boolean attribute associated with a UDateFormat.
962 * An example of a boolean attribute is parse leniency control. If the formatter does not understand
963 * the attribute, the call is ignored.
964 * @param fmt The formatter to set.
965 * @param attr The attribute to set; one of UDAT_PARSE_ALLOW_WHITESPACE or UDAT_PARSE_ALLOW_NUMERIC
966 * @param newValue The new value of attr.
967 * @param status A pointer to an UErrorCode to receive any errors
b331163b 968 * @stable ICU 53
57a6839d 969 */
f3c0d7a5 970U_CAPI void U_EXPORT2
57a6839d
A
971udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBool newValue, UErrorCode* status);
972
57a6839d
A
973
974
729e4ab9
A
975#if U_SHOW_CPLUSPLUS_API
976
977U_NAMESPACE_BEGIN
978
979/**
980 * \class LocalUDateFormatPointer
981 * "Smart pointer" class, closes a UDateFormat via udat_close().
982 * For most methods see the LocalPointerBase base class.
983 *
984 * @see LocalPointerBase
985 * @see LocalPointer
986 * @stable ICU 4.4
987 */
988U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateFormatPointer, UDateFormat, udat_close);
989
990U_NAMESPACE_END
991
340931cb 992#endif
729e4ab9 993
b75a7d8f
A
994/**
995 * Open a copy of a UDateFormat.
996 * This function performs a deep copy.
997 * @param fmt The format to copy
998 * @param status A pointer to an UErrorCode to receive any errors.
999 * @return A pointer to a UDateFormat identical to fmt.
1000 * @stable ICU 2.0
1001 */
f3c0d7a5 1002U_CAPI UDateFormat* U_EXPORT2
b75a7d8f
A
1003udat_clone(const UDateFormat *fmt,
1004 UErrorCode *status);
1005
1006/**
b331163b 1007* Format a date using a UDateFormat.
374ca955 1008* The date will be formatted using the conventions specified in {@link #udat_open }
b75a7d8f
A
1009* @param format The formatter to use
1010* @param dateToFormat The date to format
1011* @param result A pointer to a buffer to receive the formatted number.
1012* @param resultLength The maximum size of result.
1013* @param position A pointer to a UFieldPosition. On input, position->field
1014* is read. On output, position->beginIndex and position->endIndex indicate
1015* the beginning and ending indices of field number position->field, if such
1016* a field exists. This parameter may be NULL, in which case no field
1017* position data is returned.
1018* @param status A pointer to an UErrorCode to receive any errors
1019* @return The total buffer size needed; if greater than resultLength, the output was truncated.
1020* @see udat_parse
1021* @see UFieldPosition
1022* @stable ICU 2.0
1023*/
f3c0d7a5 1024U_CAPI int32_t U_EXPORT2
b75a7d8f
A
1025udat_format( const UDateFormat* format,
1026 UDate dateToFormat,
1027 UChar* result,
1028 int32_t resultLength,
1029 UFieldPosition* position,
1030 UErrorCode* status);
1031
b331163b
A
1032/**
1033* Format a date using an UDateFormat.
1034* The date will be formatted using the conventions specified in {@link #udat_open }
1035* @param format The formatter to use
1036* @param calendar The calendar to format. The calendar instance might be
1037* mutated if fields are not yet fully calculated, though
1038* the function won't change the logical date and time held
1039* by the instance.
1040* @param result A pointer to a buffer to receive the formatted number.
1041* @param capacity The maximum size of result.
1042* @param position A pointer to a UFieldPosition. On input, position->field
1043* is read. On output, position->beginIndex and position->endIndex indicate
1044* the beginning and ending indices of field number position->field, if such
1045* a field exists. This parameter may be NULL, in which case no field
1046* position data is returned.
1047* @param status A pointer to an UErrorCode to receive any errors
1048* @return The total buffer size needed; if greater than resultLength, the output was truncated.
1049* @see udat_format
1050* @see udat_parseCalendar
1051* @see UFieldPosition
2ca993e8 1052* @stable ICU 55
b331163b 1053*/
f3c0d7a5 1054U_CAPI int32_t U_EXPORT2
b331163b
A
1055udat_formatCalendar( const UDateFormat* format,
1056 UCalendar* calendar,
1057 UChar* result,
1058 int32_t capacity,
1059 UFieldPosition* position,
1060 UErrorCode* status);
1061
1062/**
1063* Format a date using a UDateFormat.
1064* The date will be formatted using the conventions specified in {@link #udat_open}
1065* @param format
1066* The formatter to use
1067* @param dateToFormat
1068* The date to format
1069* @param result
1070* A pointer to a buffer to receive the formatted number.
1071* @param resultLength
1072* The maximum size of result.
1073* @param fpositer
1074* A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open}
1075* (may be NULL if field position information is not needed). Any
1076* iteration information already present in the UFieldPositionIterator
1077* will be deleted, and the iterator will be reset to apply to the
1078* fields in the formatted string created by this function call; the
1079* field values provided by {@link #ufieldpositer_next} will be from the
1080* UDateFormatField enum.
1081* @param status
1082* A pointer to a UErrorCode to receive any errors
1083* @return
1084* The total buffer size needed; if greater than resultLength, the output was truncated.
1085* @see udat_parse
1086* @see UFieldPositionIterator
2ca993e8 1087* @stable ICU 55
b331163b 1088*/
f3c0d7a5 1089U_CAPI int32_t U_EXPORT2
b331163b
A
1090udat_formatForFields( const UDateFormat* format,
1091 UDate dateToFormat,
1092 UChar* result,
1093 int32_t resultLength,
1094 UFieldPositionIterator* fpositer,
1095 UErrorCode* status);
1096
1097/**
1098* Format a date using a UDateFormat.
1099* The date will be formatted using the conventions specified in {@link #udat_open }
1100* @param format
1101* The formatter to use
1102* @param calendar
1103* The calendar to format. The calendar instance might be mutated if fields
1104* are not yet fully calculated, though the function won't change the logical
1105* date and time held by the instance.
1106* @param result
1107* A pointer to a buffer to receive the formatted number.
1108* @param capacity
1109* The maximum size of result.
1110* @param fpositer
1111* A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open}
1112* (may be NULL if field position information is not needed). Any
1113* iteration information already present in the UFieldPositionIterator
1114* will be deleted, and the iterator will be reset to apply to the
1115* fields in the formatted string created by this function call; the
1116* field values provided by {@link #ufieldpositer_next} will be from the
1117* UDateFormatField enum.
1118* @param status
1119* A pointer to a UErrorCode to receive any errors
1120* @return
1121* The total buffer size needed; if greater than resultLength, the output was truncated.
1122* @see udat_format
1123* @see udat_parseCalendar
1124* @see UFieldPositionIterator
2ca993e8 1125* @stable ICU 55
b331163b 1126*/
f3c0d7a5 1127U_CAPI int32_t U_EXPORT2
b331163b
A
1128udat_formatCalendarForFields( const UDateFormat* format,
1129 UCalendar* calendar,
1130 UChar* result,
1131 int32_t capacity,
1132 UFieldPositionIterator* fpositer,
1133 UErrorCode* status);
1134
b331163b 1135
b75a7d8f
A
1136/**
1137* Parse a string into an date/time using a UDateFormat.
4388f060
A
1138* The date will be parsed using the conventions specified in {@link #udat_open }.
1139* <P>
1140* Note that the normal date formats associated with some calendars - such
1141* as the Chinese lunar calendar - do not specify enough fields to enable
1142* dates to be parsed unambiguously. In the case of the Chinese lunar
1143* calendar, while the year within the current 60-year cycle is specified,
1144* the number of such cycles since the start date of the calendar (in the
1145* UCAL_ERA field of the UCalendar object) is not normally part of the format,
1146* and parsing may assume the wrong era. For cases such as this it is
1147* recommended that clients parse using udat_parseCalendar with the UCalendar
1148* passed in set to the current date, or to a date within the era/cycle that
1149* should be assumed if absent in the format.
1150*
b75a7d8f
A
1151* @param format The formatter to use.
1152* @param text The text to parse.
1153* @param textLength The length of text, or -1 if null-terminated.
1154* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
1155* to begin parsing. If not 0, on output the offset at which parsing ended.
1156* @param status A pointer to an UErrorCode to receive any errors
1157* @return The value of the parsed date/time
1158* @see udat_format
1159* @stable ICU 2.0
1160*/
f3c0d7a5 1161U_CAPI UDate U_EXPORT2
4388f060
A
1162udat_parse(const UDateFormat* format,
1163 const UChar* text,
b75a7d8f
A
1164 int32_t textLength,
1165 int32_t *parsePos,
1166 UErrorCode *status);
1167
1168/**
1169* Parse a string into an date/time using a UDateFormat.
4388f060 1170* The date will be parsed using the conventions specified in {@link #udat_open }.
b75a7d8f 1171* @param format The formatter to use.
4388f060
A
1172* @param calendar A calendar set on input to the date and time to be used for
1173* missing values in the date/time string being parsed, and set
1174* on output to the parsed date/time. When the calendar type is
1175* different from the internal calendar held by the UDateFormat
1176* instance, the internal calendar will be cloned to a work
1177* calendar set to the same milliseconds and time zone as this
1178* calendar parameter, field values will be parsed based on the
1179* work calendar, then the result (milliseconds and time zone)
1180* will be set in this calendar.
b75a7d8f
A
1181* @param text The text to parse.
1182* @param textLength The length of text, or -1 if null-terminated.
1183* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
1184* to begin parsing. If not 0, on output the offset at which parsing ended.
1185* @param status A pointer to an UErrorCode to receive any errors
1186* @see udat_format
1187* @stable ICU 2.0
1188*/
f3c0d7a5 1189U_CAPI void U_EXPORT2
b75a7d8f
A
1190udat_parseCalendar(const UDateFormat* format,
1191 UCalendar* calendar,
1192 const UChar* text,
1193 int32_t textLength,
1194 int32_t *parsePos,
1195 UErrorCode *status);
1196
1197/**
1198* Determine if an UDateFormat will perform lenient parsing.
1199* With lenient parsing, the parser may use heuristics to interpret inputs that do not
1200* precisely match the pattern. With strict parsing, inputs must match the pattern.
1201* @param fmt The formatter to query
1202* @return TRUE if fmt is set to perform lenient parsing, FALSE otherwise.
1203* @see udat_setLenient
1204* @stable ICU 2.0
1205*/
f3c0d7a5 1206U_CAPI UBool U_EXPORT2
b75a7d8f
A
1207udat_isLenient(const UDateFormat* fmt);
1208
1209/**
1210* Specify whether an UDateFormat will perform lenient parsing.
1211* With lenient parsing, the parser may use heuristics to interpret inputs that do not
1212* precisely match the pattern. With strict parsing, inputs must match the pattern.
1213* @param fmt The formatter to set
1214* @param isLenient TRUE if fmt should perform lenient parsing, FALSE otherwise.
1215* @see dat_isLenient
1216* @stable ICU 2.0
1217*/
f3c0d7a5 1218U_CAPI void U_EXPORT2
b75a7d8f
A
1219udat_setLenient( UDateFormat* fmt,
1220 UBool isLenient);
1221
1222/**
1223* Get the UCalendar associated with an UDateFormat.
1224* A UDateFormat uses a UCalendar to convert a raw value to, for example,
1225* the day of the week.
1226* @param fmt The formatter to query.
1227* @return A pointer to the UCalendar used by fmt.
1228* @see udat_setCalendar
1229* @stable ICU 2.0
1230*/
f3c0d7a5 1231U_CAPI const UCalendar* U_EXPORT2
b75a7d8f
A
1232udat_getCalendar(const UDateFormat* fmt);
1233
1234/**
1235* Set the UCalendar associated with an UDateFormat.
1236* A UDateFormat uses a UCalendar to convert a raw value to, for example,
1237* the day of the week.
1238* @param fmt The formatter to set.
1239* @param calendarToSet A pointer to an UCalendar to be used by fmt.
1240* @see udat_setCalendar
1241* @stable ICU 2.0
1242*/
f3c0d7a5 1243U_CAPI void U_EXPORT2
b75a7d8f
A
1244udat_setCalendar( UDateFormat* fmt,
1245 const UCalendar* calendarToSet);
1246
1247/**
1248* Get the UNumberFormat associated with an UDateFormat.
1249* A UDateFormat uses a UNumberFormat to format numbers within a date,
1250* for example the day number.
1251* @param fmt The formatter to query.
1252* @return A pointer to the UNumberFormat used by fmt to format numbers.
1253* @see udat_setNumberFormat
1254* @stable ICU 2.0
1255*/
f3c0d7a5 1256U_CAPI const UNumberFormat* U_EXPORT2
b75a7d8f
A
1257udat_getNumberFormat(const UDateFormat* fmt);
1258
b331163b
A
1259/**
1260* Get the UNumberFormat for specific field associated with an UDateFormat.
1261* For example: 'y' for year and 'M' for month
1262* @param fmt The formatter to query.
1263* @param field the field to query
1264* @return A pointer to the UNumberFormat used by fmt to format field numbers.
1265* @see udat_setNumberFormatForField
2ca993e8 1266* @stable ICU 54
b331163b 1267*/
f3c0d7a5 1268U_CAPI const UNumberFormat* U_EXPORT2
b331163b
A
1269udat_getNumberFormatForField(const UDateFormat* fmt, UChar field);
1270
1271/**
1272* Set the UNumberFormat for specific field associated with an UDateFormat.
1273* It can be a single field like: "y"(year) or "M"(month)
1274* It can be several field combined together: "yM"(year and month)
2ca993e8 1275* Note:
b331163b
A
1276* 1 symbol field is enough for multiple symbol field (so "y" will override "yy", "yyy")
1277* If the field is not numeric, then override has no effect (like "MMM" will use abbreviation, not numerical field)
1278*
1279* @param fields the fields to set
1280* @param fmt The formatter to set.
1281* @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to format numbers.
1282* @param status error code passed around (memory allocation or invalid fields)
1283* @see udat_getNumberFormatForField
2ca993e8 1284* @stable ICU 54
b331163b 1285*/
f3c0d7a5 1286U_CAPI void U_EXPORT2
b331163b
A
1287udat_adoptNumberFormatForFields( UDateFormat* fmt,
1288 const UChar* fields,
1289 UNumberFormat* numberFormatToSet,
1290 UErrorCode* status);
b75a7d8f
A
1291/**
1292* Set the UNumberFormat associated with an UDateFormat.
1293* A UDateFormat uses a UNumberFormat to format numbers within a date,
1294* for example the day number.
2ca993e8
A
1295* This method also clears per field NumberFormat instances previously
1296* set by {@see udat_setNumberFormatForField}
b75a7d8f
A
1297* @param fmt The formatter to set.
1298* @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to format numbers.
1299* @see udat_getNumberFormat
b331163b 1300* @see udat_setNumberFormatForField
b75a7d8f
A
1301* @stable ICU 2.0
1302*/
f3c0d7a5 1303U_CAPI void U_EXPORT2
b75a7d8f
A
1304udat_setNumberFormat( UDateFormat* fmt,
1305 const UNumberFormat* numberFormatToSet);
b331163b
A
1306/**
1307* Adopt the UNumberFormat associated with an UDateFormat.
1308* A UDateFormat uses a UNumberFormat to format numbers within a date,
1309* for example the day number.
1310* @param fmt The formatter to set.
1311* @param numberFormatToAdopt A pointer to the UNumberFormat to be used by fmt to format numbers.
1312* @see udat_getNumberFormat
2ca993e8 1313* @stable ICU 54
b331163b 1314*/
f3c0d7a5 1315U_CAPI void U_EXPORT2
b331163b
A
1316udat_adoptNumberFormat( UDateFormat* fmt,
1317 UNumberFormat* numberFormatToAdopt);
b75a7d8f
A
1318/**
1319* Get a locale for which date/time formatting patterns are available.
1320* A UDateFormat in a locale returned by this function will perform the correct
1321* formatting and parsing for the locale.
46f4442e 1322* @param localeIndex The index of the desired locale.
b75a7d8f
A
1323* @return A locale for which date/time formatting patterns are available, or 0 if none.
1324* @see udat_countAvailable
1325* @stable ICU 2.0
1326*/
f3c0d7a5 1327U_CAPI const char* U_EXPORT2
46f4442e 1328udat_getAvailable(int32_t localeIndex);
b75a7d8f
A
1329
1330/**
1331* Determine how many locales have date/time formatting patterns available.
1332* This function is most useful as determining the loop ending condition for
374ca955 1333* calls to {@link #udat_getAvailable }.
b75a7d8f
A
1334* @return The number of locales for which date/time formatting patterns are available.
1335* @see udat_getAvailable
1336* @stable ICU 2.0
1337*/
f3c0d7a5 1338U_CAPI int32_t U_EXPORT2
b75a7d8f
A
1339udat_countAvailable(void);
1340
1341/**
1342* Get the year relative to which all 2-digit years are interpreted.
1343* For example, if the 2-digit start year is 2100, the year 99 will be
1344* interpreted as 2199.
1345* @param fmt The formatter to query.
1346* @param status A pointer to an UErrorCode to receive any errors
1347* @return The year relative to which all 2-digit years are interpreted.
1348* @see udat_Set2DigitYearStart
1349* @stable ICU 2.0
1350*/
f3c0d7a5 1351U_CAPI UDate U_EXPORT2
b75a7d8f
A
1352udat_get2DigitYearStart( const UDateFormat *fmt,
1353 UErrorCode *status);
1354
1355/**
1356* Set the year relative to which all 2-digit years will be interpreted.
1357* For example, if the 2-digit start year is 2100, the year 99 will be
1358* interpreted as 2199.
1359* @param fmt The formatter to set.
1360* @param d The year relative to which all 2-digit years will be interpreted.
1361* @param status A pointer to an UErrorCode to receive any errors
1362* @see udat_Set2DigitYearStart
1363* @stable ICU 2.0
1364*/
f3c0d7a5 1365U_CAPI void U_EXPORT2
b75a7d8f
A
1366udat_set2DigitYearStart( UDateFormat *fmt,
1367 UDate d,
1368 UErrorCode *status);
1369
1370/**
1371* Extract the pattern from a UDateFormat.
1372* The pattern will follow the pattern syntax rules.
1373* @param fmt The formatter to query.
1374* @param localized TRUE if the pattern should be localized, FALSE otherwise.
1375* @param result A pointer to a buffer to receive the pattern.
1376* @param resultLength The maximum size of result.
1377* @param status A pointer to an UErrorCode to receive any errors
1378* @return The total buffer size needed; if greater than resultLength, the output was truncated.
1379* @see udat_applyPattern
1380* @stable ICU 2.0
1381*/
f3c0d7a5 1382U_CAPI int32_t U_EXPORT2
b75a7d8f
A
1383udat_toPattern( const UDateFormat *fmt,
1384 UBool localized,
1385 UChar *result,
1386 int32_t resultLength,
1387 UErrorCode *status);
1388
1389/**
1390* Set the pattern used by an UDateFormat.
1391* The pattern should follow the pattern syntax rules.
1392* @param format The formatter to set.
1393* @param localized TRUE if the pattern is localized, FALSE otherwise.
1394* @param pattern The new pattern
1395* @param patternLength The length of pattern, or -1 if null-terminated.
1396* @see udat_toPattern
1397* @stable ICU 2.0
1398*/
f3c0d7a5 1399U_CAPI void U_EXPORT2
b75a7d8f
A
1400udat_applyPattern( UDateFormat *format,
1401 UBool localized,
1402 const UChar *pattern,
1403 int32_t patternLength);
1404
2ca993e8
A
1405/**
1406 * The possible types of date format symbols
b75a7d8f
A
1407 * @stable ICU 2.6
1408 */
1409typedef enum UDateFormatSymbolType {
1410 /** The era names, for example AD */
1411 UDAT_ERAS,
1412 /** The month names, for example February */
1413 UDAT_MONTHS,
1414 /** The short month names, for example Feb. */
1415 UDAT_SHORT_MONTHS,
51004dcb 1416 /** The CLDR-style format "wide" weekday names, for example Monday */
b75a7d8f 1417 UDAT_WEEKDAYS,
51004dcb
A
1418 /**
1419 * The CLDR-style format "abbreviated" (not "short") weekday names, for example "Mon."
1420 * For the CLDR-style format "short" weekday names, use UDAT_SHORTER_WEEKDAYS.
1421 */
b75a7d8f
A
1422 UDAT_SHORT_WEEKDAYS,
1423 /** The AM/PM names, for example AM */
1424 UDAT_AM_PMS,
1425 /** The localized characters */
73c04bcf
A
1426 UDAT_LOCALIZED_CHARS,
1427 /** The long era names, for example Anno Domini */
1428 UDAT_ERA_NAMES,
1429 /** The narrow month names, for example F */
1430 UDAT_NARROW_MONTHS,
51004dcb 1431 /** The CLDR-style format "narrow" weekday names, for example "M" */
73c04bcf
A
1432 UDAT_NARROW_WEEKDAYS,
1433 /** Standalone context versions of months */
1434 UDAT_STANDALONE_MONTHS,
1435 UDAT_STANDALONE_SHORT_MONTHS,
1436 UDAT_STANDALONE_NARROW_MONTHS,
51004dcb 1437 /** The CLDR-style stand-alone "wide" weekday names */
73c04bcf 1438 UDAT_STANDALONE_WEEKDAYS,
51004dcb
A
1439 /**
1440 * The CLDR-style stand-alone "abbreviated" (not "short") weekday names.
1441 * For the CLDR-style stand-alone "short" weekday names, use UDAT_STANDALONE_SHORTER_WEEKDAYS.
1442 */
73c04bcf 1443 UDAT_STANDALONE_SHORT_WEEKDAYS,
51004dcb 1444 /** The CLDR-style stand-alone "narrow" weekday names */
73c04bcf
A
1445 UDAT_STANDALONE_NARROW_WEEKDAYS,
1446 /** The quarters, for example 1st Quarter */
1447 UDAT_QUARTERS,
1448 /** The short quarter names, for example Q1 */
1449 UDAT_SHORT_QUARTERS,
1450 /** Standalone context versions of quarters */
1451 UDAT_STANDALONE_QUARTERS,
51004dcb 1452 UDAT_STANDALONE_SHORT_QUARTERS,
51004dcb
A
1453 /**
1454 * The CLDR-style short weekday names, e.g. "Su", Mo", etc.
1455 * These are named "SHORTER" to contrast with the constants using _SHORT_
1456 * above, which actually get the CLDR-style *abbreviated* versions of the
1457 * corresponding names.
57a6839d 1458 * @stable ICU 51
51004dcb
A
1459 */
1460 UDAT_SHORTER_WEEKDAYS,
1461 /**
1462 * Standalone version of UDAT_SHORTER_WEEKDAYS.
57a6839d 1463 * @stable ICU 51
51004dcb 1464 */
2ca993e8 1465 UDAT_STANDALONE_SHORTER_WEEKDAYS,
b331163b
A
1466 /**
1467 * Cyclic year names (only supported for some calendars, and only for FORMAT usage;
1468 * udat_setSymbols not supported for UDAT_CYCLIC_YEARS_WIDE)
2ca993e8 1469 * @stable ICU 54
b331163b
A
1470 */
1471 UDAT_CYCLIC_YEARS_WIDE,
1472 /**
1473 * Cyclic year names (only supported for some calendars, and only for FORMAT usage)
2ca993e8 1474 * @stable ICU 54
b331163b
A
1475 */
1476 UDAT_CYCLIC_YEARS_ABBREVIATED,
1477 /**
1478 * Cyclic year names (only supported for some calendars, and only for FORMAT usage;
1479 * udat_setSymbols not supported for UDAT_CYCLIC_YEARS_NARROW)
2ca993e8 1480 * @stable ICU 54
b331163b
A
1481 */
1482 UDAT_CYCLIC_YEARS_NARROW,
1483 /**
1484 * Calendar zodiac names (only supported for some calendars, and only for FORMAT usage;
1485 * udat_setSymbols not supported for UDAT_ZODIAC_NAMES_WIDE)
2ca993e8 1486 * @stable ICU 54
b331163b
A
1487 */
1488 UDAT_ZODIAC_NAMES_WIDE,
1489 /**
1490 * Calendar zodiac names (only supported for some calendars, and only for FORMAT usage)
2ca993e8 1491 * @stable ICU 54
b331163b
A
1492 */
1493 UDAT_ZODIAC_NAMES_ABBREVIATED,
1494 /**
1495 * Calendar zodiac names (only supported for some calendars, and only for FORMAT usage;
1496 * udat_setSymbols not supported for UDAT_ZODIAC_NAMES_NARROW)
2ca993e8 1497 * @stable ICU 54
b331163b
A
1498 */
1499 UDAT_ZODIAC_NAMES_NARROW
57a6839d 1500#ifndef U_HIDE_INTERNAL_API
b331163b 1501 ,
57a6839d
A
1502 /**
1503 * Apple-specific,.
1504 * only for udat_getSymbols.
1505 * no directly corresponding UCAL_ field.
1506 * @internal ICU 54
1507 */
1508 UADAT_CYCLIC_ZODIAC_NAMES = 128
1509#endif /* U_HIDE_INTERNAL_API */
b75a7d8f
A
1510} UDateFormatSymbolType;
1511
1512struct UDateFormatSymbols;
1513/** Date format symbols.
1514 * For usage in C programs.
1515 * @stable ICU 2.6
1516 */
1517typedef struct UDateFormatSymbols UDateFormatSymbols;
1518
1519/**
1520* Get the symbols associated with an UDateFormat.
1521* The symbols are what a UDateFormat uses to represent locale-specific data,
1522* for example month or day names.
1523* @param fmt The formatter to query.
1524* @param type The type of symbols to get. One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,
1525* UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS
46f4442e 1526* @param symbolIndex The desired symbol of type type.
b75a7d8f
A
1527* @param result A pointer to a buffer to receive the pattern.
1528* @param resultLength The maximum size of result.
1529* @param status A pointer to an UErrorCode to receive any errors
1530* @return The total buffer size needed; if greater than resultLength, the output was truncated.
1531* @see udat_countSymbols
1532* @see udat_setSymbols
1533* @stable ICU 2.0
1534*/
f3c0d7a5 1535U_CAPI int32_t U_EXPORT2
b75a7d8f
A
1536udat_getSymbols(const UDateFormat *fmt,
1537 UDateFormatSymbolType type,
46f4442e 1538 int32_t symbolIndex,
b75a7d8f
A
1539 UChar *result,
1540 int32_t resultLength,
1541 UErrorCode *status);
1542
1543/**
1544* Count the number of particular symbols for an UDateFormat.
1545* This function is most useful as for detemining the loop termination condition
374ca955 1546* for calls to {@link #udat_getSymbols }.
b75a7d8f
A
1547* @param fmt The formatter to query.
1548* @param type The type of symbols to count. One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,
1549* UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS
1550* @return The number of symbols of type type.
1551* @see udat_getSymbols
1552* @see udat_setSymbols
1553* @stable ICU 2.0
1554*/
f3c0d7a5 1555U_CAPI int32_t U_EXPORT2
b75a7d8f
A
1556udat_countSymbols( const UDateFormat *fmt,
1557 UDateFormatSymbolType type);
1558
1559/**
1560* Set the symbols associated with an UDateFormat.
1561* The symbols are what a UDateFormat uses to represent locale-specific data,
1562* for example month or day names.
1563* @param format The formatter to set
1564* @param type The type of symbols to set. One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,
1565* UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS
46f4442e 1566* @param symbolIndex The index of the symbol to set of type type.
b75a7d8f
A
1567* @param value The new value
1568* @param valueLength The length of value, or -1 if null-terminated
1569* @param status A pointer to an UErrorCode to receive any errors
1570* @see udat_getSymbols
1571* @see udat_countSymbols
1572* @stable ICU 2.0
1573*/
f3c0d7a5 1574U_CAPI void U_EXPORT2
b75a7d8f
A
1575udat_setSymbols( UDateFormat *format,
1576 UDateFormatSymbolType type,
46f4442e 1577 int32_t symbolIndex,
b75a7d8f
A
1578 UChar *value,
1579 int32_t valueLength,
1580 UErrorCode *status);
1581
b75a7d8f 1582/**
374ca955
A
1583 * Get the locale for this date format object.
1584 * You can choose between valid and actual locale.
1585 * @param fmt The formatter to get the locale from
2ca993e8 1586 * @param type type of the locale we're looking for (valid or actual)
374ca955
A
1587 * @param status error code for the operation
1588 * @return the locale name
73c04bcf 1589 * @stable ICU 2.8
b75a7d8f 1590 */
f3c0d7a5 1591U_CAPI const char* U_EXPORT2
374ca955
A
1592udat_getLocaleByType(const UDateFormat *fmt,
1593 ULocDataLocaleType type,
2ca993e8 1594 UErrorCode* status);
b75a7d8f 1595
4388f060 1596/**
51004dcb
A
1597 * Set a particular UDisplayContext value in the formatter, such as
1598 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
1599 * @param fmt The formatter for which to set a UDisplayContext value.
1600 * @param value The UDisplayContext value to set.
4388f060 1601 * @param status A pointer to an UErrorCode to receive any errors
57a6839d 1602 * @stable ICU 51
4388f060 1603 */
f3c0d7a5 1604U_CAPI void U_EXPORT2
51004dcb 1605udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status);
4388f060
A
1606
1607/**
51004dcb
A
1608 * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
1609 * such as UDISPCTX_TYPE_CAPITALIZATION.
1610 * @param fmt The formatter to query.
1611 * @param type The UDisplayContextType whose value to return
4388f060 1612 * @param status A pointer to an UErrorCode to receive any errors
51004dcb 1613 * @return The UDisplayContextValue for the specified type.
b331163b 1614 * @stable ICU 53
4388f060 1615 */
f3c0d7a5 1616U_CAPI UDisplayContext U_EXPORT2
57a6839d 1617udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* status);
51004dcb 1618
4388f060 1619#ifndef U_HIDE_INTERNAL_API
46f4442e
A
1620/**
1621* Extract the date pattern from a UDateFormat set for relative date formatting.
1622* The pattern will follow the pattern syntax rules.
1623* @param fmt The formatter to query.
1624* @param result A pointer to a buffer to receive the pattern.
1625* @param resultLength The maximum size of result.
1626* @param status A pointer to a UErrorCode to receive any errors
1627* @return The total buffer size needed; if greater than resultLength, the output was truncated.
1628* @see udat_applyPatternRelative
1629* @internal ICU 4.2 technology preview
1630*/
2ca993e8 1631U_INTERNAL int32_t U_EXPORT2
46f4442e
A
1632udat_toPatternRelativeDate(const UDateFormat *fmt,
1633 UChar *result,
1634 int32_t resultLength,
1635 UErrorCode *status);
1636
1637/**
1638* Extract the time pattern from a UDateFormat set for relative date formatting.
1639* The pattern will follow the pattern syntax rules.
1640* @param fmt The formatter to query.
1641* @param result A pointer to a buffer to receive the pattern.
1642* @param resultLength The maximum size of result.
1643* @param status A pointer to a UErrorCode to receive any errors
1644* @return The total buffer size needed; if greater than resultLength, the output was truncated.
1645* @see udat_applyPatternRelative
1646* @internal ICU 4.2 technology preview
1647*/
2ca993e8 1648U_INTERNAL int32_t U_EXPORT2
46f4442e
A
1649udat_toPatternRelativeTime(const UDateFormat *fmt,
1650 UChar *result,
1651 int32_t resultLength,
1652 UErrorCode *status);
1653
1654/**
1655* Set the date & time patterns used by a UDateFormat set for relative date formatting.
1656* The patterns should follow the pattern syntax rules.
1657* @param format The formatter to set.
1658* @param datePattern The new date pattern
1659* @param datePatternLength The length of datePattern, or -1 if null-terminated.
1660* @param timePattern The new time pattern
1661* @param timePatternLength The length of timePattern, or -1 if null-terminated.
1662* @param status A pointer to a UErrorCode to receive any errors
1663* @see udat_toPatternRelativeDate, udat_toPatternRelativeTime
1664* @internal ICU 4.2 technology preview
1665*/
2ca993e8 1666U_INTERNAL void U_EXPORT2
46f4442e
A
1667udat_applyPatternRelative(UDateFormat *format,
1668 const UChar *datePattern,
1669 int32_t datePatternLength,
1670 const UChar *timePattern,
1671 int32_t timePatternLength,
1672 UErrorCode *status);
4388f060
A
1673
1674/**
1675 * @internal
1676 * @see udat_open
1677 */
1678typedef UDateFormat* (U_EXPORT2 *UDateFormatOpener) (UDateFormatStyle timeStyle,
1679 UDateFormatStyle dateStyle,
1680 const char *locale,
1681 const UChar *tzID,
1682 int32_t tzIDLength,
1683 const UChar *pattern,
1684 int32_t patternLength,
1685 UErrorCode *status);
1686
1687/**
1688 * Register a provider factory
1689 * @internal ICU 49
1690 */
1691U_INTERNAL void U_EXPORT2
1692udat_registerOpener(UDateFormatOpener opener, UErrorCode *status);
1693
1694/**
1695 * Un-Register a provider factory
1696 * @internal ICU 49
1697 */
1698U_INTERNAL UDateFormatOpener U_EXPORT2
1699udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status);
51004dcb 1700#endif /* U_HIDE_INTERNAL_API */
46f4442e 1701
729e4ab9 1702
b75a7d8f
A
1703#endif /* #if !UCONFIG_NO_FORMATTING */
1704
1705#endif