Index: source/i18n/unicode/dtitvfmt.h |
diff --git a/source/i18n/unicode/dtitvfmt.h b/source/i18n/unicode/dtitvfmt.h |
index fb27eec48158d2e8bbf1b7584f24c95d82bdd85f..d163bad60f4c127bd382f171667fa5e9b23e25c7 100644 |
--- a/source/i18n/unicode/dtitvfmt.h |
+++ b/source/i18n/unicode/dtitvfmt.h |
@@ -1,5 +1,5 @@ |
/******************************************************************************** |
-* Copyright (C) 2008-2013, International Business Machines Corporation and |
+* Copyright (C) 2008-2013,2015, International Business Machines Corporation and |
* others. All Rights Reserved. |
******************************************************************************* |
* |
@@ -93,9 +93,11 @@ U_NAMESPACE_BEGIN |
* |
* <P> |
* The calendar fields we support for interval formatting are: |
- * year, month, date, day-of-week, am-pm, hour, hour-of-day, and minute. |
+ * year, month, date, day-of-week, am-pm, hour, hour-of-day, minute, and second |
+ * (though we do not currently have specific intervalFormat date for skeletons |
+ * with seconds). |
* Those calendar fields can be defined in the following order: |
- * year > month > date > hour (in day) > minute |
+ * year > month > date > hour (in day) > minute > second |
* |
* The largest different calendar fields between 2 calendars is the |
* first different calendar field in above order. |
@@ -387,6 +389,9 @@ public: |
* Result is appended to existing contents. |
* @param fieldPosition On input: an alignment field, if desired. |
* On output: the offsets of the alignment field. |
+ * There may be multiple instances of a given field type |
+ * in an interval format; in this case the fieldPosition |
+ * offsets refer to the first instance. |
* @param status Output param filled with success/failure status. |
* @return Reference to 'appendTo' parameter. |
* @stable ICU 4.0 |
@@ -406,6 +411,9 @@ public: |
* Result is appended to existing contents. |
* @param fieldPosition On input: an alignment field, if desired. |
* On output: the offsets of the alignment field. |
+ * There may be multiple instances of a given field type |
+ * in an interval format; in this case the fieldPosition |
+ * offsets refer to the first instance. |
* @param status Output param filled with success/failure status. |
* @return Reference to 'appendTo' parameter. |
* @stable ICU 4.0 |
@@ -430,6 +438,9 @@ public: |
* Result is appended to existing contents. |
* @param fieldPosition On input: an alignment field, if desired. |
* On output: the offsets of the alignment field. |
+ * There may be multiple instances of a given field type |
+ * in an interval format; in this case the fieldPosition |
+ * offsets refer to the first instance. |
* @param status Output param filled with success/failure status. |
* Caller needs to make sure it is SUCCESS |
* at the function entrance |
@@ -642,27 +653,30 @@ private: |
UErrorCode& status); |
/** |
- * Create a simple date/time formatter from skeleton, given locale, |
- * and date time pattern generator. |
- * |
- * @param skeleton the skeleton on which date format based. |
- * @param locale the given locale. |
- * @param dtpng the date time pattern generator. |
- * @param status Output param to be set to success/failure code. |
- * If it is failure, the returned date formatter will |
- * be NULL. |
- * @return a simple date formatter which the caller owns. |
+ * Below are for generating interval patterns local to the formatter |
*/ |
- static SimpleDateFormat* U_EXPORT2 createSDFPatternInstance( |
- const UnicodeString& skeleton, |
- const Locale& locale, |
- DateTimePatternGenerator* dtpng, |
- UErrorCode& status); |
- |
/** |
- * Below are for generating interval patterns local to the formatter |
+ * Provide an updated FieldPosition posResult based on two formats, |
+ * the FieldPosition values for each of them, and the pattern used |
+ * to combine them. The idea is for posResult to indicate the first |
+ * instance (if any) of the specified field in the combined result, |
+ * with correct offsets. |
+ * |
+ * @param combiningPattern Pattern used to combine pat0 and pat1 |
+ * @param pat0 Formatted date/time value to replace {0} |
+ * @param pos0 FieldPosition within pat0 |
+ * @param pat1 Formatted date/time value to replace {1} |
+ * @param pos1 FieldPosition within pat1 |
+ * @param posResult FieldPosition to be set to the correct |
+ * position of the first field instance when |
+ * pat0 and pat1 are combined using combiningPattern |
*/ |
+ static void |
+ adjustPosition(UnicodeString& combiningPattern, // has {0} and {1} in it |
+ UnicodeString& pat0, FieldPosition& pos0, // pattern and pos corresponding to {0} |
+ UnicodeString& pat1, FieldPosition& pos1, // pattern and pos corresponding to {1} |
+ FieldPosition& posResult); |
/** |
@@ -675,6 +689,8 @@ private: |
* to be formatted into date interval string |
* @param toCalendar calendar set to the to date in date interval |
* to be formatted into date interval string |
+ * @param fromToOnSameDay TRUE iff from and to dates are on the same day |
+ * (any difference is in ampm/hours or below) |
* @param appendTo Output parameter to receive result. |
* Result is appended to existing contents. |
* @param pos On input: an alignment field, if desired. |
@@ -684,6 +700,7 @@ private: |
*/ |
UnicodeString& fallbackFormat(Calendar& fromCalendar, |
Calendar& toCalendar, |
+ UBool fromToOnSameDay, |
UnicodeString& appendTo, |
FieldPosition& pos, |
UErrorCode& status) const; |
@@ -874,13 +891,11 @@ private: |
* both time and date. Present the date followed by |
* the range expression for the time. |
* @param format date and time format |
- * @param formatLen format string length |
* @param datePattern date pattern |
* @param field time calendar field: AM_PM, HOUR, MINUTE |
* @param status output param set to success/failure code on exit |
*/ |
- void concatSingleDate2TimeInterval(const UChar* format, |
- int32_t formatLen, |
+ void concatSingleDate2TimeInterval(UnicodeString& format, |
const UnicodeString& datePattern, |
UCalendarDateFields field, |
UErrorCode& status); |
@@ -960,16 +975,20 @@ private: |
Calendar* fFromCalendar; |
Calendar* fToCalendar; |
- /** |
- * Date time pattern generator |
- */ |
- DateTimePatternGenerator* fDtpng; |
+ Locale fLocale; |
/** |
- * Following are interval information relavent (locale) to this formatter. |
+ * Following are interval information relevant (locale) to this formatter. |
*/ |
UnicodeString fSkeleton; |
PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX]; |
+ |
+ /** |
+ * Patterns for fallback formatting. |
+ */ |
+ UnicodeString* fDatePattern; |
+ UnicodeString* fTimePattern; |
+ UnicodeString* fDateTimeFormat; |
}; |
inline UBool |