From 685ba04d7a0978cb82129aa013280e9ec8d1ca00 Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Thu, 11 Mar 2004 13:59:09 +0000 Subject: [PATCH] ICU-3391 move FieldPosition selectors to udat X-SVN-Rev: 14679 --- icu4c/source/i18n/unicode/datefmt.h | 129 ++++++++++++---------------- icu4c/source/i18n/unicode/udat.h | 56 ++++++------ 2 files changed, 86 insertions(+), 99 deletions(-) diff --git a/icu4c/source/i18n/unicode/datefmt.h b/icu4c/source/i18n/unicode/datefmt.h index 22b82eebff..bb7775f773 100644 --- a/icu4c/source/i18n/unicode/datefmt.h +++ b/icu4c/source/i18n/unicode/datefmt.h @@ -23,6 +23,7 @@ #if !UCONFIG_NO_FORMATTING +#include "unicode/udat.h" #include "unicode/calendar.h" #include "unicode/numfmt.h" #include "unicode/format.h" @@ -126,76 +127,6 @@ class TimeZone; */ class U_I18N_API DateFormat : public Format { public: - /** - * The following enum values are used in FieldPosition with date/time formatting. - * They are also used to index into DateFormatSymbols::fgPatternChars, which - * is the list of standard internal-representation pattern characters, and - * the resource bundle localPatternChars data. For this reason, this enum - * should be treated with care; don't change the order or contents of it - * unless you really know what you are doing. You'll probably have to change - * the code in DateFormatSymbols, SimpleDateFormat, and all the locale - * resource bundle data files. - * @draft ICU 2.4 - */ - enum EField - { - kEraField = 0, // ERA field alignment. - kYearField, // YEAR field alignment. - kMonthField, // MONTH field alignment. - kDateField, // DATE field alignment. - kHourOfDay1Field, // One-based HOUR_OF_DAY field alignment. - // kHourOfDay1Field is used for the one-based 24-hour clock. - // For example, 23:59 + 01:00 results in 24:59. - kHourOfDay0Field, // Zero-based HOUR_OF_DAY field alignment. - // HOUR_OF_DAY0_FIELD is used for the zero-based 24-hour clock. - // For example, 23:59 + 01:00 results in 00:59. - kMinuteField, // MINUTE field alignment. - kSecondField, // SECOND field alignment. - kMillisecondField, // MILLISECOND field alignment. - kDayOfWeekField, // DAY_OF_WEEK field alignment. - kDayOfYearField, // DAY_OF_YEAR field alignment. - kDayOfWeekInMonthField,// DAY_OF_WEEK_IN_MONTH field alignment. - kWeekOfYearField, // WEEK_OF_YEAR field alignment. - kWeekOfMonthField, // WEEK_OF_MONTH field alignment. - kAmPmField, // AM_PM field alignment. - kHour1Field, // One-based HOUR field alignment. - // HOUR1_FIELD is used for the one-based 12-hour clock. - // For example, 11:30 PM + 1 hour results in 12:30 AM. - kHour0Field, // Zero-based HOUR field alignment. - // HOUR0_FIELD is used for the zero-based 12-hour clock. - // For example, 11:30 PM + 1 hour results in 00:30 AM. - kTimezoneField, // TIMEZONE field alignment. - kYearWOYField, // Corrected year for week representation - kDOWLocalField, // localized day of week - kExtendedYearField, - kJulianDayField, - kMillisecondsInDayField, - - - /** - * These constants are provided for backwards compatibility only. - * Please use the C++ style constants defined above. - */ - ERA_FIELD = kEraField, - YEAR_FIELD = kYearField, - MONTH_FIELD = kMonthField, - DATE_FIELD = kDateField, - HOUR_OF_DAY1_FIELD = kHourOfDay1Field, - HOUR_OF_DAY0_FIELD = kHourOfDay0Field, - MINUTE_FIELD = kMinuteField, - SECOND_FIELD = kSecondField, - MILLISECOND_FIELD = kMillisecondField, - DAY_OF_WEEK_FIELD = kDayOfWeekField, - DAY_OF_YEAR_FIELD = kDayOfYearField, - DAY_OF_WEEK_IN_MONTH_FIELD = kDayOfWeekInMonthField, - WEEK_OF_YEAR_FIELD = kWeekOfYearField, - WEEK_OF_MONTH_FIELD = kWeekOfMonthField, - AM_PM_FIELD = kAmPmField, - HOUR1_FIELD = kHour1Field, - HOUR0_FIELD = kHour0Field, - TIMEZONE_FIELD = kTimezoneField - - }; /** * Constants for various style patterns. These reflect the order of items in @@ -279,7 +210,7 @@ public: * in with the text offsets for that field. *

