dtitvfmt.h 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /********************************************************************************
  4. * Copyright (C) 2008-2016, International Business Machines Corporation and
  5. * others. All Rights Reserved.
  6. *******************************************************************************
  7. *
  8. * File DTITVFMT.H
  9. *
  10. *******************************************************************************
  11. */
  12. #ifndef __DTITVFMT_H__
  13. #define __DTITVFMT_H__
  14. #include "unicode/utypes.h"
  15. #if U_SHOW_CPLUSPLUS_API
  16. /**
  17. * \file
  18. * \brief C++ API: Format and parse date interval in a language-independent manner.
  19. */
  20. #if !UCONFIG_NO_FORMATTING
  21. #include "unicode/ucal.h"
  22. #include "unicode/smpdtfmt.h"
  23. #include "unicode/dtintrv.h"
  24. #include "unicode/dtitvinf.h"
  25. #include "unicode/dtptngen.h"
  26. #include "unicode/formattedvalue.h"
  27. #include "unicode/udisplaycontext.h"
  28. U_NAMESPACE_BEGIN
  29. class FormattedDateIntervalData;
  30. class DateIntervalFormat;
  31. /**
  32. * An immutable class containing the result of a date interval formatting operation.
  33. *
  34. * Instances of this class are immutable and thread-safe.
  35. *
  36. * When calling nextPosition():
  37. * The fields are returned from left to right. The special field category
  38. * UFIELD_CATEGORY_DATE_INTERVAL_SPAN is used to indicate which datetime
  39. * primitives came from which arguments: 0 means fromCalendar, and 1 means
  40. * toCalendar. The span category will always occur before the
  41. * corresponding fields in UFIELD_CATEGORY_DATE
  42. * in the nextPosition() iterator.
  43. *
  44. * Not intended for public subclassing.
  45. *
  46. * @stable ICU 64
  47. */
  48. class U_I18N_API FormattedDateInterval : public UMemory, public FormattedValue {
  49. public:
  50. /**
  51. * Default constructor; makes an empty FormattedDateInterval.
  52. * @stable ICU 64
  53. */
  54. FormattedDateInterval() : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {}
  55. /**
  56. * Move constructor: Leaves the source FormattedDateInterval in an undefined state.
  57. * @stable ICU 64
  58. */
  59. FormattedDateInterval(FormattedDateInterval&& src) noexcept;
  60. /**
  61. * Destruct an instance of FormattedDateInterval.
  62. * @stable ICU 64
  63. */
  64. virtual ~FormattedDateInterval() override;
  65. /** Copying not supported; use move constructor instead. */
  66. FormattedDateInterval(const FormattedDateInterval&) = delete;
  67. /** Copying not supported; use move assignment instead. */
  68. FormattedDateInterval& operator=(const FormattedDateInterval&) = delete;
  69. /**
  70. * Move assignment: Leaves the source FormattedDateInterval in an undefined state.
  71. * @stable ICU 64
  72. */
  73. FormattedDateInterval& operator=(FormattedDateInterval&& src) noexcept;
  74. /** @copydoc FormattedValue::toString() */
  75. UnicodeString toString(UErrorCode& status) const override;
  76. /** @copydoc FormattedValue::toTempString() */
  77. UnicodeString toTempString(UErrorCode& status) const override;
  78. /** @copydoc FormattedValue::appendTo() */
  79. Appendable &appendTo(Appendable& appendable, UErrorCode& status) const override;
  80. /** @copydoc FormattedValue::nextPosition() */
  81. UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const override;
  82. private:
  83. FormattedDateIntervalData *fData;
  84. UErrorCode fErrorCode;
  85. explicit FormattedDateInterval(FormattedDateIntervalData *results)
  86. : fData(results), fErrorCode(U_ZERO_ERROR) {}
  87. explicit FormattedDateInterval(UErrorCode errorCode)
  88. : fData(nullptr), fErrorCode(errorCode) {}
  89. friend class DateIntervalFormat;
  90. };
  91. /**
  92. * DateIntervalFormat is a class for formatting and parsing date
  93. * intervals in a language-independent manner.
  94. * Only formatting is supported, parsing is not supported.
  95. *
  96. * <P>
  97. * Date interval means from one date to another date,
  98. * for example, from "Jan 11, 2008" to "Jan 18, 2008".
  99. * We introduced class DateInterval to represent it.
  100. * DateInterval is a pair of UDate, which is
  101. * the standard milliseconds since 24:00 GMT, Jan 1, 1970.
  102. *
  103. * <P>
  104. * DateIntervalFormat formats a DateInterval into
  105. * text as compactly as possible.
  106. * For example, the date interval format from "Jan 11, 2008" to "Jan 18,. 2008"
  107. * is "Jan 11-18, 2008" for English.
  108. * And it parses text into DateInterval,
  109. * although initially, parsing is not supported.
  110. *
  111. * <P>
  112. * There is no structural information in date time patterns.
  113. * For any punctuations and string literals inside a date time pattern,
  114. * we do not know whether it is just a separator, or a prefix, or a suffix.
  115. * Without such information, so, it is difficult to generate a sub-pattern
  116. * (or super-pattern) by algorithm.
  117. * So, formatting a DateInterval is pattern-driven. It is very
  118. * similar to formatting in SimpleDateFormat.
  119. * We introduce class DateIntervalInfo to save date interval
  120. * patterns, similar to date time pattern in SimpleDateFormat.
  121. *
  122. * <P>
  123. * Logically, the interval patterns are mappings
  124. * from (skeleton, the_largest_different_calendar_field)
  125. * to (date_interval_pattern).
  126. *
  127. * <P>
  128. * A skeleton
  129. * <ol>
  130. * <li>
  131. * only keeps the field pattern letter and ignores all other parts
  132. * in a pattern, such as space, punctuations, and string literals.
  133. * </li>
  134. * <li>
  135. * hides the order of fields.
  136. * </li>
  137. * <li>
  138. * might hide a field's pattern letter length.
  139. * </li>
  140. * </ol>
  141. *
  142. * For those non-digit calendar fields, the pattern letter length is
  143. * important, such as MMM, MMMM, and MMMMM; EEE and EEEE,
  144. * and the field's pattern letter length is honored.
  145. *
  146. * For the digit calendar fields, such as M or MM, d or dd, yy or yyyy,
  147. * the field pattern length is ignored and the best match, which is defined
  148. * in date time patterns, will be returned without honor the field pattern
  149. * letter length in skeleton.
  150. *
  151. * <P>
  152. * The calendar fields we support for interval formatting are:
  153. * year, month, date, day-of-week, am-pm, hour, hour-of-day, minute, second,
  154. * and millisecond.
  155. * (though we do not currently have specific intervalFormat date for skeletons
  156. * with seconds and millisecond).
  157. * Those calendar fields can be defined in the following order:
  158. * year > month > date > hour (in day) > minute > second > millisecond
  159. *
  160. * The largest different calendar fields between 2 calendars is the
  161. * first different calendar field in above order.
  162. *
  163. * For example: the largest different calendar fields between "Jan 10, 2007"
  164. * and "Feb 20, 2008" is year.
  165. *
  166. * <P>
  167. * For other calendar fields, the compact interval formatting is not
  168. * supported. And the interval format will be fall back to fall-back
  169. * patterns, which is mostly "{date0} - {date1}".
  170. *
  171. * <P>
  172. * There is a set of pre-defined static skeleton strings.
  173. * There are pre-defined interval patterns for those pre-defined skeletons
  174. * in locales' resource files.
  175. * For example, for a skeleton UDAT_YEAR_ABBR_MONTH_DAY, which is &quot;yMMMd&quot;,
  176. * in en_US, if the largest different calendar field between date1 and date2
  177. * is &quot;year&quot;, the date interval pattern is &quot;MMM d, yyyy - MMM d, yyyy&quot;,
  178. * such as &quot;Jan 10, 2007 - Jan 10, 2008&quot;.
  179. * If the largest different calendar field between date1 and date2 is &quot;month&quot;,
  180. * the date interval pattern is &quot;MMM d - MMM d, yyyy&quot;,
  181. * such as &quot;Jan 10 - Feb 10, 2007&quot;.
  182. * If the largest different calendar field between date1 and date2 is &quot;day&quot;,
  183. * the date interval pattern is &quot;MMM d-d, yyyy&quot;, such as &quot;Jan 10-20, 2007&quot;.
  184. *
  185. * For date skeleton, the interval patterns when year, or month, or date is
  186. * different are defined in resource files.
  187. * For time skeleton, the interval patterns when am/pm, or hour, or minute is
  188. * different are defined in resource files.
  189. *
  190. * <P>
  191. * If a skeleton is not found in a locale's DateIntervalInfo, which means
  192. * the interval patterns for the skeleton is not defined in resource file,
  193. * the interval pattern will falls back to the interval "fallback" pattern
  194. * defined in resource file.
  195. * If the interval "fallback" pattern is not defined, the default fall-back
  196. * is "{date0} - {data1}".
  197. *
  198. * <P>
  199. * For the combination of date and time,
  200. * The rule to generate interval patterns are:
  201. * <ol>
  202. * <li>
  203. * when the year, month, or day differs, falls back to fall-back
  204. * interval pattern, which mostly is the concatenate the two original
  205. * expressions with a separator between,
  206. * For example, interval pattern from "Jan 10, 2007 10:10 am"
  207. * to "Jan 11, 2007 10:10am" is
  208. * "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am"
  209. * </li>
  210. * <li>
  211. * otherwise, present the date followed by the range expression
  212. * for the time.
  213. * For example, interval pattern from "Jan 10, 2007 10:10 am"
  214. * to "Jan 10, 2007 11:10am" is "Jan 10, 2007 10:10 am - 11:10am"
  215. * </li>
  216. * </ol>
  217. *
  218. *
  219. * <P>
  220. * If two dates are the same, the interval pattern is the single date pattern.
  221. * For example, interval pattern from "Jan 10, 2007" to "Jan 10, 2007" is
  222. * "Jan 10, 2007".
  223. *
  224. * Or if the presenting fields between 2 dates have the exact same values,
  225. * the interval pattern is the single date pattern.
  226. * For example, if user only requests year and month,
  227. * the interval pattern from "Jan 10, 2007" to "Jan 20, 2007" is "Jan 2007".
  228. *
  229. * <P>
  230. * DateIntervalFormat needs the following information for correct
  231. * formatting: time zone, calendar type, pattern, date format symbols,
  232. * and date interval patterns.
  233. * It can be instantiated in 2 ways:
  234. * <ol>
  235. * <li>
  236. * create an instance using default or given locale plus given skeleton.
  237. * Users are encouraged to created date interval formatter this way and
  238. * to use the pre-defined skeleton macros, such as
  239. * UDAT_YEAR_NUM_MONTH, which consists the calendar fields and
  240. * the format style.
  241. * </li>
  242. * <li>
  243. * create an instance using default or given locale plus given skeleton
  244. * plus a given DateIntervalInfo.
  245. * This factory method is for powerful users who want to provide their own
  246. * interval patterns.
  247. * Locale provides the timezone, calendar, and format symbols information.
  248. * Local plus skeleton provides full pattern information.
  249. * DateIntervalInfo provides the date interval patterns.
  250. * </li>
  251. * </ol>
  252. *
  253. * <P>
  254. * For the calendar field pattern letter, such as G, y, M, d, a, h, H, m, s etc.
  255. * DateIntervalFormat uses the same syntax as that of
  256. * DateTime format.
  257. *
  258. * <P>
  259. * Code Sample: general usage
  260. * <pre>
  261. * \code
  262. * // the date interval object which the DateIntervalFormat formats on
  263. * // and parses into
  264. * DateInterval* dtInterval = new DateInterval(1000*3600*24, 1000*3600*24*2);
  265. * UErrorCode status = U_ZERO_ERROR;
  266. * DateIntervalFormat* dtIntervalFmt = DateIntervalFormat::createInstance(
  267. * UDAT_YEAR_MONTH_DAY,
  268. * Locale("en", "GB", ""), status);
  269. * UnicodeUnicodeString dateIntervalString;
  270. * FieldPosition pos = 0;
  271. * // formatting
  272. * dtIntervalFmt->format(dtInterval, dateIntervalUnicodeString, pos, status);
  273. * delete dtIntervalFmt;
  274. * \endcode
  275. * </pre>
  276. */
  277. class U_I18N_API DateIntervalFormat : public Format {
  278. public:
  279. /**
  280. * Construct a DateIntervalFormat from skeleton and the default locale.
  281. *
  282. * This is a convenient override of
  283. * createInstance(const UnicodeString& skeleton, const Locale& locale,
  284. * UErrorCode&)
  285. * with the value of locale as default locale.
  286. *
  287. * @param skeleton the skeleton on which interval format based.
  288. * @param status output param set to success/failure code on exit
  289. * @return a date time interval formatter which the caller owns.
  290. * @stable ICU 4.0
  291. */
  292. static DateIntervalFormat* U_EXPORT2 createInstance(
  293. const UnicodeString& skeleton,
  294. UErrorCode& status);
  295. /**
  296. * Construct a DateIntervalFormat from skeleton and a given locale.
  297. * <P>
  298. * In this factory method,
  299. * the date interval pattern information is load from resource files.
  300. * Users are encouraged to created date interval formatter this way and
  301. * to use the pre-defined skeleton macros.
  302. *
  303. * <P>
  304. * There are pre-defined skeletons (defined in udate.h) having predefined
  305. * interval patterns in resource files.
  306. * Users are encouraged to use those macros.
  307. * For example:
  308. * DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)
  309. *
  310. * The given Locale provides the interval patterns.
  311. * For example, for en_GB, if skeleton is UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY,
  312. * which is "yMMMEEEd",
  313. * the interval patterns defined in resource file to above skeleton are:
  314. * "EEE, d MMM, yyyy - EEE, d MMM, yyyy" for year differs,
  315. * "EEE, d MMM - EEE, d MMM, yyyy" for month differs,
  316. * "EEE, d - EEE, d MMM, yyyy" for day differs,
  317. * @param skeleton the skeleton on which the interval format is based.
  318. * @param locale the given locale
  319. * @param status output param set to success/failure code on exit
  320. * @return a date time interval formatter which the caller owns.
  321. * @stable ICU 4.0
  322. */
  323. static DateIntervalFormat* U_EXPORT2 createInstance(
  324. const UnicodeString& skeleton,
  325. const Locale& locale,
  326. UErrorCode& status);
  327. /**
  328. * Construct a DateIntervalFormat from skeleton
  329. * DateIntervalInfo, and default locale.
  330. *
  331. * This is a convenient override of
  332. * createInstance(const UnicodeString& skeleton, const Locale& locale,
  333. * const DateIntervalInfo& dtitvinf, UErrorCode&)
  334. * with the locale value as default locale.
  335. *
  336. * @param skeleton the skeleton on which interval format based.
  337. * @param dtitvinf the DateIntervalInfo object.
  338. * @param status output param set to success/failure code on exit
  339. * @return a date time interval formatter which the caller owns.
  340. * @stable ICU 4.0
  341. */
  342. static DateIntervalFormat* U_EXPORT2 createInstance(
  343. const UnicodeString& skeleton,
  344. const DateIntervalInfo& dtitvinf,
  345. UErrorCode& status);
  346. /**
  347. * Construct a DateIntervalFormat from skeleton
  348. * a DateIntervalInfo, and the given locale.
  349. *
  350. * <P>
  351. * In this factory method, user provides its own date interval pattern
  352. * information, instead of using those pre-defined data in resource file.
  353. * This factory method is for powerful users who want to provide their own
  354. * interval patterns.
  355. * <P>
  356. * There are pre-defined skeletons (defined in udate.h) having predefined
  357. * interval patterns in resource files.
  358. * Users are encouraged to use those macros.
  359. * For example:
  360. * DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)
  361. *
  362. * The DateIntervalInfo provides the interval patterns.
  363. * and the DateIntervalInfo ownership remains to the caller.
  364. *
  365. * User are encouraged to set default interval pattern in DateIntervalInfo
  366. * as well, if they want to set other interval patterns ( instead of
  367. * reading the interval patterns from resource files).
  368. * When the corresponding interval pattern for a largest calendar different
  369. * field is not found ( if user not set it ), interval format fallback to
  370. * the default interval pattern.
  371. * If user does not provide default interval pattern, it fallback to
  372. * "{date0} - {date1}"
  373. *
  374. * @param skeleton the skeleton on which interval format based.
  375. * @param locale the given locale
  376. * @param dtitvinf the DateIntervalInfo object.
  377. * @param status output param set to success/failure code on exit
  378. * @return a date time interval formatter which the caller owns.
  379. * @stable ICU 4.0
  380. */
  381. static DateIntervalFormat* U_EXPORT2 createInstance(
  382. const UnicodeString& skeleton,
  383. const Locale& locale,
  384. const DateIntervalInfo& dtitvinf,
  385. UErrorCode& status);
  386. /**
  387. * Destructor.
  388. * @stable ICU 4.0
  389. */
  390. virtual ~DateIntervalFormat();
  391. /**
  392. * Clone this Format object polymorphically. The caller owns the result and
  393. * should delete it when done.
  394. * @return A copy of the object.
  395. * @stable ICU 4.0
  396. */
  397. virtual DateIntervalFormat* clone() const override;
  398. /**
  399. * Return true if the given Format objects are semantically equal. Objects
  400. * of different subclasses are considered unequal.
  401. * @param other the object to be compared with.
  402. * @return true if the given Format objects are semantically equal.
  403. * @stable ICU 4.0
  404. */
  405. virtual bool operator==(const Format& other) const override;
  406. /**
  407. * Return true if the given Format objects are not semantically equal.
  408. * Objects of different subclasses are considered unequal.
  409. * @param other the object to be compared with.
  410. * @return true if the given Format objects are not semantically equal.
  411. * @stable ICU 4.0
  412. */
  413. bool operator!=(const Format& other) const;
  414. using Format::format;
  415. /**
  416. * Format an object to produce a string. This method handles Formattable
  417. * objects with a DateInterval type.
  418. * If a the Formattable object type is not a DateInterval,
  419. * then it returns a failing UErrorCode.
  420. *
  421. * @param obj The object to format.
  422. * Must be a DateInterval.
  423. * @param appendTo Output parameter to receive result.
  424. * Result is appended to existing contents.
  425. * @param fieldPosition On input: an alignment field, if desired.
  426. * On output: the offsets of the alignment field.
  427. * There may be multiple instances of a given field type
  428. * in an interval format; in this case the fieldPosition
  429. * offsets refer to the first instance.
  430. * @param status Output param filled with success/failure status.
  431. * @return Reference to 'appendTo' parameter.
  432. * @stable ICU 4.0
  433. */
  434. virtual UnicodeString& format(const Formattable& obj,
  435. UnicodeString& appendTo,
  436. FieldPosition& fieldPosition,
  437. UErrorCode& status) const override;
  438. /**
  439. * Format a DateInterval to produce a string.
  440. *
  441. * @param dtInterval DateInterval to be formatted.
  442. * @param appendTo Output parameter to receive result.
  443. * Result is appended to existing contents.
  444. * @param fieldPosition On input: an alignment field, if desired.
  445. * On output: the offsets of the alignment field.
  446. * There may be multiple instances of a given field type
  447. * in an interval format; in this case the fieldPosition
  448. * offsets refer to the first instance.
  449. * @param status Output param filled with success/failure status.
  450. * @return Reference to 'appendTo' parameter.
  451. * @stable ICU 4.0
  452. */
  453. UnicodeString& format(const DateInterval* dtInterval,
  454. UnicodeString& appendTo,
  455. FieldPosition& fieldPosition,
  456. UErrorCode& status) const ;
  457. /**
  458. * Format a DateInterval to produce a FormattedDateInterval.
  459. *
  460. * The FormattedDateInterval exposes field information about the formatted string.
  461. *
  462. * @param dtInterval DateInterval to be formatted.
  463. * @param status Set if an error occurs.
  464. * @return A FormattedDateInterval containing the format result.
  465. * @stable ICU 64
  466. */
  467. FormattedDateInterval formatToValue(
  468. const DateInterval& dtInterval,
  469. UErrorCode& status) const;
  470. /**
  471. * Format 2 Calendars to produce a string.
  472. *
  473. * Note: "fromCalendar" and "toCalendar" are not const,
  474. * since calendar is not const in SimpleDateFormat::format(Calendar&),
  475. *
  476. * @param fromCalendar calendar set to the from date in date interval
  477. * to be formatted into date interval string
  478. * @param toCalendar calendar set to the to date in date interval
  479. * to be formatted into date interval string
  480. * @param appendTo Output parameter to receive result.
  481. * Result is appended to existing contents.
  482. * @param fieldPosition On input: an alignment field, if desired.
  483. * On output: the offsets of the alignment field.
  484. * There may be multiple instances of a given field type
  485. * in an interval format; in this case the fieldPosition
  486. * offsets refer to the first instance.
  487. * @param status Output param filled with success/failure status.
  488. * Caller needs to make sure it is SUCCESS
  489. * at the function entrance
  490. * @return Reference to 'appendTo' parameter.
  491. * @stable ICU 4.0
  492. */
  493. UnicodeString& format(Calendar& fromCalendar,
  494. Calendar& toCalendar,
  495. UnicodeString& appendTo,
  496. FieldPosition& fieldPosition,
  497. UErrorCode& status) const ;
  498. /**
  499. * Format 2 Calendars to produce a FormattedDateInterval.
  500. *
  501. * The FormattedDateInterval exposes field information about the formatted string.
  502. *
  503. * Note: "fromCalendar" and "toCalendar" are not const,
  504. * since calendar is not const in SimpleDateFormat::format(Calendar&),
  505. *
  506. * @param fromCalendar calendar set to the from date in date interval
  507. * to be formatted into date interval string
  508. * @param toCalendar calendar set to the to date in date interval
  509. * to be formatted into date interval string
  510. * @param status Set if an error occurs.
  511. * @return A FormattedDateInterval containing the format result.
  512. * @stable ICU 64
  513. */
  514. FormattedDateInterval formatToValue(
  515. Calendar& fromCalendar,
  516. Calendar& toCalendar,
  517. UErrorCode& status) const;
  518. /**
  519. * Date interval parsing is not supported. Please do not use.
  520. * <P>
  521. * This method should handle parsing of
  522. * date time interval strings into Formattable objects with
  523. * DateInterval type, which is a pair of UDate.
  524. * <P>
  525. * Before calling, set parse_pos.index to the offset you want to start
  526. * parsing at in the source. After calling, parse_pos.index is the end of
  527. * the text you parsed. If error occurs, index is unchanged.
  528. * <P>
  529. * When parsing, leading whitespace is discarded (with a successful parse),
  530. * while trailing whitespace is left as is.
  531. * <P>
  532. * See Format::parseObject() for more.
  533. *
  534. * @param source The string to be parsed into an object.
  535. * @param result Formattable to be set to the parse result.
  536. * If parse fails, return contents are undefined.
  537. * @param parse_pos The position to start parsing at. Since no parsing
  538. * is supported, upon return this param is unchanged.
  539. * @return A newly created Formattable* object, or nullptr
  540. * on failure. The caller owns this and should
  541. * delete it when done.
  542. * @internal ICU 4.0
  543. */
  544. virtual void parseObject(const UnicodeString& source,
  545. Formattable& result,
  546. ParsePosition& parse_pos) const override;
  547. /**
  548. * Gets the date time interval patterns.
  549. * @return the date time interval patterns associated with
  550. * this date interval formatter.
  551. * @stable ICU 4.0
  552. */
  553. const DateIntervalInfo* getDateIntervalInfo() const;
  554. /**
  555. * Set the date time interval patterns.
  556. * @param newIntervalPatterns the given interval patterns to copy.
  557. * @param status output param set to success/failure code on exit
  558. * @stable ICU 4.0
  559. */
  560. void setDateIntervalInfo(const DateIntervalInfo& newIntervalPatterns,
  561. UErrorCode& status);
  562. /**
  563. * Gets the date formatter. The DateIntervalFormat instance continues to own
  564. * the returned DateFormatter object, and will use and possibly modify it
  565. * during format operations. In a multi-threaded environment, the returned
  566. * DateFormat can only be used if it is certain that no other threads are
  567. * concurrently using this DateIntervalFormatter, even for nominally const
  568. * functions.
  569. *
  570. * @return the date formatter associated with this date interval formatter.
  571. * @stable ICU 4.0
  572. */
  573. const DateFormat* getDateFormat() const;
  574. /**
  575. * Returns a reference to the TimeZone used by this DateIntervalFormat's calendar.
  576. * @return the time zone associated with the calendar of DateIntervalFormat.
  577. * @stable ICU 4.8
  578. */
  579. virtual const TimeZone& getTimeZone() const;
  580. /**
  581. * Sets the time zone for the calendar used by this DateIntervalFormat object. The
  582. * caller no longer owns the TimeZone object and should not delete it after this call.
  583. * @param zoneToAdopt the TimeZone to be adopted.
  584. * @stable ICU 4.8
  585. */
  586. virtual void adoptTimeZone(TimeZone* zoneToAdopt);
  587. /**
  588. * Sets the time zone for the calendar used by this DateIntervalFormat object.
  589. * @param zone the new time zone.
  590. * @stable ICU 4.8
  591. */
  592. virtual void setTimeZone(const TimeZone& zone);
  593. /**
  594. * Set a particular UDisplayContext value in the formatter, such as
  595. * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. This causes the formatted
  596. * result to be capitalized appropriately for the context in which
  597. * it is intended to be used, considering both the locale and the
  598. * type of field at the beginning of the formatted result.
  599. * @param value The UDisplayContext value to set.
  600. * @param status Input/output status. If at entry this indicates a failure
  601. * status, the function will do nothing; otherwise this will be
  602. * updated with any new status from the function.
  603. * @stable ICU 68
  604. */
  605. virtual void setContext(UDisplayContext value, UErrorCode& status);
  606. /**
  607. * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
  608. * such as UDISPCTX_TYPE_CAPITALIZATION.
  609. * @param type The UDisplayContextType whose value to return
  610. * @param status Input/output status. If at entry this indicates a failure
  611. * status, the function will do nothing; otherwise this will be
  612. * updated with any new status from the function.
  613. * @return The UDisplayContextValue for the specified type.
  614. * @stable ICU 68
  615. */
  616. virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
  617. /**
  618. * Return the class ID for this class. This is useful only for comparing to
  619. * a return value from getDynamicClassID(). For example:
  620. * <pre>
  621. * . Base* polymorphic_pointer = createPolymorphicObject();
  622. * . if (polymorphic_pointer->getDynamicClassID() ==
  623. * . erived::getStaticClassID()) ...
  624. * </pre>
  625. * @return The class ID for all objects of this class.
  626. * @stable ICU 4.0
  627. */
  628. static UClassID U_EXPORT2 getStaticClassID();
  629. /**
  630. * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
  631. * method is to implement a simple version of RTTI, since not all C++
  632. * compilers support genuine RTTI. Polymorphic operator==() and clone()
  633. * methods call this method.
  634. *
  635. * @return The class ID for this object. All objects of a
  636. * given class have the same class ID. Objects of
  637. * other classes have different class IDs.
  638. * @stable ICU 4.0
  639. */
  640. virtual UClassID getDynamicClassID() const override;
  641. protected:
  642. /**
  643. * Copy constructor.
  644. * @stable ICU 4.0
  645. */
  646. DateIntervalFormat(const DateIntervalFormat&);
  647. /**
  648. * Assignment operator.
  649. * @stable ICU 4.0
  650. */
  651. DateIntervalFormat& operator=(const DateIntervalFormat&);
  652. private:
  653. /*
  654. * This is for ICU internal use only. Please do not use.
  655. * Save the interval pattern information.
  656. * Interval pattern consists of 2 single date patterns and the separator.
  657. * For example, interval pattern "MMM d - MMM d, yyyy" consists
  658. * a single date pattern "MMM d", another single date pattern "MMM d, yyyy",
  659. * and a separator "-".
  660. * The pattern is divided into 2 parts. For above example,
  661. * the first part is "MMM d - ", and the second part is "MMM d, yyyy".
  662. * Also, the first date appears in an interval pattern could be
  663. * the earlier date or the later date.
  664. * And such information is saved in the interval pattern as well.
  665. */
  666. struct PatternInfo {
  667. UnicodeString firstPart;
  668. UnicodeString secondPart;
  669. /**
  670. * Whether the first date in interval pattern is later date or not.
  671. * Fallback format set the default ordering.
  672. * And for a particular interval pattern, the order can be
  673. * overridden by prefixing the interval pattern with "latestFirst:" or
  674. * "earliestFirst:"
  675. * For example, given 2 date, Jan 10, 2007 to Feb 10, 2007.
  676. * if the fallback format is "{0} - {1}",
  677. * and the pattern is "d MMM - d MMM yyyy", the interval format is
  678. * "10 Jan - 10 Feb, 2007".
  679. * If the pattern is "latestFirst:d MMM - d MMM yyyy",
  680. * the interval format is "10 Feb - 10 Jan, 2007"
  681. */
  682. UBool laterDateFirst;
  683. };
  684. /**
  685. * default constructor
  686. * @internal (private)
  687. */
  688. DateIntervalFormat();
  689. /**
  690. * Construct a DateIntervalFormat from DateFormat,
  691. * a DateIntervalInfo, and skeleton.
  692. * DateFormat provides the timezone, calendar,
  693. * full pattern, and date format symbols information.
  694. * It should be a SimpleDateFormat object which
  695. * has a pattern in it.
  696. * the DateIntervalInfo provides the interval patterns.
  697. *
  698. * Note: the DateIntervalFormat takes ownership of both
  699. * DateFormat and DateIntervalInfo objects.
  700. * Caller should not delete them.
  701. *
  702. * @param locale the locale of this date interval formatter.
  703. * @param dtItvInfo the DateIntervalInfo object to be adopted.
  704. * @param skeleton the skeleton of the date formatter
  705. * @param status output param set to success/failure code on exit
  706. */
  707. DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo,
  708. const UnicodeString* skeleton, UErrorCode& status);
  709. /**
  710. * Construct a DateIntervalFormat from DateFormat
  711. * and a DateIntervalInfo.
  712. *
  713. * It is a wrapper of the constructor.
  714. *
  715. * @param locale the locale of this date interval formatter.
  716. * @param dtitvinf the DateIntervalInfo object to be adopted.
  717. * @param skeleton the skeleton of this formatter.
  718. * @param status Output param set to success/failure code.
  719. * @return a date time interval formatter which the caller owns.
  720. */
  721. static DateIntervalFormat* U_EXPORT2 create(const Locale& locale,
  722. DateIntervalInfo* dtitvinf,
  723. const UnicodeString* skeleton,
  724. UErrorCode& status);
  725. /**
  726. * Below are for generating interval patterns local to the formatter
  727. */
  728. /** Like fallbackFormat, but only formats the range part of the fallback. */
  729. void fallbackFormatRange(
  730. Calendar& fromCalendar,
  731. Calendar& toCalendar,
  732. UnicodeString& appendTo,
  733. int8_t& firstIndex,
  734. FieldPositionHandler& fphandler,
  735. UErrorCode& status) const;
  736. /**
  737. * Format 2 Calendars using fall-back interval pattern
  738. *
  739. * The full pattern used in this fall-back format is the
  740. * full pattern of the date formatter.
  741. *
  742. * gFormatterMutex must already be locked when calling this function.
  743. *
  744. * @param fromCalendar calendar set to the from date in date interval
  745. * to be formatted into date interval string
  746. * @param toCalendar calendar set to the to date in date interval
  747. * to be formatted into date interval string
  748. * @param fromToOnSameDay true iff from and to dates are on the same day
  749. * (any difference is in ampm/hours or below)
  750. * @param appendTo Output parameter to receive result.
  751. * Result is appended to existing contents.
  752. * @param firstIndex See formatImpl for more information.
  753. * @param fphandler See formatImpl for more information.
  754. * @param status output param set to success/failure code on exit
  755. * @return Reference to 'appendTo' parameter.
  756. * @internal (private)
  757. */
  758. UnicodeString& fallbackFormat(Calendar& fromCalendar,
  759. Calendar& toCalendar,
  760. UBool fromToOnSameDay,
  761. UnicodeString& appendTo,
  762. int8_t& firstIndex,
  763. FieldPositionHandler& fphandler,
  764. UErrorCode& status) const;
  765. /**
  766. * Initialize interval patterns locale to this formatter
  767. *
  768. * This code is a bit complicated since
  769. * 1. the interval patterns saved in resource bundle files are interval
  770. * patterns based on date or time only.
  771. * It does not have interval patterns based on both date and time.
  772. * Interval patterns on both date and time are algorithm generated.
  773. *
  774. * For example, it has interval patterns on skeleton "dMy" and "hm",
  775. * but it does not have interval patterns on skeleton "dMyhm".
  776. *
  777. * The rule to generate interval patterns for both date and time skeleton are
  778. * 1) when the year, month, or day differs, concatenate the two original
  779. * expressions with a separator between,
  780. * For example, interval pattern from "Jan 10, 2007 10:10 am"
  781. * to "Jan 11, 2007 10:10am" is
  782. * "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am"
  783. *
  784. * 2) otherwise, present the date followed by the range expression
  785. * for the time.
  786. * For example, interval pattern from "Jan 10, 2007 10:10 am"
  787. * to "Jan 10, 2007 11:10am" is
  788. * "Jan 10, 2007 10:10 am - 11:10am"
  789. *
  790. * 2. even a pattern does not request a certain calendar field,
  791. * the interval pattern needs to include such field if such fields are
  792. * different between 2 dates.
  793. * For example, a pattern/skeleton is "hm", but the interval pattern
  794. * includes year, month, and date when year, month, and date differs.
  795. *
  796. *
  797. * @param status output param set to success/failure code on exit
  798. */
  799. void initializePattern(UErrorCode& status);
  800. /**
  801. * Set fall back interval pattern given a calendar field,
  802. * a skeleton, and a date time pattern generator.
  803. * @param field the largest different calendar field
  804. * @param skeleton a skeleton
  805. * @param status output param set to success/failure code on exit
  806. */
  807. void setFallbackPattern(UCalendarDateFields field,
  808. const UnicodeString& skeleton,
  809. UErrorCode& status);
  810. /**
  811. * Converts special hour metacharacters (such as 'j') in the skeleton into locale-appropriate
  812. * pattern characters.
  813. *
  814. *
  815. * @param skeleton The skeleton to convert
  816. * @return A copy of the skeleton, which "j" and any other special hour metacharacters converted to the regular ones.
  817. *
  818. */
  819. UnicodeString normalizeHourMetacharacters(const UnicodeString& skeleton) const;
  820. /**
  821. * get separated date and time skeleton from a combined skeleton.
  822. *
  823. * The difference between date skeleton and normalizedDateSkeleton are:
  824. * 1. both 'y' and 'd' are appeared only once in normalizeDateSkeleton
  825. * 2. 'E' and 'EE' are normalized into 'EEE'
  826. * 3. 'MM' is normalized into 'M'
  827. *
  828. ** the difference between time skeleton and normalizedTimeSkeleton are:
  829. * 1. both 'H' and 'h' are normalized as 'h' in normalized time skeleton,
  830. * 2. 'a' is omitted in normalized time skeleton.
  831. * 3. there is only one appearance for 'h', 'm','v', 'z' in normalized time
  832. * skeleton
  833. *
  834. *
  835. * @param skeleton given combined skeleton.
  836. * @param date Output parameter for date only skeleton.
  837. * @param normalizedDate Output parameter for normalized date only
  838. *
  839. * @param time Output parameter for time only skeleton.
  840. * @param normalizedTime Output parameter for normalized time only
  841. * skeleton.
  842. *
  843. */
  844. static void U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton,
  845. UnicodeString& date,
  846. UnicodeString& normalizedDate,
  847. UnicodeString& time,
  848. UnicodeString& normalizedTime);
  849. /**
  850. * Generate date or time interval pattern from resource,
  851. * and set them into the interval pattern locale to this formatter.
  852. *
  853. * It needs to handle the following:
  854. * 1. need to adjust field width.
  855. * For example, the interval patterns saved in DateIntervalInfo
  856. * includes "dMMMy", but not "dMMMMy".
  857. * Need to get interval patterns for dMMMMy from dMMMy.
  858. * Another example, the interval patterns saved in DateIntervalInfo
  859. * includes "hmv", but not "hmz".
  860. * Need to get interval patterns for "hmz' from 'hmv'
  861. *
  862. * 2. there might be no pattern for 'y' differ for skeleton "Md",
  863. * in order to get interval patterns for 'y' differ,
  864. * need to look for it from skeleton 'yMd'
  865. *
  866. * @param dateSkeleton normalized date skeleton
  867. * @param timeSkeleton normalized time skeleton
  868. * @return whether the resource is found for the skeleton.
  869. * true if interval pattern found for the skeleton,
  870. * false otherwise.
  871. */
  872. UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,
  873. const UnicodeString& timeSkeleton);
  874. /**
  875. * Generate interval pattern from existing resource
  876. *
  877. * It not only save the interval patterns,
  878. * but also return the extended skeleton and its best match skeleton.
  879. *
  880. * @param field largest different calendar field
  881. * @param skeleton skeleton
  882. * @param bestSkeleton the best match skeleton which has interval pattern
  883. * defined in resource
  884. * @param differenceInfo the difference between skeleton and best skeleton
  885. * 0 means the best matched skeleton is the same as input skeleton
  886. * 1 means the fields are the same, but field width are different
  887. * 2 means the only difference between fields are v/z,
  888. * -1 means there are other fields difference
  889. *
  890. * @param extendedSkeleton extended skeleton
  891. * @param extendedBestSkeleton extended best match skeleton
  892. * @return whether the interval pattern is found
  893. * through extending skeleton or not.
  894. * true if interval pattern is found by
  895. * extending skeleton, false otherwise.
  896. */
  897. UBool setIntervalPattern(UCalendarDateFields field,
  898. const UnicodeString* skeleton,
  899. const UnicodeString* bestSkeleton,
  900. int8_t differenceInfo,
  901. UnicodeString* extendedSkeleton = nullptr,
  902. UnicodeString* extendedBestSkeleton = nullptr);
  903. /**
  904. * Adjust field width in best match interval pattern to match
  905. * the field width in input skeleton.
  906. *
  907. * TODO (xji) make a general solution
  908. * The adjusting rule can be:
  909. * 1. always adjust
  910. * 2. never adjust
  911. * 3. default adjust, which means adjust according to the following rules
  912. * 3.1 always adjust string, such as MMM and MMMM
  913. * 3.2 never adjust between string and numeric, such as MM and MMM
  914. * 3.3 always adjust year
  915. * 3.4 do not adjust 'd', 'h', or 'm' if h presents
  916. * 3.5 do not adjust 'M' if it is numeric(?)
  917. *
  918. * Since date interval format is well-formed format,
  919. * date and time skeletons are normalized previously,
  920. * till this stage, the adjust here is only "adjust strings, such as MMM
  921. * and MMMM, EEE and EEEE.
  922. *
  923. * @param inputSkeleton the input skeleton
  924. * @param bestMatchSkeleton the best match skeleton
  925. * @param bestMatchIntervalPattern the best match interval pattern
  926. * @param differenceInfo the difference between 2 skeletons
  927. * 1 means only field width differs
  928. * 2 means v/z exchange
  929. * @param suppressDayPeriodField if true, remove the day period field from the pattern, if there is one
  930. * @param adjustedIntervalPattern adjusted interval pattern
  931. */
  932. static void U_EXPORT2 adjustFieldWidth(
  933. const UnicodeString& inputSkeleton,
  934. const UnicodeString& bestMatchSkeleton,
  935. const UnicodeString& bestMatchIntervalPattern,
  936. int8_t differenceInfo,
  937. UBool suppressDayPeriodField,
  938. UnicodeString& adjustedIntervalPattern);
  939. /**
  940. * Does the same thing as UnicodeString::findAndReplace(), except that it won't perform
  941. * the substitution inside quoted literal text.
  942. * @param targetString The string to perform the find-replace operation on.
  943. * @param strToReplace The string to search for and replace in the target string.
  944. * @param strToReplaceWith The string to substitute in wherever `stringToReplace` was found.
  945. */
  946. static void U_EXPORT2 findReplaceInPattern(UnicodeString& targetString,
  947. const UnicodeString& strToReplace,
  948. const UnicodeString& strToReplaceWith);
  949. /**
  950. * Concat a single date pattern with a time interval pattern,
  951. * set it into the intervalPatterns, while field is time field.
  952. * This is used to handle time interval patterns on skeleton with
  953. * both time and date. Present the date followed by
  954. * the range expression for the time.
  955. * @param format date and time format
  956. * @param datePattern date pattern
  957. * @param field time calendar field: AM_PM, HOUR, MINUTE
  958. * @param status output param set to success/failure code on exit
  959. */
  960. void concatSingleDate2TimeInterval(UnicodeString& format,
  961. const UnicodeString& datePattern,
  962. UCalendarDateFields field,
  963. UErrorCode& status);
  964. /**
  965. * check whether a calendar field present in a skeleton.
  966. * @param field calendar field need to check
  967. * @param skeleton given skeleton on which to check the calendar field
  968. * @return true if field present in a skeleton.
  969. */
  970. static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field,
  971. const UnicodeString& skeleton);
  972. /**
  973. * Split interval patterns into 2 part.
  974. * @param intervalPattern interval pattern
  975. * @return the index in interval pattern which split the pattern into 2 part
  976. */
  977. static int32_t U_EXPORT2 splitPatternInto2Part(const UnicodeString& intervalPattern);
  978. /**
  979. * Break interval patterns as 2 part and save them into pattern info.
  980. * @param field calendar field
  981. * @param intervalPattern interval pattern
  982. */
  983. void setIntervalPattern(UCalendarDateFields field,
  984. const UnicodeString& intervalPattern);
  985. /**
  986. * Break interval patterns as 2 part and save them into pattern info.
  987. * @param field calendar field
  988. * @param intervalPattern interval pattern
  989. * @param laterDateFirst whether later date appear first in interval pattern
  990. */
  991. void setIntervalPattern(UCalendarDateFields field,
  992. const UnicodeString& intervalPattern,
  993. UBool laterDateFirst);
  994. /**
  995. * Set pattern information.
  996. *
  997. * @param field calendar field
  998. * @param firstPart the first part in interval pattern
  999. * @param secondPart the second part in interval pattern
  1000. * @param laterDateFirst whether the first date in intervalPattern
  1001. * is earlier date or later date
  1002. */
  1003. void setPatternInfo(UCalendarDateFields field,
  1004. const UnicodeString* firstPart,
  1005. const UnicodeString* secondPart,
  1006. UBool laterDateFirst);
  1007. /**
  1008. * Format 2 Calendars to produce a string.
  1009. * Implementation of the similar public format function.
  1010. * Must be called with gFormatterMutex already locked.
  1011. *
  1012. * Note: "fromCalendar" and "toCalendar" are not const,
  1013. * since calendar is not const in SimpleDateFormat::format(Calendar&),
  1014. *
  1015. * @param fromCalendar calendar set to the from date in date interval
  1016. * to be formatted into date interval string
  1017. * @param toCalendar calendar set to the to date in date interval
  1018. * to be formatted into date interval string
  1019. * @param appendTo Output parameter to receive result.
  1020. * Result is appended to existing contents.
  1021. * @param firstIndex 0 if the first output date is fromCalendar;
  1022. * 1 if it corresponds to toCalendar;
  1023. * -1 if there is only one date printed.
  1024. * @param fphandler Handler for field position information.
  1025. * The fields will be from the UDateFormatField enum.
  1026. * @param status Output param filled with success/failure status.
  1027. * Caller needs to make sure it is SUCCESS
  1028. * at the function entrance
  1029. * @return Reference to 'appendTo' parameter.
  1030. * @internal (private)
  1031. */
  1032. UnicodeString& formatImpl(Calendar& fromCalendar,
  1033. Calendar& toCalendar,
  1034. UnicodeString& appendTo,
  1035. int8_t& firstIndex,
  1036. FieldPositionHandler& fphandler,
  1037. UErrorCode& status) const ;
  1038. /** Version of formatImpl for DateInterval. */
  1039. UnicodeString& formatIntervalImpl(const DateInterval& dtInterval,
  1040. UnicodeString& appendTo,
  1041. int8_t& firstIndex,
  1042. FieldPositionHandler& fphandler,
  1043. UErrorCode& status) const;
  1044. // from calendar field to pattern letter
  1045. static const char16_t fgCalendarFieldToPatternLetter[];
  1046. /**
  1047. * The interval patterns for this locale.
  1048. */
  1049. DateIntervalInfo* fInfo;
  1050. /**
  1051. * The DateFormat object used to format single pattern
  1052. */
  1053. SimpleDateFormat* fDateFormat;
  1054. /**
  1055. * The 2 calendars with the from and to date.
  1056. * could re-use the calendar in fDateFormat,
  1057. * but keeping 2 calendars make it clear and clean.
  1058. */
  1059. Calendar* fFromCalendar;
  1060. Calendar* fToCalendar;
  1061. Locale fLocale;
  1062. /**
  1063. * Following are interval information relevant (locale) to this formatter.
  1064. */
  1065. UnicodeString fSkeleton;
  1066. PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX];
  1067. /**
  1068. * Patterns for fallback formatting.
  1069. */
  1070. UnicodeString* fDatePattern;
  1071. UnicodeString* fTimePattern;
  1072. UnicodeString* fDateTimeFormat;
  1073. /**
  1074. * Other formatting information
  1075. */
  1076. UDisplayContext fCapitalizationContext;
  1077. };
  1078. inline bool
  1079. DateIntervalFormat::operator!=(const Format& other) const {
  1080. return !operator==(other);
  1081. }
  1082. U_NAMESPACE_END
  1083. #endif /* #if !UCONFIG_NO_FORMATTING */
  1084. #endif /* U_SHOW_CPLUSPLUS_API */
  1085. #endif // _DTITVFMT_H__
  1086. //eof