annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/udat.h @ 69:33d812a61356

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