For example, given a time text * "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition.field is - * DateFormat::kYearField, the offsets fieldPosition.beginIndex and + * UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and * statfieldPositionus.getEndIndex will be set to 0 and 4, respectively. *

Notice * that if the same time field appears more than once in a pattern, the status will @@ -311,7 +242,7 @@ public: * in with the text offsets for that field. *

For example, given a time text * "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition.field is - * DateFormat::kYearField, the offsets fieldPosition.beginIndex and + * UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and * statfieldPositionus.getEndIndex will be set to 0 and 4, respectively. *

Notice * that if the same time field appears more than once in a pattern, the status will @@ -649,6 +580,60 @@ private: * @return a date/time formatter, or 0 on failure. */ static DateFormat* create(EStyle timeStyle, EStyle dateStyle, const Locale&); + +public: + /** + * Field selector for FieldPosition for DateFormat fields. + * @obsolete ICU 3.4 use UDateFormatField instead, since this API will be + * removed in that release + */ + enum EField + { + // Obsolete; use UDateFormatField instead + kEraField = UDAT_ERA_FIELD, + kYearField = UDAT_YEAR_FIELD, + kMonthField = UDAT_MONTH_FIELD, + kDateField = UDAT_DATE_FIELD, + kHourOfDay1Field = UDAT_HOUR_OF_DAY1_FIELD, + kHourOfDay0Field = UDAT_HOUR_OF_DAY0_FIELD, + kMinuteField = UDAT_MINUTE_FIELD, + kSecondField = UDAT_SECOND_FIELD, + kMillisecondField = UDAT_FRACTIONAL_SECOND_FIELD, + kDayOfWeekField = UDAT_DAY_OF_WEEK_FIELD, + kDayOfYearField = UDAT_DAY_OF_YEAR_FIELD, + kDayOfWeekInMonthField = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD, + kWeekOfYearField = UDAT_WEEK_OF_YEAR_FIELD, + kWeekOfMonthField = UDAT_WEEK_OF_MONTH_FIELD, + kAmPmField = UDAT_AM_PM_FIELD, + kHour1Field = UDAT_HOUR1_FIELD, + kHour0Field = UDAT_HOUR0_FIELD, + kTimezoneField = UDAT_TIMEZONE_FIELD, + kYearWOYField = UDAT_YEAR_WOY_FIELD, + kDOWLocalField = UDAT_DOW_LOCAL_FIELD, + kExtendedYearField = UDAT_EXTENDED_YEAR_FIELD, + kJulianDayField = UDAT_JULIAN_DAY_FIELD, + kMillisecondsInDayField = UDAT_MILLISECONDS_IN_DAY_FIELD, + + // Obsolete; use UDateFormatField instead + ERA_FIELD = UDAT_ERA_FIELD, + YEAR_FIELD = UDAT_YEAR_FIELD, + MONTH_FIELD = UDAT_MONTH_FIELD, + DATE_FIELD = UDAT_DATE_FIELD, + HOUR_OF_DAY1_FIELD = UDAT_HOUR_OF_DAY1_FIELD, + HOUR_OF_DAY0_FIELD = UDAT_HOUR_OF_DAY0_FIELD, + MINUTE_FIELD = UDAT_MINUTE_FIELD, + SECOND_FIELD = UDAT_SECOND_FIELD, + MILLISECOND_FIELD = UDAT_FRACTIONAL_SECOND_FIELD, + DAY_OF_WEEK_FIELD = UDAT_DAY_OF_WEEK_FIELD, + DAY_OF_YEAR_FIELD = UDAT_DAY_OF_YEAR_FIELD, + DAY_OF_WEEK_IN_MONTH_FIELD = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD, + WEEK_OF_YEAR_FIELD = UDAT_WEEK_OF_YEAR_FIELD, + WEEK_OF_MONTH_FIELD = UDAT_WEEK_OF_MONTH_FIELD, + AM_PM_FIELD = UDAT_AM_PM_FIELD, + HOUR1_FIELD = UDAT_HOUR1_FIELD, + HOUR0_FIELD = UDAT_HOUR0_FIELD, + TIMEZONE_FIELD = UDAT_TIMEZONE_FIELD + }; }; inline UnicodeString& diff --git a/icu4c/source/i18n/unicode/udat.h b/icu4c/source/i18n/unicode/udat.h index 72b5bc937f..d42a5dbe5c 100644 --- a/icu4c/source/i18n/unicode/udat.h +++ b/icu4c/source/i18n/unicode/udat.h @@ -158,40 +158,41 @@ typedef enum UDateFormatStyle { } UDateFormatStyle; /** - * UFieldPosition selectors for format fields defined by UDateFormat. + * FieldPosition and UFieldPosition selectors for format fields + * defined by DateFormat and UDateFormat. * @draft ICU 3.0 */ typedef enum UDateFormatField { /** - * UFieldPosition selector for 'G' field alignment, + * FieldPosition and UFieldPosition selector for 'G' field alignment, * corresponding to the UCAL_ERA field. * @draft ICU 3.0 */ UDAT_ERA_FIELD = 0, /** - * UFieldPosition selector for 'y' field alignment, + * FieldPosition and UFieldPosition selector for 'y' field alignment, * corresponding to the UCAL_YEAR field. * @draft ICU 3.0 */ UDAT_YEAR_FIELD = 1, /** - * UFieldPosition selector for 'M' field alignment, + * FieldPosition and UFieldPosition selector for 'M' field alignment, * corresponding to the UCAL_MONTH field. * @draft ICU 3.0 */ UDAT_MONTH_FIELD = 2, /** - * UFieldPosition selector for 'd' field alignment, + * FieldPosition and UFieldPosition selector for 'd' field alignment, * corresponding to the UCAL_DATE field. * @draft ICU 3.0 */ UDAT_DATE_FIELD = 3, /** - * UFieldPosition selector for 'k' field alignment, + * FieldPosition and UFieldPosition selector for 'k' field alignment, * corresponding to the UCAL_HOUR_OF_DAY field. * UDAT_HOUR_OF_DAY1_FIELD is used for the one-based 24-hour clock. * For example, 23:59 + 01:00 results in 24:59. @@ -200,7 +201,7 @@ typedef enum UDateFormatField { UDAT_HOUR_OF_DAY1_FIELD = 4, /** - * UFieldPosition selector for 'H' field alignment, + * FieldPosition and UFieldPosition selector for 'H' field alignment, * corresponding to the UCAL_HOUR_OF_DAY field. * UDAT_HOUR_OF_DAY0_FIELD is used for the zero-based 24-hour clock. * For example, 23:59 + 01:00 results in 00:59. @@ -209,70 +210,70 @@ typedef enum UDateFormatField { UDAT_HOUR_OF_DAY0_FIELD = 5, /** - * UFieldPosition selector for 'm' field alignment, + * FieldPosition and UFieldPosition selector for 'm' field alignment, * corresponding to the UCAL_MINUTE field. * @draft ICU 3.0 */ UDAT_MINUTE_FIELD = 6, /** - * UFieldPosition selector for 's' field alignment, + * FieldPosition and UFieldPosition selector for 's' field alignment, * corresponding to the UCAL_SECOND field. * @draft ICU 3.0 */ UDAT_SECOND_FIELD = 7, /** - * UFieldPosition selector for 'S' field alignment, + * FieldPosition and UFieldPosition selector for 'S' field alignment, * corresponding to the UCAL_MILLISECOND field. * @draft ICU 3.0 */ - UDAT_MILLISECOND_FIELD = 8, + UDAT_FRACTIONAL_SECOND_FIELD = 8, /** - * UFieldPosition selector for 'E' field alignment, + * FieldPosition and UFieldPosition selector for 'E' field alignment, * corresponding to the UCAL_DAY_OF_WEEK field. * @draft ICU 3.0 */ UDAT_DAY_OF_WEEK_FIELD = 9, /** - * UFieldPosition selector for 'D' field alignment, + * FieldPosition and UFieldPosition selector for 'D' field alignment, * corresponding to the UCAL_DAY_OF_YEAR field. * @draft ICU 3.0 */ UDAT_DAY_OF_YEAR_FIELD = 10, /** - * UFieldPosition selector for 'F' field alignment, + * FieldPosition and UFieldPosition selector for 'F' field alignment, * corresponding to the UCAL_DAY_OF_WEEK_IN_MONTH field. * @draft ICU 3.0 */ UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11, /** - * UFieldPosition selector for 'w' field alignment, + * FieldPosition and UFieldPosition selector for 'w' field alignment, * corresponding to the UCAL_WEEK_OF_YEAR field. * @draft ICU 3.0 */ UDAT_WEEK_OF_YEAR_FIELD = 12, /** - * UFieldPosition selector for 'W' field alignment, + * FieldPosition and UFieldPosition selector for 'W' field alignment, * corresponding to the UCAL_WEEK_OF_MONTH field. * @draft ICU 3.0 */ UDAT_WEEK_OF_MONTH_FIELD = 13, /** - * UFieldPosition selector for 'a' field alignment, + * FieldPosition and UFieldPosition selector for 'a' field alignment, * corresponding to the UCAL_AM_PM field. * @draft ICU 3.0 */ UDAT_AM_PM_FIELD = 14, /** - * UFieldPosition selector for 'h' field alignment, + * FieldPosition and UFieldPosition selector for 'h' field alignment, * corresponding to the UCAL_HOUR field. * UDAT_HOUR1_FIELD is used for the one-based 12-hour clock. * For example, 11:30 PM + 1 hour results in 12:30 AM. @@ -281,7 +282,7 @@ typedef enum UDateFormatField { UDAT_HOUR1_FIELD = 15, /** - * UFieldPosition selector for 'K' field alignment, + * FieldPosition and UFieldPosition selector for 'K' field alignment, * corresponding to the UCAL_HOUR field. * UDAT_HOUR0_FIELD is used for the zero-based 12-hour clock. * For example, 11:30 PM + 1 hour results in 00:30 AM. @@ -290,7 +291,7 @@ typedef enum UDateFormatField { UDAT_HOUR0_FIELD = 16, /** - * UFieldPosition selector for 'z' field alignment, + * FieldPosition and UFieldPosition selector for 'z' field alignment, * corresponding to the UCAL_ZONE_OFFSET and * UCAL_DST_OFFSET fields. * @draft ICU 3.0 @@ -298,42 +299,42 @@ typedef enum UDateFormatField { UDAT_TIMEZONE_FIELD = 17, /** - * UFieldPosition selector for 'Y' field alignment, + * FieldPosition and UFieldPosition selector for 'Y' field alignment, * corresponding to the UCAL_YEAR_WOY field. * @draft ICU 3.0 */ UDAT_YEAR_WOY_FIELD = 18, /** - * UFieldPosition selector for 'e' field alignment, + * FieldPosition and UFieldPosition selector for 'e' field alignment, * corresponding to the UCAL_DOW_LOCAL field. * @draft ICU 3.0 */ UDAT_DOW_LOCAL_FIELD = 19, /** - * UFieldPosition selector for 'u' field alignment, + * FieldPosition and UFieldPosition selector for 'u' field alignment, * corresponding to the UCAL_EXTENDED_YEAR field. * @draft ICU 3.0 */ UDAT_EXTENDED_YEAR_FIELD = 20, /** - * UFieldPosition selector for 'g' field alignment, + * FieldPosition and UFieldPosition selector for 'g' field alignment, * corresponding to the UCAL_JULIAN_DAY field. * @draft ICU 3.0 */ UDAT_JULIAN_DAY_FIELD = 21, /** - * UFieldPosition selector for 'A' field alignment, + * FieldPosition and UFieldPosition selector for 'A' field alignment, * corresponding to the UCAL_MILLISECONDS_IN_DAY field. * @draft ICU 3.0 */ UDAT_MILLISECONDS_IN_DAY_FIELD = 22, /** - * UFieldPosition selector for 'Z' field alignment, + * FieldPosition and UFieldPosition selector for 'Z' field alignment, * corresponding to the UCAL_ZONE_OFFSET and * UCAL_DST_OFFSET fields. * @draft ICU 3.0 @@ -341,7 +342,8 @@ typedef enum UDateFormatField { UDAT_TIMEZONE_RFC_FIELD = 23, /** - * Number of UFieldPosition selectors for UDateFormat. + * Number of FieldPosition and UFieldPosition selectors for + * DateFormat and UDateFormat. * Valid selectors range from 0 to UDAT_FIELD_COUNT-1. * This value is subject to change if new fields are defined * in the future.