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