jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /******************************************************************************** jpayne@69: * Copyright (C) 2008-2016, International Business Machines Corporation and jpayne@69: * others. All Rights Reserved. jpayne@69: ******************************************************************************* jpayne@69: * jpayne@69: * File DTITVFMT.H jpayne@69: * jpayne@69: ******************************************************************************* jpayne@69: */ jpayne@69: jpayne@69: #ifndef __DTITVFMT_H__ jpayne@69: #define __DTITVFMT_H__ jpayne@69: jpayne@69: jpayne@69: #include "unicode/utypes.h" jpayne@69: jpayne@69: #if U_SHOW_CPLUSPLUS_API jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C++ API: Format and parse date interval in a language-independent manner. jpayne@69: */ jpayne@69: jpayne@69: #if !UCONFIG_NO_FORMATTING jpayne@69: jpayne@69: #include "unicode/ucal.h" jpayne@69: #include "unicode/smpdtfmt.h" jpayne@69: #include "unicode/dtintrv.h" jpayne@69: #include "unicode/dtitvinf.h" jpayne@69: #include "unicode/dtptngen.h" jpayne@69: #include "unicode/formattedvalue.h" jpayne@69: jpayne@69: U_NAMESPACE_BEGIN jpayne@69: jpayne@69: jpayne@69: class FormattedDateIntervalData; jpayne@69: class DateIntervalFormat; jpayne@69: jpayne@69: /** jpayne@69: * An immutable class containing the result of a date interval formatting operation. jpayne@69: * jpayne@69: * Instances of this class are immutable and thread-safe. jpayne@69: * jpayne@69: * When calling nextPosition(): jpayne@69: * The fields are returned from left to right. The special field category jpayne@69: * UFIELD_CATEGORY_DATE_INTERVAL_SPAN is used to indicate which datetime jpayne@69: * primitives came from which arguments: 0 means fromCalendar, and 1 means jpayne@69: * toCalendar. The span category will always occur before the jpayne@69: * corresponding fields in UFIELD_CATEGORY_DATE jpayne@69: * in the nextPosition() iterator. jpayne@69: * jpayne@69: * Not intended for public subclassing. jpayne@69: * jpayne@69: * @stable ICU 64 jpayne@69: */ jpayne@69: class U_I18N_API FormattedDateInterval : public UMemory, public FormattedValue { jpayne@69: public: jpayne@69: /** jpayne@69: * Default constructor; makes an empty FormattedDateInterval. jpayne@69: * @stable ICU 64 jpayne@69: */ jpayne@69: FormattedDateInterval() : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {} jpayne@69: jpayne@69: /** jpayne@69: * Move constructor: Leaves the source FormattedDateInterval in an undefined state. jpayne@69: * @stable ICU 64 jpayne@69: */ jpayne@69: FormattedDateInterval(FormattedDateInterval&& src) U_NOEXCEPT; jpayne@69: jpayne@69: /** jpayne@69: * Destruct an instance of FormattedDateInterval. jpayne@69: * @stable ICU 64 jpayne@69: */ jpayne@69: virtual ~FormattedDateInterval() U_OVERRIDE; jpayne@69: jpayne@69: /** Copying not supported; use move constructor instead. */ jpayne@69: FormattedDateInterval(const FormattedDateInterval&) = delete; jpayne@69: jpayne@69: /** Copying not supported; use move assignment instead. */ jpayne@69: FormattedDateInterval& operator=(const FormattedDateInterval&) = delete; jpayne@69: jpayne@69: /** jpayne@69: * Move assignment: Leaves the source FormattedDateInterval in an undefined state. jpayne@69: * @stable ICU 64 jpayne@69: */ jpayne@69: FormattedDateInterval& operator=(FormattedDateInterval&& src) U_NOEXCEPT; jpayne@69: jpayne@69: /** @copydoc FormattedValue::toString() */ jpayne@69: UnicodeString toString(UErrorCode& status) const U_OVERRIDE; jpayne@69: jpayne@69: /** @copydoc FormattedValue::toTempString() */ jpayne@69: UnicodeString toTempString(UErrorCode& status) const U_OVERRIDE; jpayne@69: jpayne@69: /** @copydoc FormattedValue::appendTo() */ jpayne@69: Appendable &appendTo(Appendable& appendable, UErrorCode& status) const U_OVERRIDE; jpayne@69: jpayne@69: /** @copydoc FormattedValue::nextPosition() */ jpayne@69: UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const U_OVERRIDE; jpayne@69: jpayne@69: private: jpayne@69: FormattedDateIntervalData *fData; jpayne@69: UErrorCode fErrorCode; jpayne@69: explicit FormattedDateInterval(FormattedDateIntervalData *results) jpayne@69: : fData(results), fErrorCode(U_ZERO_ERROR) {} jpayne@69: explicit FormattedDateInterval(UErrorCode errorCode) jpayne@69: : fData(nullptr), fErrorCode(errorCode) {} jpayne@69: friend class DateIntervalFormat; jpayne@69: }; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * DateIntervalFormat is a class for formatting and parsing date jpayne@69: * intervals in a language-independent manner. jpayne@69: * Only formatting is supported, parsing is not supported. jpayne@69: * jpayne@69: *
jpayne@69: * Date interval means from one date to another date, jpayne@69: * for example, from "Jan 11, 2008" to "Jan 18, 2008". jpayne@69: * We introduced class DateInterval to represent it. jpayne@69: * DateInterval is a pair of UDate, which is jpayne@69: * the standard milliseconds since 24:00 GMT, Jan 1, 1970. jpayne@69: * jpayne@69: *
jpayne@69: * DateIntervalFormat formats a DateInterval into jpayne@69: * text as compactly as possible. jpayne@69: * For example, the date interval format from "Jan 11, 2008" to "Jan 18,. 2008" jpayne@69: * is "Jan 11-18, 2008" for English. jpayne@69: * And it parses text into DateInterval, jpayne@69: * although initially, parsing is not supported. jpayne@69: * jpayne@69: *
jpayne@69: * There is no structural information in date time patterns. jpayne@69: * For any punctuations and string literals inside a date time pattern, jpayne@69: * we do not know whether it is just a separator, or a prefix, or a suffix. jpayne@69: * Without such information, so, it is difficult to generate a sub-pattern jpayne@69: * (or super-pattern) by algorithm. jpayne@69: * So, formatting a DateInterval is pattern-driven. It is very jpayne@69: * similar to formatting in SimpleDateFormat. jpayne@69: * We introduce class DateIntervalInfo to save date interval jpayne@69: * patterns, similar to date time pattern in SimpleDateFormat. jpayne@69: * jpayne@69: *
jpayne@69: * Logically, the interval patterns are mappings jpayne@69: * from (skeleton, the_largest_different_calendar_field) jpayne@69: * to (date_interval_pattern). jpayne@69: * jpayne@69: *
jpayne@69: * A skeleton jpayne@69: *
jpayne@69: * The calendar fields we support for interval formatting are: jpayne@69: * year, month, date, day-of-week, am-pm, hour, hour-of-day, minute, second, jpayne@69: * and millisecond. jpayne@69: * (though we do not currently have specific intervalFormat date for skeletons jpayne@69: * with seconds and millisecond). jpayne@69: * Those calendar fields can be defined in the following order: jpayne@69: * year > month > date > hour (in day) > minute > second > millisecond jpayne@69: * jpayne@69: * The largest different calendar fields between 2 calendars is the jpayne@69: * first different calendar field in above order. jpayne@69: * jpayne@69: * For example: the largest different calendar fields between "Jan 10, 2007" jpayne@69: * and "Feb 20, 2008" is year. jpayne@69: * jpayne@69: *
jpayne@69: * For other calendar fields, the compact interval formatting is not jpayne@69: * supported. And the interval format will be fall back to fall-back jpayne@69: * patterns, which is mostly "{date0} - {date1}". jpayne@69: * jpayne@69: *
jpayne@69: * There is a set of pre-defined static skeleton strings. jpayne@69: * There are pre-defined interval patterns for those pre-defined skeletons jpayne@69: * in locales' resource files. jpayne@69: * For example, for a skeleton UDAT_YEAR_ABBR_MONTH_DAY, which is "yMMMd", jpayne@69: * in en_US, if the largest different calendar field between date1 and date2 jpayne@69: * is "year", the date interval pattern is "MMM d, yyyy - MMM d, yyyy", jpayne@69: * such as "Jan 10, 2007 - Jan 10, 2008". jpayne@69: * If the largest different calendar field between date1 and date2 is "month", jpayne@69: * the date interval pattern is "MMM d - MMM d, yyyy", jpayne@69: * such as "Jan 10 - Feb 10, 2007". jpayne@69: * If the largest different calendar field between date1 and date2 is "day", jpayne@69: * the date interval pattern is "MMM d-d, yyyy", such as "Jan 10-20, 2007". jpayne@69: * jpayne@69: * For date skeleton, the interval patterns when year, or month, or date is jpayne@69: * different are defined in resource files. jpayne@69: * For time skeleton, the interval patterns when am/pm, or hour, or minute is jpayne@69: * different are defined in resource files. jpayne@69: * jpayne@69: *
jpayne@69: * If a skeleton is not found in a locale's DateIntervalInfo, which means jpayne@69: * the interval patterns for the skeleton is not defined in resource file, jpayne@69: * the interval pattern will falls back to the interval "fallback" pattern jpayne@69: * defined in resource file. jpayne@69: * If the interval "fallback" pattern is not defined, the default fall-back jpayne@69: * is "{date0} - {data1}". jpayne@69: * jpayne@69: *
jpayne@69: * For the combination of date and time, jpayne@69: * The rule to generate interval patterns are: jpayne@69: *
jpayne@69: * If two dates are the same, the interval pattern is the single date pattern. jpayne@69: * For example, interval pattern from "Jan 10, 2007" to "Jan 10, 2007" is jpayne@69: * "Jan 10, 2007". jpayne@69: * jpayne@69: * Or if the presenting fields between 2 dates have the exact same values, jpayne@69: * the interval pattern is the single date pattern. jpayne@69: * For example, if user only requests year and month, jpayne@69: * the interval pattern from "Jan 10, 2007" to "Jan 20, 2007" is "Jan 2007". jpayne@69: * jpayne@69: *
jpayne@69: * DateIntervalFormat needs the following information for correct jpayne@69: * formatting: time zone, calendar type, pattern, date format symbols, jpayne@69: * and date interval patterns. jpayne@69: * It can be instantiated in 2 ways: jpayne@69: *
jpayne@69: * For the calendar field pattern letter, such as G, y, M, d, a, h, H, m, s etc. jpayne@69: * DateIntervalFormat uses the same syntax as that of jpayne@69: * DateTime format. jpayne@69: * jpayne@69: *
jpayne@69: * Code Sample: general usage jpayne@69: *
jpayne@69: * \code jpayne@69: * // the date interval object which the DateIntervalFormat formats on jpayne@69: * // and parses into jpayne@69: * DateInterval* dtInterval = new DateInterval(1000*3600*24, 1000*3600*24*2); jpayne@69: * UErrorCode status = U_ZERO_ERROR; jpayne@69: * DateIntervalFormat* dtIntervalFmt = DateIntervalFormat::createInstance( jpayne@69: * UDAT_YEAR_MONTH_DAY, jpayne@69: * Locale("en", "GB", ""), status); jpayne@69: * UnicodeUnicodeString dateIntervalString; jpayne@69: * FieldPosition pos = 0; jpayne@69: * // formatting jpayne@69: * dtIntervalFmt->format(dtInterval, dateIntervalUnicodeString, pos, status); jpayne@69: * delete dtIntervalFmt; jpayne@69: * \endcode jpayne@69: *jpayne@69: */ jpayne@69: class U_I18N_API DateIntervalFormat : public Format { jpayne@69: public: jpayne@69: jpayne@69: /** jpayne@69: * Construct a DateIntervalFormat from skeleton and the default locale. jpayne@69: * jpayne@69: * This is a convenient override of jpayne@69: * createInstance(const UnicodeString& skeleton, const Locale& locale, jpayne@69: * UErrorCode&) jpayne@69: * with the value of locale as default locale. jpayne@69: * jpayne@69: * @param skeleton the skeleton on which interval format based. jpayne@69: * @param status output param set to success/failure code on exit jpayne@69: * @return a date time interval formatter which the caller owns. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: static DateIntervalFormat* U_EXPORT2 createInstance( jpayne@69: const UnicodeString& skeleton, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Construct a DateIntervalFormat from skeleton and a given locale. jpayne@69: *
jpayne@69: * In this factory method, jpayne@69: * the date interval pattern information is load from resource files. jpayne@69: * Users are encouraged to created date interval formatter this way and jpayne@69: * to use the pre-defined skeleton macros. jpayne@69: * jpayne@69: *
jpayne@69: * There are pre-defined skeletons (defined in udate.h) having predefined jpayne@69: * interval patterns in resource files. jpayne@69: * Users are encouraged to use those macros. jpayne@69: * For example: jpayne@69: * DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status) jpayne@69: * jpayne@69: * The given Locale provides the interval patterns. jpayne@69: * For example, for en_GB, if skeleton is UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY, jpayne@69: * which is "yMMMEEEd", jpayne@69: * the interval patterns defined in resource file to above skeleton are: jpayne@69: * "EEE, d MMM, yyyy - EEE, d MMM, yyyy" for year differs, jpayne@69: * "EEE, d MMM - EEE, d MMM, yyyy" for month differs, jpayne@69: * "EEE, d - EEE, d MMM, yyyy" for day differs, jpayne@69: * @param skeleton the skeleton on which the interval format is based. jpayne@69: * @param locale the given locale jpayne@69: * @param status output param set to success/failure code on exit jpayne@69: * @return a date time interval formatter which the caller owns. jpayne@69: * @stable ICU 4.0 jpayne@69: *
jpayne@69: *
jpayne@69: */ jpayne@69: jpayne@69: static DateIntervalFormat* U_EXPORT2 createInstance( jpayne@69: const UnicodeString& skeleton, jpayne@69: const Locale& locale, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Construct a DateIntervalFormat from skeleton jpayne@69: * DateIntervalInfo, and default locale. jpayne@69: * jpayne@69: * This is a convenient override of jpayne@69: * createInstance(const UnicodeString& skeleton, const Locale& locale, jpayne@69: * const DateIntervalInfo& dtitvinf, UErrorCode&) jpayne@69: * with the locale value as default locale. jpayne@69: * jpayne@69: * @param skeleton the skeleton on which interval format based. jpayne@69: * @param dtitvinf the DateIntervalInfo object. jpayne@69: * @param status output param set to success/failure code on exit jpayne@69: * @return a date time interval formatter which the caller owns. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: static DateIntervalFormat* U_EXPORT2 createInstance( jpayne@69: const UnicodeString& skeleton, jpayne@69: const DateIntervalInfo& dtitvinf, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Construct a DateIntervalFormat from skeleton jpayne@69: * a DateIntervalInfo, and the given locale. jpayne@69: * jpayne@69: *
jpayne@69: * In this factory method, user provides its own date interval pattern jpayne@69: * information, instead of using those pre-defined data in resource file. jpayne@69: * This factory method is for powerful users who want to provide their own jpayne@69: * interval patterns. jpayne@69: *
jpayne@69: * There are pre-defined skeletons (defined in udate.h) having predefined jpayne@69: * interval patterns in resource files. jpayne@69: * Users are encouraged to use those macros. jpayne@69: * For example: jpayne@69: * DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status) jpayne@69: * jpayne@69: * The DateIntervalInfo provides the interval patterns. jpayne@69: * and the DateIntervalInfo ownership remains to the caller. jpayne@69: * jpayne@69: * User are encouraged to set default interval pattern in DateIntervalInfo jpayne@69: * as well, if they want to set other interval patterns ( instead of jpayne@69: * reading the interval patterns from resource files). jpayne@69: * When the corresponding interval pattern for a largest calendar different jpayne@69: * field is not found ( if user not set it ), interval format fallback to jpayne@69: * the default interval pattern. jpayne@69: * If user does not provide default interval pattern, it fallback to jpayne@69: * "{date0} - {date1}" jpayne@69: * jpayne@69: * @param skeleton the skeleton on which interval format based. jpayne@69: * @param locale the given locale jpayne@69: * @param dtitvinf the DateIntervalInfo object. jpayne@69: * @param status output param set to success/failure code on exit jpayne@69: * @return a date time interval formatter which the caller owns. jpayne@69: * @stable ICU 4.0 jpayne@69: *
jpayne@69: *
jpayne@69: */ jpayne@69: static DateIntervalFormat* U_EXPORT2 createInstance( jpayne@69: const UnicodeString& skeleton, jpayne@69: const Locale& locale, jpayne@69: const DateIntervalInfo& dtitvinf, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Destructor. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: virtual ~DateIntervalFormat(); jpayne@69: jpayne@69: /** jpayne@69: * Clone this Format object polymorphically. The caller owns the result and jpayne@69: * should delete it when done. jpayne@69: * @return A copy of the object. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: virtual DateIntervalFormat* clone() const; jpayne@69: jpayne@69: /** jpayne@69: * Return true if the given Format objects are semantically equal. Objects jpayne@69: * of different subclasses are considered unequal. jpayne@69: * @param other the object to be compared with. jpayne@69: * @return true if the given Format objects are semantically equal. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: virtual UBool operator==(const Format& other) const; jpayne@69: jpayne@69: /** jpayne@69: * Return true if the given Format objects are not semantically equal. jpayne@69: * Objects of different subclasses are considered unequal. jpayne@69: * @param other the object to be compared with. jpayne@69: * @return true if the given Format objects are not semantically equal. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: UBool operator!=(const Format& other) const; jpayne@69: jpayne@69: jpayne@69: using Format::format; jpayne@69: jpayne@69: /** jpayne@69: * Format an object to produce a string. This method handles Formattable jpayne@69: * objects with a DateInterval type. jpayne@69: * If a the Formattable object type is not a DateInterval, jpayne@69: * then it returns a failing UErrorCode. jpayne@69: * jpayne@69: * @param obj The object to format. jpayne@69: * Must be a DateInterval. jpayne@69: * @param appendTo Output parameter to receive result. jpayne@69: * Result is appended to existing contents. jpayne@69: * @param fieldPosition On input: an alignment field, if desired. jpayne@69: * On output: the offsets of the alignment field. jpayne@69: * There may be multiple instances of a given field type jpayne@69: * in an interval format; in this case the fieldPosition jpayne@69: * offsets refer to the first instance. jpayne@69: * @param status Output param filled with success/failure status. jpayne@69: * @return Reference to 'appendTo' parameter. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: virtual UnicodeString& format(const Formattable& obj, jpayne@69: UnicodeString& appendTo, jpayne@69: FieldPosition& fieldPosition, jpayne@69: UErrorCode& status) const ; jpayne@69: jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Format a DateInterval to produce a string. jpayne@69: * jpayne@69: * @param dtInterval DateInterval to be formatted. jpayne@69: * @param appendTo Output parameter to receive result. jpayne@69: * Result is appended to existing contents. jpayne@69: * @param fieldPosition On input: an alignment field, if desired. jpayne@69: * On output: the offsets of the alignment field. jpayne@69: * There may be multiple instances of a given field type jpayne@69: * in an interval format; in this case the fieldPosition jpayne@69: * offsets refer to the first instance. jpayne@69: * @param status Output param filled with success/failure status. jpayne@69: * @return Reference to 'appendTo' parameter. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: UnicodeString& format(const DateInterval* dtInterval, jpayne@69: UnicodeString& appendTo, jpayne@69: FieldPosition& fieldPosition, jpayne@69: UErrorCode& status) const ; jpayne@69: jpayne@69: /** jpayne@69: * Format a DateInterval to produce a FormattedDateInterval. jpayne@69: * jpayne@69: * The FormattedDateInterval exposes field information about the formatted string. jpayne@69: * jpayne@69: * @param dtInterval DateInterval to be formatted. jpayne@69: * @param status Set if an error occurs. jpayne@69: * @return A FormattedDateInterval containing the format result. jpayne@69: * @stable ICU 64 jpayne@69: */ jpayne@69: FormattedDateInterval formatToValue( jpayne@69: const DateInterval& dtInterval, jpayne@69: UErrorCode& status) const; jpayne@69: jpayne@69: /** jpayne@69: * Format 2 Calendars to produce a string. jpayne@69: * jpayne@69: * Note: "fromCalendar" and "toCalendar" are not const, jpayne@69: * since calendar is not const in SimpleDateFormat::format(Calendar&), jpayne@69: * jpayne@69: * @param fromCalendar calendar set to the from date in date interval jpayne@69: * to be formatted into date interval string jpayne@69: * @param toCalendar calendar set to the to date in date interval jpayne@69: * to be formatted into date interval string jpayne@69: * @param appendTo Output parameter to receive result. jpayne@69: * Result is appended to existing contents. jpayne@69: * @param fieldPosition On input: an alignment field, if desired. jpayne@69: * On output: the offsets of the alignment field. jpayne@69: * There may be multiple instances of a given field type jpayne@69: * in an interval format; in this case the fieldPosition jpayne@69: * offsets refer to the first instance. jpayne@69: * @param status Output param filled with success/failure status. jpayne@69: * Caller needs to make sure it is SUCCESS jpayne@69: * at the function entrance jpayne@69: * @return Reference to 'appendTo' parameter. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: UnicodeString& format(Calendar& fromCalendar, jpayne@69: Calendar& toCalendar, jpayne@69: UnicodeString& appendTo, jpayne@69: FieldPosition& fieldPosition, jpayne@69: UErrorCode& status) const ; jpayne@69: jpayne@69: /** jpayne@69: * Format 2 Calendars to produce a FormattedDateInterval. jpayne@69: * jpayne@69: * The FormattedDateInterval exposes field information about the formatted string. jpayne@69: * jpayne@69: * Note: "fromCalendar" and "toCalendar" are not const, jpayne@69: * since calendar is not const in SimpleDateFormat::format(Calendar&), jpayne@69: * jpayne@69: * @param fromCalendar calendar set to the from date in date interval jpayne@69: * to be formatted into date interval string jpayne@69: * @param toCalendar calendar set to the to date in date interval jpayne@69: * to be formatted into date interval string jpayne@69: * @param status Set if an error occurs. jpayne@69: * @return A FormattedDateInterval containing the format result. jpayne@69: * @stable ICU 64 jpayne@69: */ jpayne@69: FormattedDateInterval formatToValue( jpayne@69: Calendar& fromCalendar, jpayne@69: Calendar& toCalendar, jpayne@69: UErrorCode& status) const; jpayne@69: jpayne@69: /** jpayne@69: * Date interval parsing is not supported. Please do not use. jpayne@69: *
jpayne@69: * This method should handle parsing of jpayne@69: * date time interval strings into Formattable objects with jpayne@69: * DateInterval type, which is a pair of UDate. jpayne@69: *
jpayne@69: * Before calling, set parse_pos.index to the offset you want to start jpayne@69: * parsing at in the source. After calling, parse_pos.index is the end of jpayne@69: * the text you parsed. If error occurs, index is unchanged. jpayne@69: *
jpayne@69: * When parsing, leading whitespace is discarded (with a successful parse), jpayne@69: * while trailing whitespace is left as is. jpayne@69: *
jpayne@69: * See Format::parseObject() for more. jpayne@69: * jpayne@69: * @param source The string to be parsed into an object. jpayne@69: * @param result Formattable to be set to the parse result. jpayne@69: * If parse fails, return contents are undefined. jpayne@69: * @param parse_pos The position to start parsing at. Since no parsing jpayne@69: * is supported, upon return this param is unchanged. jpayne@69: * @return A newly created Formattable* object, or NULL jpayne@69: * on failure. The caller owns this and should jpayne@69: * delete it when done. jpayne@69: * @internal ICU 4.0 jpayne@69: */ jpayne@69: virtual void parseObject(const UnicodeString& source, jpayne@69: Formattable& result, jpayne@69: ParsePosition& parse_pos) const; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Gets the date time interval patterns. jpayne@69: * @return the date time interval patterns associated with jpayne@69: * this date interval formatter. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: const DateIntervalInfo* getDateIntervalInfo(void) const; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Set the date time interval patterns. jpayne@69: * @param newIntervalPatterns the given interval patterns to copy. jpayne@69: * @param status output param set to success/failure code on exit jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: void setDateIntervalInfo(const DateIntervalInfo& newIntervalPatterns, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Gets the date formatter. The DateIntervalFormat instance continues to own jpayne@69: * the returned DateFormatter object, and will use and possibly modify it jpayne@69: * during format operations. In a multi-threaded environment, the returned jpayne@69: * DateFormat can only be used if it is certain that no other threads are jpayne@69: * concurrently using this DateIntervalFormatter, even for nominally const jpayne@69: * functions. jpayne@69: * jpayne@69: * @return the date formatter associated with this date interval formatter. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: const DateFormat* getDateFormat(void) const; jpayne@69: jpayne@69: /** jpayne@69: * Returns a reference to the TimeZone used by this DateIntervalFormat's calendar. jpayne@69: * @return the time zone associated with the calendar of DateIntervalFormat. jpayne@69: * @stable ICU 4.8 jpayne@69: */ jpayne@69: virtual const TimeZone& getTimeZone(void) const; jpayne@69: jpayne@69: /** jpayne@69: * Sets the time zone for the calendar used by this DateIntervalFormat object. The jpayne@69: * caller no longer owns the TimeZone object and should not delete it after this call. jpayne@69: * @param zoneToAdopt the TimeZone to be adopted. jpayne@69: * @stable ICU 4.8 jpayne@69: */ jpayne@69: virtual void adoptTimeZone(TimeZone* zoneToAdopt); jpayne@69: jpayne@69: /** jpayne@69: * Sets the time zone for the calendar used by this DateIntervalFormat object. jpayne@69: * @param zone the new time zone. jpayne@69: * @stable ICU 4.8 jpayne@69: */ jpayne@69: virtual void setTimeZone(const TimeZone& zone); jpayne@69: jpayne@69: /** jpayne@69: * Return the class ID for this class. This is useful only for comparing to jpayne@69: * a return value from getDynamicClassID(). For example: jpayne@69: *
jpayne@69: * . Base* polymorphic_pointer = createPolymorphicObject(); jpayne@69: * . if (polymorphic_pointer->getDynamicClassID() == jpayne@69: * . erived::getStaticClassID()) ... jpayne@69: *jpayne@69: * @return The class ID for all objects of this class. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: static UClassID U_EXPORT2 getStaticClassID(void); jpayne@69: jpayne@69: /** jpayne@69: * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This jpayne@69: * method is to implement a simple version of RTTI, since not all C++ jpayne@69: * compilers support genuine RTTI. Polymorphic operator==() and clone() jpayne@69: * methods call this method. jpayne@69: * jpayne@69: * @return The class ID for this object. All objects of a jpayne@69: * given class have the same class ID. Objects of jpayne@69: * other classes have different class IDs. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: virtual UClassID getDynamicClassID(void) const; jpayne@69: jpayne@69: protected: jpayne@69: jpayne@69: /** jpayne@69: * Copy constructor. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: DateIntervalFormat(const DateIntervalFormat&); jpayne@69: jpayne@69: /** jpayne@69: * Assignment operator. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: DateIntervalFormat& operator=(const DateIntervalFormat&); jpayne@69: jpayne@69: private: jpayne@69: jpayne@69: /* jpayne@69: * This is for ICU internal use only. Please do not use. jpayne@69: * Save the interval pattern information. jpayne@69: * Interval pattern consists of 2 single date patterns and the separator. jpayne@69: * For example, interval pattern "MMM d - MMM d, yyyy" consists jpayne@69: * a single date pattern "MMM d", another single date pattern "MMM d, yyyy", jpayne@69: * and a separator "-". jpayne@69: * The pattern is divided into 2 parts. For above example, jpayne@69: * the first part is "MMM d - ", and the second part is "MMM d, yyyy". jpayne@69: * Also, the first date appears in an interval pattern could be jpayne@69: * the earlier date or the later date. jpayne@69: * And such information is saved in the interval pattern as well. jpayne@69: */ jpayne@69: struct PatternInfo { jpayne@69: UnicodeString firstPart; jpayne@69: UnicodeString secondPart; jpayne@69: /** jpayne@69: * Whether the first date in interval pattern is later date or not. jpayne@69: * Fallback format set the default ordering. jpayne@69: * And for a particular interval pattern, the order can be jpayne@69: * overriden by prefixing the interval pattern with "latestFirst:" or jpayne@69: * "earliestFirst:" jpayne@69: * For example, given 2 date, Jan 10, 2007 to Feb 10, 2007. jpayne@69: * if the fallback format is "{0} - {1}", jpayne@69: * and the pattern is "d MMM - d MMM yyyy", the interval format is jpayne@69: * "10 Jan - 10 Feb, 2007". jpayne@69: * If the pattern is "latestFirst:d MMM - d MMM yyyy", jpayne@69: * the interval format is "10 Feb - 10 Jan, 2007" jpayne@69: */ jpayne@69: UBool laterDateFirst; jpayne@69: }; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * default constructor jpayne@69: * @internal (private) jpayne@69: */ jpayne@69: DateIntervalFormat(); jpayne@69: jpayne@69: /** jpayne@69: * Construct a DateIntervalFormat from DateFormat, jpayne@69: * a DateIntervalInfo, and skeleton. jpayne@69: * DateFormat provides the timezone, calendar, jpayne@69: * full pattern, and date format symbols information. jpayne@69: * It should be a SimpleDateFormat object which jpayne@69: * has a pattern in it. jpayne@69: * the DateIntervalInfo provides the interval patterns. jpayne@69: * jpayne@69: * Note: the DateIntervalFormat takes ownership of both jpayne@69: * DateFormat and DateIntervalInfo objects. jpayne@69: * Caller should not delete them. jpayne@69: * jpayne@69: * @param locale the locale of this date interval formatter. jpayne@69: * @param dtItvInfo the DateIntervalInfo object to be adopted. jpayne@69: * @param skeleton the skeleton of the date formatter jpayne@69: * @param status output param set to success/failure code on exit jpayne@69: */ jpayne@69: DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo, jpayne@69: const UnicodeString* skeleton, UErrorCode& status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Construct a DateIntervalFormat from DateFormat jpayne@69: * and a DateIntervalInfo. jpayne@69: * jpayne@69: * It is a wrapper of the constructor. jpayne@69: * jpayne@69: * @param locale the locale of this date interval formatter. jpayne@69: * @param dtitvinf the DateIntervalInfo object to be adopted. jpayne@69: * @param skeleton the skeleton of this formatter. jpayne@69: * @param status Output param set to success/failure code. jpayne@69: * @return a date time interval formatter which the caller owns. jpayne@69: */ jpayne@69: static DateIntervalFormat* U_EXPORT2 create(const Locale& locale, jpayne@69: DateIntervalInfo* dtitvinf, jpayne@69: const UnicodeString* skeleton, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * Below are for generating interval patterns local to the formatter jpayne@69: */ jpayne@69: jpayne@69: /** Like fallbackFormat, but only formats the range part of the fallback. */ jpayne@69: void fallbackFormatRange( jpayne@69: Calendar& fromCalendar, jpayne@69: Calendar& toCalendar, jpayne@69: UnicodeString& appendTo, jpayne@69: int8_t& firstIndex, jpayne@69: FieldPositionHandler& fphandler, jpayne@69: UErrorCode& status) const; jpayne@69: jpayne@69: /** jpayne@69: * Format 2 Calendars using fall-back interval pattern jpayne@69: * jpayne@69: * The full pattern used in this fall-back format is the jpayne@69: * full pattern of the date formatter. jpayne@69: * jpayne@69: * gFormatterMutex must already be locked when calling this function. jpayne@69: * jpayne@69: * @param fromCalendar calendar set to the from date in date interval jpayne@69: * to be formatted into date interval string jpayne@69: * @param toCalendar calendar set to the to date in date interval jpayne@69: * to be formatted into date interval string jpayne@69: * @param fromToOnSameDay TRUE iff from and to dates are on the same day jpayne@69: * (any difference is in ampm/hours or below) jpayne@69: * @param appendTo Output parameter to receive result. jpayne@69: * Result is appended to existing contents. jpayne@69: * @param firstIndex See formatImpl for more information. jpayne@69: * @param fphandler See formatImpl for more information. jpayne@69: * @param status output param set to success/failure code on exit jpayne@69: * @return Reference to 'appendTo' parameter. jpayne@69: * @internal (private) jpayne@69: */ jpayne@69: UnicodeString& fallbackFormat(Calendar& fromCalendar, jpayne@69: Calendar& toCalendar, jpayne@69: UBool fromToOnSameDay, jpayne@69: UnicodeString& appendTo, jpayne@69: int8_t& firstIndex, jpayne@69: FieldPositionHandler& fphandler, jpayne@69: UErrorCode& status) const; jpayne@69: jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Initialize interval patterns locale to this formatter jpayne@69: * jpayne@69: * This code is a bit complicated since jpayne@69: * 1. the interval patterns saved in resource bundle files are interval jpayne@69: * patterns based on date or time only. jpayne@69: * It does not have interval patterns based on both date and time. jpayne@69: * Interval patterns on both date and time are algorithm generated. jpayne@69: * jpayne@69: * For example, it has interval patterns on skeleton "dMy" and "hm", jpayne@69: * but it does not have interval patterns on skeleton "dMyhm". jpayne@69: * jpayne@69: * The rule to generate interval patterns for both date and time skeleton are jpayne@69: * 1) when the year, month, or day differs, concatenate the two original jpayne@69: * expressions with a separator between, jpayne@69: * For example, interval pattern from "Jan 10, 2007 10:10 am" jpayne@69: * to "Jan 11, 2007 10:10am" is jpayne@69: * "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am" jpayne@69: * jpayne@69: * 2) otherwise, present the date followed by the range expression jpayne@69: * for the time. jpayne@69: * For example, interval pattern from "Jan 10, 2007 10:10 am" jpayne@69: * to "Jan 10, 2007 11:10am" is jpayne@69: * "Jan 10, 2007 10:10 am - 11:10am" jpayne@69: * jpayne@69: * 2. even a pattern does not request a certain calendar field, jpayne@69: * the interval pattern needs to include such field if such fields are jpayne@69: * different between 2 dates. jpayne@69: * For example, a pattern/skeleton is "hm", but the interval pattern jpayne@69: * includes year, month, and date when year, month, and date differs. jpayne@69: * jpayne@69: * jpayne@69: * @param status output param set to success/failure code on exit jpayne@69: */ jpayne@69: void initializePattern(UErrorCode& status); jpayne@69: jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Set fall back interval pattern given a calendar field, jpayne@69: * a skeleton, and a date time pattern generator. jpayne@69: * @param field the largest different calendar field jpayne@69: * @param skeleton a skeleton jpayne@69: * @param status output param set to success/failure code on exit jpayne@69: */ jpayne@69: void setFallbackPattern(UCalendarDateFields field, jpayne@69: const UnicodeString& skeleton, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * get separated date and time skeleton from a combined skeleton. jpayne@69: * jpayne@69: * The difference between date skeleton and normalizedDateSkeleton are: jpayne@69: * 1. both 'y' and 'd' are appeared only once in normalizeDateSkeleton jpayne@69: * 2. 'E' and 'EE' are normalized into 'EEE' jpayne@69: * 3. 'MM' is normalized into 'M' jpayne@69: * jpayne@69: ** the difference between time skeleton and normalizedTimeSkeleton are: jpayne@69: * 1. both 'H' and 'h' are normalized as 'h' in normalized time skeleton, jpayne@69: * 2. 'a' is omitted in normalized time skeleton. jpayne@69: * 3. there is only one appearance for 'h', 'm','v', 'z' in normalized time jpayne@69: * skeleton jpayne@69: * jpayne@69: * jpayne@69: * @param skeleton given combined skeleton. jpayne@69: * @param date Output parameter for date only skeleton. jpayne@69: * @param normalizedDate Output parameter for normalized date only jpayne@69: * jpayne@69: * @param time Output parameter for time only skeleton. jpayne@69: * @param normalizedTime Output parameter for normalized time only jpayne@69: * skeleton. jpayne@69: * jpayne@69: */ jpayne@69: static void U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton, jpayne@69: UnicodeString& date, jpayne@69: UnicodeString& normalizedDate, jpayne@69: UnicodeString& time, jpayne@69: UnicodeString& normalizedTime); jpayne@69: jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Generate date or time interval pattern from resource, jpayne@69: * and set them into the interval pattern locale to this formatter. jpayne@69: * jpayne@69: * It needs to handle the following: jpayne@69: * 1. need to adjust field width. jpayne@69: * For example, the interval patterns saved in DateIntervalInfo jpayne@69: * includes "dMMMy", but not "dMMMMy". jpayne@69: * Need to get interval patterns for dMMMMy from dMMMy. jpayne@69: * Another example, the interval patterns saved in DateIntervalInfo jpayne@69: * includes "hmv", but not "hmz". jpayne@69: * Need to get interval patterns for "hmz' from 'hmv' jpayne@69: * jpayne@69: * 2. there might be no pattern for 'y' differ for skeleton "Md", jpayne@69: * in order to get interval patterns for 'y' differ, jpayne@69: * need to look for it from skeleton 'yMd' jpayne@69: * jpayne@69: * @param dateSkeleton normalized date skeleton jpayne@69: * @param timeSkeleton normalized time skeleton jpayne@69: * @return whether the resource is found for the skeleton. jpayne@69: * TRUE if interval pattern found for the skeleton, jpayne@69: * FALSE otherwise. jpayne@69: */ jpayne@69: UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton, jpayne@69: const UnicodeString& timeSkeleton); jpayne@69: jpayne@69: jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Generate interval pattern from existing resource jpayne@69: * jpayne@69: * It not only save the interval patterns, jpayne@69: * but also return the extended skeleton and its best match skeleton. jpayne@69: * jpayne@69: * @param field largest different calendar field jpayne@69: * @param skeleton skeleton jpayne@69: * @param bestSkeleton the best match skeleton which has interval pattern jpayne@69: * defined in resource jpayne@69: * @param differenceInfo the difference between skeleton and best skeleton jpayne@69: * 0 means the best matched skeleton is the same as input skeleton jpayne@69: * 1 means the fields are the same, but field width are different jpayne@69: * 2 means the only difference between fields are v/z, jpayne@69: * -1 means there are other fields difference jpayne@69: * jpayne@69: * @param extendedSkeleton extended skeleton jpayne@69: * @param extendedBestSkeleton extended best match skeleton jpayne@69: * @return whether the interval pattern is found jpayne@69: * through extending skeleton or not. jpayne@69: * TRUE if interval pattern is found by jpayne@69: * extending skeleton, FALSE otherwise. jpayne@69: */ jpayne@69: UBool setIntervalPattern(UCalendarDateFields field, jpayne@69: const UnicodeString* skeleton, jpayne@69: const UnicodeString* bestSkeleton, jpayne@69: int8_t differenceInfo, jpayne@69: UnicodeString* extendedSkeleton = NULL, jpayne@69: UnicodeString* extendedBestSkeleton = NULL); jpayne@69: jpayne@69: /** jpayne@69: * Adjust field width in best match interval pattern to match jpayne@69: * the field width in input skeleton. jpayne@69: * jpayne@69: * TODO (xji) make a general solution jpayne@69: * The adjusting rule can be: jpayne@69: * 1. always adjust jpayne@69: * 2. never adjust jpayne@69: * 3. default adjust, which means adjust according to the following rules jpayne@69: * 3.1 always adjust string, such as MMM and MMMM jpayne@69: * 3.2 never adjust between string and numeric, such as MM and MMM jpayne@69: * 3.3 always adjust year jpayne@69: * 3.4 do not adjust 'd', 'h', or 'm' if h presents jpayne@69: * 3.5 do not adjust 'M' if it is numeric(?) jpayne@69: * jpayne@69: * Since date interval format is well-formed format, jpayne@69: * date and time skeletons are normalized previously, jpayne@69: * till this stage, the adjust here is only "adjust strings, such as MMM jpayne@69: * and MMMM, EEE and EEEE. jpayne@69: * jpayne@69: * @param inputSkeleton the input skeleton jpayne@69: * @param bestMatchSkeleton the best match skeleton jpayne@69: * @param bestMatchIntervalPattern the best match interval pattern jpayne@69: * @param differenceInfo the difference between 2 skeletons jpayne@69: * 1 means only field width differs jpayne@69: * 2 means v/z exchange jpayne@69: * @param adjustedIntervalPattern adjusted interval pattern jpayne@69: */ jpayne@69: static void U_EXPORT2 adjustFieldWidth( jpayne@69: const UnicodeString& inputSkeleton, jpayne@69: const UnicodeString& bestMatchSkeleton, jpayne@69: const UnicodeString& bestMatchIntervalPattern, jpayne@69: int8_t differenceInfo, jpayne@69: UnicodeString& adjustedIntervalPattern); jpayne@69: jpayne@69: /** jpayne@69: * Concat a single date pattern with a time interval pattern, jpayne@69: * set it into the intervalPatterns, while field is time field. jpayne@69: * This is used to handle time interval patterns on skeleton with jpayne@69: * both time and date. Present the date followed by jpayne@69: * the range expression for the time. jpayne@69: * @param format date and time format jpayne@69: * @param datePattern date pattern jpayne@69: * @param field time calendar field: AM_PM, HOUR, MINUTE jpayne@69: * @param status output param set to success/failure code on exit jpayne@69: */ jpayne@69: void concatSingleDate2TimeInterval(UnicodeString& format, jpayne@69: const UnicodeString& datePattern, jpayne@69: UCalendarDateFields field, jpayne@69: UErrorCode& status); jpayne@69: jpayne@69: /** jpayne@69: * check whether a calendar field present in a skeleton. jpayne@69: * @param field calendar field need to check jpayne@69: * @param skeleton given skeleton on which to check the calendar field jpayne@69: * @return true if field present in a skeleton. jpayne@69: */ jpayne@69: static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field, jpayne@69: const UnicodeString& skeleton); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Split interval patterns into 2 part. jpayne@69: * @param intervalPattern interval pattern jpayne@69: * @return the index in interval pattern which split the pattern into 2 part jpayne@69: */ jpayne@69: static int32_t U_EXPORT2 splitPatternInto2Part(const UnicodeString& intervalPattern); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Break interval patterns as 2 part and save them into pattern info. jpayne@69: * @param field calendar field jpayne@69: * @param intervalPattern interval pattern jpayne@69: */ jpayne@69: void setIntervalPattern(UCalendarDateFields field, jpayne@69: const UnicodeString& intervalPattern); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Break interval patterns as 2 part and save them into pattern info. jpayne@69: * @param field calendar field jpayne@69: * @param intervalPattern interval pattern jpayne@69: * @param laterDateFirst whether later date appear first in interval pattern jpayne@69: */ jpayne@69: void setIntervalPattern(UCalendarDateFields field, jpayne@69: const UnicodeString& intervalPattern, jpayne@69: UBool laterDateFirst); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Set pattern information. jpayne@69: * jpayne@69: * @param field calendar field jpayne@69: * @param firstPart the first part in interval pattern jpayne@69: * @param secondPart the second part in interval pattern jpayne@69: * @param laterDateFirst whether the first date in intervalPattern jpayne@69: * is earlier date or later date jpayne@69: */ jpayne@69: void setPatternInfo(UCalendarDateFields field, jpayne@69: const UnicodeString* firstPart, jpayne@69: const UnicodeString* secondPart, jpayne@69: UBool laterDateFirst); jpayne@69: jpayne@69: /** jpayne@69: * Format 2 Calendars to produce a string. jpayne@69: * Implementation of the similar public format function. jpayne@69: * Must be called with gFormatterMutex already locked. jpayne@69: * jpayne@69: * Note: "fromCalendar" and "toCalendar" are not const, jpayne@69: * since calendar is not const in SimpleDateFormat::format(Calendar&), jpayne@69: * jpayne@69: * @param fromCalendar calendar set to the from date in date interval jpayne@69: * to be formatted into date interval string jpayne@69: * @param toCalendar calendar set to the to date in date interval jpayne@69: * to be formatted into date interval string jpayne@69: * @param appendTo Output parameter to receive result. jpayne@69: * Result is appended to existing contents. jpayne@69: * @param firstIndex 0 if the first output date is fromCalendar; jpayne@69: * 1 if it corresponds to toCalendar; jpayne@69: * -1 if there is only one date printed. jpayne@69: * @param fphandler Handler for field position information. jpayne@69: * The fields will be from the UDateFormatField enum. jpayne@69: * @param status Output param filled with success/failure status. jpayne@69: * Caller needs to make sure it is SUCCESS jpayne@69: * at the function entrance jpayne@69: * @return Reference to 'appendTo' parameter. jpayne@69: * @internal (private) jpayne@69: */ jpayne@69: UnicodeString& formatImpl(Calendar& fromCalendar, jpayne@69: Calendar& toCalendar, jpayne@69: UnicodeString& appendTo, jpayne@69: int8_t& firstIndex, jpayne@69: FieldPositionHandler& fphandler, jpayne@69: UErrorCode& status) const ; jpayne@69: jpayne@69: /** Version of formatImpl for DateInterval. */ jpayne@69: UnicodeString& formatIntervalImpl(const DateInterval& dtInterval, jpayne@69: UnicodeString& appendTo, jpayne@69: int8_t& firstIndex, jpayne@69: FieldPositionHandler& fphandler, jpayne@69: UErrorCode& status) const; jpayne@69: jpayne@69: jpayne@69: // from calendar field to pattern letter jpayne@69: static const char16_t fgCalendarFieldToPatternLetter[]; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * The interval patterns for this locale. jpayne@69: */ jpayne@69: DateIntervalInfo* fInfo; jpayne@69: jpayne@69: /** jpayne@69: * The DateFormat object used to format single pattern jpayne@69: */ jpayne@69: SimpleDateFormat* fDateFormat; jpayne@69: jpayne@69: /** jpayne@69: * The 2 calendars with the from and to date. jpayne@69: * could re-use the calendar in fDateFormat, jpayne@69: * but keeping 2 calendars make it clear and clean. jpayne@69: */ jpayne@69: Calendar* fFromCalendar; jpayne@69: Calendar* fToCalendar; jpayne@69: jpayne@69: Locale fLocale; jpayne@69: jpayne@69: /** jpayne@69: * Following are interval information relevant (locale) to this formatter. jpayne@69: */ jpayne@69: UnicodeString fSkeleton; jpayne@69: PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX]; jpayne@69: jpayne@69: /** jpayne@69: * Patterns for fallback formatting. jpayne@69: */ jpayne@69: UnicodeString* fDatePattern; jpayne@69: UnicodeString* fTimePattern; jpayne@69: UnicodeString* fDateTimeFormat; jpayne@69: }; jpayne@69: jpayne@69: inline UBool jpayne@69: DateIntervalFormat::operator!=(const Format& other) const { jpayne@69: return !operator==(other); jpayne@69: } jpayne@69: jpayne@69: U_NAMESPACE_END jpayne@69: jpayne@69: #endif /* #if !UCONFIG_NO_FORMATTING */ jpayne@69: jpayne@69: #endif /* U_SHOW_CPLUSPLUS_API */ jpayne@69: jpayne@69: #endif // _DTITVFMT_H__ jpayne@69: //eof