| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 ******************************************************************************* | |
| 3 * | |
| 4 * Copyright (C) 2007-2010, International Business Machines | |
| 5 * Corporation and others. All Rights Reserved. | |
| 6 * | |
| 7 ******************************************************************************* | |
| 8 * file name: udatpg.h | |
| 9 * encoding: US-ASCII | |
| 10 * tab size: 8 (not used) | |
| 11 * indentation:4 | |
| 12 * | |
| 13 * created on: 2007jul30 | |
| 14 * created by: Markus W. Scherer | |
| 15 */ | |
| 16 | |
| 17 #ifndef __UDATPG_H__ | |
| 18 #define __UDATPG_H__ | |
| 19 | |
| 20 #include "unicode/utypes.h" | |
| 21 #include "unicode/uenum.h" | |
| 22 #include "unicode/localpointer.h" | |
| 23 | |
| 24 /** | |
| 25 * \file | |
| 26 * \brief C API: Wrapper for DateTimePatternGenerator (unicode/dtptngen.h). | |
| 27 * | |
| 28 * UDateTimePatternGenerator provides flexible generation of date format pattern
s, | |
| 29 * like "yy-MM-dd". The user can build up the generator by adding successive | |
| 30 * patterns. Once that is done, a query can be made using a "skeleton", which is
| |
| 31 * a pattern which just includes the desired fields and lengths. The generator | |
| 32 * will return the "best fit" pattern corresponding to that skeleton. | |
| 33 * <p>The main method people will use is udatpg_getBestPattern, since normally | |
| 34 * UDateTimePatternGenerator is pre-built with data from a particular locale. | |
| 35 * However, generators can be built directly from other data as well. | |
| 36 * <p><i>Issue: may be useful to also have a function that returns the list of | |
| 37 * fields in a pattern, in order, since we have that internally. | |
| 38 * That would be useful for getting the UI order of field elements.</i> | |
| 39 */ | |
| 40 | |
| 41 /** | |
| 42 * Opaque type for a date/time pattern generator object. | |
| 43 * @stable ICU 3.8 | |
| 44 */ | |
| 45 typedef void *UDateTimePatternGenerator; | |
| 46 | |
| 47 /** | |
| 48 * Field number constants for udatpg_getAppendItemFormats() and similar function
s. | |
| 49 * These constants are separate from UDateFormatField despite semantic overlap | |
| 50 * because some fields are merged for the date/time pattern generator. | |
| 51 * @stable ICU 3.8 | |
| 52 */ | |
| 53 typedef enum UDateTimePatternField { | |
| 54 /** @stable ICU 3.8 */ | |
| 55 UDATPG_ERA_FIELD, | |
| 56 /** @stable ICU 3.8 */ | |
| 57 UDATPG_YEAR_FIELD, | |
| 58 /** @stable ICU 3.8 */ | |
| 59 UDATPG_QUARTER_FIELD, | |
| 60 /** @stable ICU 3.8 */ | |
| 61 UDATPG_MONTH_FIELD, | |
| 62 /** @stable ICU 3.8 */ | |
| 63 UDATPG_WEEK_OF_YEAR_FIELD, | |
| 64 /** @stable ICU 3.8 */ | |
| 65 UDATPG_WEEK_OF_MONTH_FIELD, | |
| 66 /** @stable ICU 3.8 */ | |
| 67 UDATPG_WEEKDAY_FIELD, | |
| 68 /** @stable ICU 3.8 */ | |
| 69 UDATPG_DAY_OF_YEAR_FIELD, | |
| 70 /** @stable ICU 3.8 */ | |
| 71 UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD, | |
| 72 /** @stable ICU 3.8 */ | |
| 73 UDATPG_DAY_FIELD, | |
| 74 /** @stable ICU 3.8 */ | |
| 75 UDATPG_DAYPERIOD_FIELD, | |
| 76 /** @stable ICU 3.8 */ | |
| 77 UDATPG_HOUR_FIELD, | |
| 78 /** @stable ICU 3.8 */ | |
| 79 UDATPG_MINUTE_FIELD, | |
| 80 /** @stable ICU 3.8 */ | |
| 81 UDATPG_SECOND_FIELD, | |
| 82 /** @stable ICU 3.8 */ | |
| 83 UDATPG_FRACTIONAL_SECOND_FIELD, | |
| 84 /** @stable ICU 3.8 */ | |
| 85 UDATPG_ZONE_FIELD, | |
| 86 /** @stable ICU 3.8 */ | |
| 87 UDATPG_FIELD_COUNT | |
| 88 } UDateTimePatternField; | |
| 89 | |
| 90 /** | |
| 91 * Masks to control forcing the length of specified fields in the returned | |
| 92 * pattern to match those in the skeleton (when this would not happen | |
| 93 * otherwise). These may be combined to force the length of multiple fields. | |
| 94 * Used with udatpg_getBestPatternWithOptions, udatpg_replaceFieldTypesWithOptio
ns. | |
| 95 * @stable ICU 4.4 | |
| 96 */ | |
| 97 typedef enum UDateTimePatternMatchOptions { | |
| 98 /** @stable ICU 4.4 */ | |
| 99 UDATPG_MATCH_NO_OPTIONS = 0, | |
| 100 /** @stable ICU 4.4 */ | |
| 101 UDATPG_MATCH_HOUR_FIELD_LENGTH = 1 << UDATPG_HOUR_FIELD, | |
| 102 /** @internal ICU 4.4 */ | |
| 103 UDATPG_MATCH_MINUTE_FIELD_LENGTH = 1 << UDATPG_MINUTE_FIELD, | |
| 104 /** @internal ICU 4.4 */ | |
| 105 UDATPG_MATCH_SECOND_FIELD_LENGTH = 1 << UDATPG_SECOND_FIELD, | |
| 106 /** @stable ICU 4.4 */ | |
| 107 UDATPG_MATCH_ALL_FIELDS_LENGTH = (1 << UDATPG_FIELD_COUNT) - 1 | |
| 108 } UDateTimePatternMatchOptions; | |
| 109 | |
| 110 /** | |
| 111 * Status return values from udatpg_addPattern(). | |
| 112 * @stable ICU 3.8 | |
| 113 */ | |
| 114 typedef enum UDateTimePatternConflict { | |
| 115 /** @stable ICU 3.8 */ | |
| 116 UDATPG_NO_CONFLICT, | |
| 117 /** @stable ICU 3.8 */ | |
| 118 UDATPG_BASE_CONFLICT, | |
| 119 /** @stable ICU 3.8 */ | |
| 120 UDATPG_CONFLICT, | |
| 121 /** @stable ICU 3.8 */ | |
| 122 UDATPG_CONFLICT_COUNT | |
| 123 } UDateTimePatternConflict; | |
| 124 | |
| 125 /** | |
| 126 * Open a generator according to a given locale. | |
| 127 * @param locale | |
| 128 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 129 * failure before the function call. | |
| 130 * @return a pointer to UDateTimePatternGenerator. | |
| 131 * @stable ICU 3.8 | |
| 132 */ | |
| 133 U_STABLE UDateTimePatternGenerator * U_EXPORT2 | |
| 134 udatpg_open(const char *locale, UErrorCode *pErrorCode); | |
| 135 | |
| 136 /** | |
| 137 * Open an empty generator, to be constructed with udatpg_addPattern(...) etc. | |
| 138 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 139 * failure before the function call. | |
| 140 * @return a pointer to UDateTimePatternGenerator. | |
| 141 * @stable ICU 3.8 | |
| 142 */ | |
| 143 U_STABLE UDateTimePatternGenerator * U_EXPORT2 | |
| 144 udatpg_openEmpty(UErrorCode *pErrorCode); | |
| 145 | |
| 146 /** | |
| 147 * Close a generator. | |
| 148 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 149 * @stable ICU 3.8 | |
| 150 */ | |
| 151 U_STABLE void U_EXPORT2 | |
| 152 udatpg_close(UDateTimePatternGenerator *dtpg); | |
| 153 | |
| 154 #if U_SHOW_CPLUSPLUS_API | |
| 155 | |
| 156 U_NAMESPACE_BEGIN | |
| 157 | |
| 158 /** | |
| 159 * \class LocalUDateTimePatternGeneratorPointer | |
| 160 * "Smart pointer" class, closes a UDateTimePatternGenerator via udatpg_close(). | |
| 161 * For most methods see the LocalPointerBase base class. | |
| 162 * | |
| 163 * @see LocalPointerBase | |
| 164 * @see LocalPointer | |
| 165 * @stable ICU 4.4 | |
| 166 */ | |
| 167 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateTimePatternGeneratorPointer, UDateTimePatt
ernGenerator, udatpg_close); | |
| 168 | |
| 169 U_NAMESPACE_END | |
| 170 | |
| 171 #endif | |
| 172 | |
| 173 /** | |
| 174 * Create a copy pf a generator. | |
| 175 * @param dtpg a pointer to UDateTimePatternGenerator to be copied. | |
| 176 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 177 * failure before the function call. | |
| 178 * @return a pointer to a new UDateTimePatternGenerator. | |
| 179 * @stable ICU 3.8 | |
| 180 */ | |
| 181 U_STABLE UDateTimePatternGenerator * U_EXPORT2 | |
| 182 udatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode); | |
| 183 | |
| 184 /** | |
| 185 * Get the best pattern matching the input skeleton. It is guaranteed to | |
| 186 * have all of the fields in the skeleton. | |
| 187 * | |
| 188 * Note that this function uses a non-const UDateTimePatternGenerator: | |
| 189 * It uses a stateful pattern parser which is set up for each generator object, | |
| 190 * rather than creating one for each function call. | |
| 191 * Consecutive calls to this function do not affect each other, | |
| 192 * but this function cannot be used concurrently on a single generator object. | |
| 193 * | |
| 194 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 195 * @param skeleton | |
| 196 * The skeleton is a pattern containing only the variable fields. | |
| 197 * For example, "MMMdd" and "mmhh" are skeletons. | |
| 198 * @param length the length of skeleton | |
| 199 * @param bestPattern | |
| 200 * The best pattern found from the given skeleton. | |
| 201 * @param capacity the capacity of bestPattern. | |
| 202 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 203 * failure before the function call. | |
| 204 * @return the length of bestPattern. | |
| 205 * @stable ICU 3.8 | |
| 206 */ | |
| 207 U_STABLE int32_t U_EXPORT2 | |
| 208 udatpg_getBestPattern(UDateTimePatternGenerator *dtpg, | |
| 209 const UChar *skeleton, int32_t length, | |
| 210 UChar *bestPattern, int32_t capacity, | |
| 211 UErrorCode *pErrorCode); | |
| 212 | |
| 213 /** | |
| 214 * Get the best pattern matching the input skeleton. It is guaranteed to | |
| 215 * have all of the fields in the skeleton. | |
| 216 * | |
| 217 * Note that this function uses a non-const UDateTimePatternGenerator: | |
| 218 * It uses a stateful pattern parser which is set up for each generator object, | |
| 219 * rather than creating one for each function call. | |
| 220 * Consecutive calls to this function do not affect each other, | |
| 221 * but this function cannot be used concurrently on a single generator object. | |
| 222 * | |
| 223 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 224 * @param skeleton | |
| 225 * The skeleton is a pattern containing only the variable fields. | |
| 226 * For example, "MMMdd" and "mmhh" are skeletons. | |
| 227 * @param length the length of skeleton | |
| 228 * @param options | |
| 229 * Options for forcing the length of specified fields in the | |
| 230 * returned pattern to match those in the skeleton (when this | |
| 231 * would not happen otherwise). For default behavior, use | |
| 232 * UDATPG_MATCH_NO_OPTIONS. | |
| 233 * @param bestPattern | |
| 234 * The best pattern found from the given skeleton. | |
| 235 * @param capacity | |
| 236 * the capacity of bestPattern. | |
| 237 * @param pErrorCode | |
| 238 * a pointer to the UErrorCode which must not indicate a | |
| 239 * failure before the function call. | |
| 240 * @return the length of bestPattern. | |
| 241 * @stable ICU 4.4 | |
| 242 */ | |
| 243 U_STABLE int32_t U_EXPORT2 | |
| 244 udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg, | |
| 245 const UChar *skeleton, int32_t length, | |
| 246 UDateTimePatternMatchOptions options, | |
| 247 UChar *bestPattern, int32_t capacity, | |
| 248 UErrorCode *pErrorCode); | |
| 249 | |
| 250 /** | |
| 251 * Get a unique skeleton from a given pattern. For example, | |
| 252 * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". | |
| 253 * | |
| 254 * Note that this function uses a non-const UDateTimePatternGenerator: | |
| 255 * It uses a stateful pattern parser which is set up for each generator object, | |
| 256 * rather than creating one for each function call. | |
| 257 * Consecutive calls to this function do not affect each other, | |
| 258 * but this function cannot be used concurrently on a single generator object. | |
| 259 * | |
| 260 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 261 * @param pattern input pattern, such as "dd/MMM". | |
| 262 * @param length the length of pattern. | |
| 263 * @param skeleton such as "MMMdd" | |
| 264 * @param capacity the capacity of skeleton. | |
| 265 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 266 * failure before the function call. | |
| 267 * @return the length of skeleton. | |
| 268 * @stable ICU 3.8 | |
| 269 */ | |
| 270 U_STABLE int32_t U_EXPORT2 | |
| 271 udatpg_getSkeleton(UDateTimePatternGenerator *dtpg, | |
| 272 const UChar *pattern, int32_t length, | |
| 273 UChar *skeleton, int32_t capacity, | |
| 274 UErrorCode *pErrorCode); | |
| 275 | |
| 276 /** | |
| 277 * Get a unique base skeleton from a given pattern. This is the same | |
| 278 * as the skeleton, except that differences in length are minimized so | |
| 279 * as to only preserve the difference between string and numeric form. So | |
| 280 * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" | |
| 281 * (notice the single d). | |
| 282 * | |
| 283 * Note that this function uses a non-const UDateTimePatternGenerator: | |
| 284 * It uses a stateful pattern parser which is set up for each generator object, | |
| 285 * rather than creating one for each function call. | |
| 286 * Consecutive calls to this function do not affect each other, | |
| 287 * but this function cannot be used concurrently on a single generator object. | |
| 288 * | |
| 289 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 290 * @param pattern input pattern, such as "dd/MMM". | |
| 291 * @param length the length of pattern. | |
| 292 * @param baseSkeleton such as "Md" | |
| 293 * @param capacity the capacity of base skeleton. | |
| 294 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 295 * failure before the function call. | |
| 296 * @return the length of baseSkeleton. | |
| 297 * @stable ICU 3.8 | |
| 298 */ | |
| 299 U_STABLE int32_t U_EXPORT2 | |
| 300 udatpg_getBaseSkeleton(UDateTimePatternGenerator *dtpg, | |
| 301 const UChar *pattern, int32_t length, | |
| 302 UChar *baseSkeleton, int32_t capacity, | |
| 303 UErrorCode *pErrorCode); | |
| 304 | |
| 305 /** | |
| 306 * Adds a pattern to the generator. If the pattern has the same skeleton as | |
| 307 * an existing pattern, and the override parameter is set, then the previous | |
| 308 * value is overriden. Otherwise, the previous value is retained. In either | |
| 309 * case, the conflicting status is set and previous vale is stored in | |
| 310 * conflicting pattern. | |
| 311 * <p> | |
| 312 * Note that single-field patterns (like "MMM") are automatically added, and | |
| 313 * don't need to be added explicitly! | |
| 314 * | |
| 315 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 316 * @param pattern input pattern, such as "dd/MMM" | |
| 317 * @param patternLength the length of pattern. | |
| 318 * @param override When existing values are to be overridden use true, | |
| 319 * otherwise use false. | |
| 320 * @param conflictingPattern Previous pattern with the same skeleton. | |
| 321 * @param capacity the capacity of conflictingPattern. | |
| 322 * @param pLength a pointer to the length of conflictingPattern. | |
| 323 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 324 * failure before the function call. | |
| 325 * @return conflicting status. The value could be UDATPG_NO_CONFLICT, | |
| 326 * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT. | |
| 327 * @stable ICU 3.8 | |
| 328 */ | |
| 329 U_STABLE UDateTimePatternConflict U_EXPORT2 | |
| 330 udatpg_addPattern(UDateTimePatternGenerator *dtpg, | |
| 331 const UChar *pattern, int32_t patternLength, | |
| 332 UBool override, | |
| 333 UChar *conflictingPattern, int32_t capacity, int32_t *pLength, | |
| 334 UErrorCode *pErrorCode); | |
| 335 | |
| 336 /** | |
| 337 * An AppendItem format is a pattern used to append a field if there is no | |
| 338 * good match. For example, suppose that the input skeleton is "GyyyyMMMd", | |
| 339 * and there is no matching pattern internally, but there is a pattern | |
| 340 * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the | |
| 341 * G. The way these two are conjoined is by using the AppendItemFormat for G | |
| 342 * (era). So if that value is, say "{0}, {1}" then the final resulting | |
| 343 * pattern is "d-MM-yyyy, G". | |
| 344 * <p> | |
| 345 * There are actually three available variables: {0} is the pattern so far, | |
| 346 * {1} is the element we are adding, and {2} is the name of the element. | |
| 347 * <p> | |
| 348 * This reflects the way that the CLDR data is organized. | |
| 349 * | |
| 350 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 351 * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD | |
| 352 * @param value pattern, such as "{0}, {1}" | |
| 353 * @param length the length of value. | |
| 354 * @stable ICU 3.8 | |
| 355 */ | |
| 356 U_STABLE void U_EXPORT2 | |
| 357 udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg, | |
| 358 UDateTimePatternField field, | |
| 359 const UChar *value, int32_t length); | |
| 360 | |
| 361 /** | |
| 362 * Getter corresponding to setAppendItemFormat. Values below 0 or at or | |
| 363 * above UDATPG_FIELD_COUNT are illegal arguments. | |
| 364 * | |
| 365 * @param dtpg A pointer to UDateTimePatternGenerator. | |
| 366 * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD | |
| 367 * @param pLength A pointer that will receive the length of appendItemFormat. | |
| 368 * @return appendItemFormat for field. | |
| 369 * @stable ICU 3.8 | |
| 370 */ | |
| 371 U_STABLE const UChar * U_EXPORT2 | |
| 372 udatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg, | |
| 373 UDateTimePatternField field, | |
| 374 int32_t *pLength); | |
| 375 | |
| 376 /** | |
| 377 * Set the name of field, eg "era" in English for ERA. These are only | |
| 378 * used if the corresponding AppendItemFormat is used, and if it contains a | |
| 379 * {2} variable. | |
| 380 * <p> | |
| 381 * This reflects the way that the CLDR data is organized. | |
| 382 * | |
| 383 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 384 * @param field UDateTimePatternField | |
| 385 * @param value name for the field. | |
| 386 * @param length the length of value. | |
| 387 * @stable ICU 3.8 | |
| 388 */ | |
| 389 U_STABLE void U_EXPORT2 | |
| 390 udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg, | |
| 391 UDateTimePatternField field, | |
| 392 const UChar *value, int32_t length); | |
| 393 | |
| 394 /** | |
| 395 * Getter corresponding to setAppendItemNames. Values below 0 or at or above | |
| 396 * UDATPG_FIELD_COUNT are illegal arguments. | |
| 397 * | |
| 398 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 399 * @param field UDateTimePatternField, such as UDATPG_ERA_FIELD | |
| 400 * @param pLength A pointer that will receive the length of the name for field. | |
| 401 * @return name for field | |
| 402 * @stable ICU 3.8 | |
| 403 */ | |
| 404 U_STABLE const UChar * U_EXPORT2 | |
| 405 udatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg, | |
| 406 UDateTimePatternField field, | |
| 407 int32_t *pLength); | |
| 408 | |
| 409 /** | |
| 410 * The date time format is a message format pattern used to compose date and | |
| 411 * time patterns. The default value is "{0} {1}", where {0} will be replaced | |
| 412 * by the date pattern and {1} will be replaced by the time pattern. | |
| 413 * <p> | |
| 414 * This is used when the input skeleton contains both date and time fields, | |
| 415 * but there is not a close match among the added patterns. For example, | |
| 416 * suppose that this object was created by adding "dd-MMM" and "hh:mm", and | |
| 417 * its datetimeFormat is the default "{0} {1}". Then if the input skeleton | |
| 418 * is "MMMdhmm", there is not an exact match, so the input skeleton is | |
| 419 * broken up into two components "MMMd" and "hmm". There are close matches | |
| 420 * for those two skeletons, so the result is put together with this pattern, | |
| 421 * resulting in "d-MMM h:mm". | |
| 422 * | |
| 423 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 424 * @param dtFormat | |
| 425 * message format pattern, here {0} will be replaced by the date | |
| 426 * pattern and {1} will be replaced by the time pattern. | |
| 427 * @param length the length of dtFormat. | |
| 428 * @stable ICU 3.8 | |
| 429 */ | |
| 430 U_STABLE void U_EXPORT2 | |
| 431 udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg, | |
| 432 const UChar *dtFormat, int32_t length); | |
| 433 | |
| 434 /** | |
| 435 * Getter corresponding to setDateTimeFormat. | |
| 436 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 437 * @param pLength A pointer that will receive the length of the format | |
| 438 * @return dateTimeFormat. | |
| 439 * @stable ICU 3.8 | |
| 440 */ | |
| 441 U_STABLE const UChar * U_EXPORT2 | |
| 442 udatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg, | |
| 443 int32_t *pLength); | |
| 444 | |
| 445 /** | |
| 446 * The decimal value is used in formatting fractions of seconds. If the | |
| 447 * skeleton contains fractional seconds, then this is used with the | |
| 448 * fractional seconds. For example, suppose that the input pattern is | |
| 449 * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and | |
| 450 * the decimal string is ",". Then the resulting pattern is modified to be | |
| 451 * "H:mm:ss,SSSS" | |
| 452 * | |
| 453 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 454 * @param decimal | |
| 455 * @param length the length of decimal. | |
| 456 * @stable ICU 3.8 | |
| 457 */ | |
| 458 U_STABLE void U_EXPORT2 | |
| 459 udatpg_setDecimal(UDateTimePatternGenerator *dtpg, | |
| 460 const UChar *decimal, int32_t length); | |
| 461 | |
| 462 /** | |
| 463 * Getter corresponding to setDecimal. | |
| 464 * | |
| 465 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 466 * @param pLength A pointer that will receive the length of the decimal string. | |
| 467 * @return corresponding to the decimal point. | |
| 468 * @stable ICU 3.8 | |
| 469 */ | |
| 470 U_STABLE const UChar * U_EXPORT2 | |
| 471 udatpg_getDecimal(const UDateTimePatternGenerator *dtpg, | |
| 472 int32_t *pLength); | |
| 473 | |
| 474 /** | |
| 475 * Adjusts the field types (width and subtype) of a pattern to match what is | |
| 476 * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a | |
| 477 * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be | |
| 478 * "dd-MMMM hh:mm". This is used internally to get the best match for the | |
| 479 * input skeleton, but can also be used externally. | |
| 480 * | |
| 481 * Note that this function uses a non-const UDateTimePatternGenerator: | |
| 482 * It uses a stateful pattern parser which is set up for each generator object, | |
| 483 * rather than creating one for each function call. | |
| 484 * Consecutive calls to this function do not affect each other, | |
| 485 * but this function cannot be used concurrently on a single generator object. | |
| 486 * | |
| 487 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 488 * @param pattern Input pattern | |
| 489 * @param patternLength the length of input pattern. | |
| 490 * @param skeleton | |
| 491 * @param skeletonLength the length of input skeleton. | |
| 492 * @param dest pattern adjusted to match the skeleton fields widths and subtype
s. | |
| 493 * @param destCapacity the capacity of dest. | |
| 494 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 495 * failure before the function call. | |
| 496 * @return the length of dest. | |
| 497 * @stable ICU 3.8 | |
| 498 */ | |
| 499 U_STABLE int32_t U_EXPORT2 | |
| 500 udatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg, | |
| 501 const UChar *pattern, int32_t patternLength, | |
| 502 const UChar *skeleton, int32_t skeletonLength, | |
| 503 UChar *dest, int32_t destCapacity, | |
| 504 UErrorCode *pErrorCode); | |
| 505 | |
| 506 /** | |
| 507 * Adjusts the field types (width and subtype) of a pattern to match what is | |
| 508 * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a | |
| 509 * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be | |
| 510 * "dd-MMMM hh:mm". This is used internally to get the best match for the | |
| 511 * input skeleton, but can also be used externally. | |
| 512 * | |
| 513 * Note that this function uses a non-const UDateTimePatternGenerator: | |
| 514 * It uses a stateful pattern parser which is set up for each generator object, | |
| 515 * rather than creating one for each function call. | |
| 516 * Consecutive calls to this function do not affect each other, | |
| 517 * but this function cannot be used concurrently on a single generator object. | |
| 518 * | |
| 519 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 520 * @param pattern Input pattern | |
| 521 * @param patternLength the length of input pattern. | |
| 522 * @param skeleton | |
| 523 * @param skeletonLength the length of input skeleton. | |
| 524 * @param options | |
| 525 * Options controlling whether the length of specified fields in the | |
| 526 * pattern are adjusted to match those in the skeleton (when this | |
| 527 * would not happen otherwise). For default behavior, use | |
| 528 * UDATPG_MATCH_NO_OPTIONS. | |
| 529 * @param dest pattern adjusted to match the skeleton fields widths and subtype
s. | |
| 530 * @param destCapacity the capacity of dest. | |
| 531 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 532 * failure before the function call. | |
| 533 * @return the length of dest. | |
| 534 * @stable ICU 4.4 | |
| 535 */ | |
| 536 U_STABLE int32_t U_EXPORT2 | |
| 537 udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg, | |
| 538 const UChar *pattern, int32_t patternLength, | |
| 539 const UChar *skeleton, int32_t skeletonLengt
h, | |
| 540 UDateTimePatternMatchOptions options, | |
| 541 UChar *dest, int32_t destCapacity, | |
| 542 UErrorCode *pErrorCode); | |
| 543 | |
| 544 /** | |
| 545 * Return a UEnumeration list of all the skeletons in canonical form. | |
| 546 * Call udatpg_getPatternForSkeleton() to get the corresponding pattern. | |
| 547 * | |
| 548 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 549 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 550 * failure before the function call | |
| 551 * @return a UEnumeration list of all the skeletons | |
| 552 * The caller must close the object. | |
| 553 * @stable ICU 3.8 | |
| 554 */ | |
| 555 U_STABLE UEnumeration * U_EXPORT2 | |
| 556 udatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCo
de); | |
| 557 | |
| 558 /** | |
| 559 * Return a UEnumeration list of all the base skeletons in canonical form. | |
| 560 * | |
| 561 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 562 * @param pErrorCode a pointer to the UErrorCode which must not indicate a | |
| 563 * failure before the function call. | |
| 564 * @return a UEnumeration list of all the base skeletons | |
| 565 * The caller must close the object. | |
| 566 * @stable ICU 3.8 | |
| 567 */ | |
| 568 U_STABLE UEnumeration * U_EXPORT2 | |
| 569 udatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErr
orCode); | |
| 570 | |
| 571 /** | |
| 572 * Get the pattern corresponding to a given skeleton. | |
| 573 * | |
| 574 * @param dtpg a pointer to UDateTimePatternGenerator. | |
| 575 * @param skeleton | |
| 576 * @param skeletonLength pointer to the length of skeleton. | |
| 577 * @param pLength pointer to the length of return pattern. | |
| 578 * @return pattern corresponding to a given skeleton. | |
| 579 * @stable ICU 3.8 | |
| 580 */ | |
| 581 U_STABLE const UChar * U_EXPORT2 | |
| 582 udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg, | |
| 583 const UChar *skeleton, int32_t skeletonLength, | |
| 584 int32_t *pLength); | |
| 585 | |
| 586 #endif | |
| OLD | NEW |