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