From 4a4907c1eb8b4f465ba59a8911aad891bd2249b4 Mon Sep 17 00:00:00 2001 From: Travis Keep Date: Tue, 11 Mar 2014 23:14:05 +0000 Subject: [PATCH] ICU-10703 Deprecate timeUnitFormat. X-SVN-Rev: 35419 --- icu4c/source/i18n/measfmt.cpp | 13 +++++++++++-- icu4c/source/i18n/unicode/tmutfmt.h | 23 ++++++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/icu4c/source/i18n/measfmt.cpp b/icu4c/source/i18n/measfmt.cpp index 5c0b55298b6..a7387b03f63 100644 --- a/icu4c/source/i18n/measfmt.cpp +++ b/icu4c/source/i18n/measfmt.cpp @@ -373,6 +373,13 @@ static UBool getFromCache( return U_SUCCESS(status); } +// Converts a composite measure into hours-minutes-seconds and stores at hms +// array. [0] is hours; [1] is minutes; [2] is seconds. Returns a bit map of +// units found: 1=hours, 2=minutes, 4=seconds. For example, if measures +// contains hours-minutes, this function would return 3. +// +// If measures cannot be converted into hours, minutes, seconds or if amounts +// are negative, or if hours, minutes, seconds are out of order, returns 0. static int32_t toHMS( const Measure *measures, int32_t measureCount, @@ -735,6 +742,7 @@ UnicodeString &MeasureFormat::formatMeasure( status); } +// Formats hours-minutes-seconds as 5:37:23 or similar. UnicodeString &MeasureFormat::formatNumeric( const Formattable *hms, // always length 3 int32_t bitMap, // 1=hourset, 2=minuteset, 4=secondset @@ -799,11 +807,12 @@ static void appendRange( dest.append(src, end, src.length() - end); } +// Formats time like 5:37:23 UnicodeString &MeasureFormat::formatNumeric( UDate date, // Time since epoch 1:30:00 would be 5400000 const DateFormat &dateFmt, // h:mm, m:ss, or h:mm:ss - UDateFormatField smallestField, - const Formattable &smallestAmount, + UDateFormatField smallestField, // seconds in 5:37:23.5 + const Formattable &smallestAmount, // 23.5 for 5:37:23.5 UnicodeString &appendTo, UErrorCode &status) const { if (U_FAILURE(status)) { diff --git a/icu4c/source/i18n/unicode/tmutfmt.h b/icu4c/source/i18n/unicode/tmutfmt.h index e1fde7255fc..f20e9200d02 100644 --- a/icu4c/source/i18n/unicode/tmutfmt.h +++ b/icu4c/source/i18n/unicode/tmutfmt.h @@ -25,28 +25,35 @@ #include "unicode/numfmt.h" #include "unicode/plurrule.h" +#ifndef U_HIDE_DEPRECATED_API + /** * Constants for various styles. * There are 2 styles: full name and abbreviated name. * For example, for English, the full name for hour duration is "3 hours", * and the abbreviated name is "3 hrs". - * @stable ICU 4.8 + * @deprecated ICU 53 Use MeasureFormat and UMeasureFormatWidth instead. */ enum UTimeUnitFormatStyle { - /** @stable ICU 4.8 */ + /** @deprecated ICU 53 */ UTMUTFMT_FULL_STYLE, - /** @stable ICU 4.8 */ + /** @deprecated ICU 53 */ UTMUTFMT_ABBREVIATED_STYLE, - /** @stable ICU 4.8 */ + /** @deprecated ICU 53 */ UTMUTFMT_FORMAT_STYLE_COUNT }; -typedef enum UTimeUnitFormatStyle UTimeUnitFormatStyle; /**< @stable ICU 4.8 */ +typedef enum UTimeUnitFormatStyle UTimeUnitFormatStyle; /**< @deprecated ICU 53 */ + +#endif + U_NAMESPACE_BEGIN class Hashtable; class UVector; +#ifndef U_HIDE_DEPRECATED_API + /** * Format or parse a TimeUnitAmount, using plural rules for the units where available. * @@ -75,7 +82,7 @@ class UVector; *

* @see TimeUnitAmount * @see TimeUnitFormat - * @stable ICU 4.2 + * @deprecated ICU 53 Use the MeasureFormat class instead. */ class U_I18N_API TimeUnitFormat: public MeasureFormat { public: @@ -226,14 +233,12 @@ private: }; - - inline UBool TimeUnitFormat::operator!=(const Format& other) const { return !operator==(other); } - +#endif /* U_HIDE_DEPRECATED_API */ U_NAMESPACE_END -- 2.40.0