udatpg.h 24 KB

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