udatpg.h 24 KB

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