From 30e8bc452dcadb3444d40deabcdf76b73908dd2a Mon Sep 17 00:00:00 2001 From: Peter Edberg Date: Wed, 5 Mar 2014 11:51:05 +0000 Subject: [PATCH] ICU-10637 Format/parse using 'r' related gregorian year, C changes part 1 (still need correct num fmt & tests) X-SVN-Rev: 35341 --- icu4c/source/i18n/calendar.cpp | 112 ++++++++++++++++++++++++ icu4c/source/i18n/dtfmtsym.cpp | 62 +++++++------ icu4c/source/i18n/dtitv_impl.h | 3 +- icu4c/source/i18n/dtitvfmt.cpp | 9 +- icu4c/source/i18n/dtptngen.cpp | 3 +- icu4c/source/i18n/smpdtfmt.cpp | 21 +++-- icu4c/source/i18n/udat.cpp | 13 +-- icu4c/source/i18n/unicode/calendar.h | 14 +++ icu4c/source/i18n/unicode/udat.h | 13 ++- icu4c/source/test/cintltst/cdattst.c | 2 +- icu4c/source/test/cintltst/cdtrgtst.c | 6 +- icu4c/source/test/intltest/dtfmttst.cpp | 11 +-- 12 files changed, 216 insertions(+), 53 deletions(-) diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index 9e7a3cc86d2..0a240e504b4 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -1163,6 +1163,118 @@ Calendar::set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t m set(UCAL_SECOND, second); } +// ------------------------------------- +// For now the full getRelatedYear implementation is here; +// per #10752 move the non-default implementation to subclasses +// (default implementation will do no year adjustment) + +int32_t Calendar::getRelatedYear(UErrorCode &status) const +{ + if (U_FAILURE(status)) { + return 0; + } + int32_t year = get(UCAL_EXTENDED_YEAR, status); + if (U_FAILURE(status)) { + return 0; + } + // modify for calendar type + ECalType type = getCalendarType(getType()); + switch (type) { + case CALTYPE_PERSIAN: + year += 622; break; + case CALTYPE_HEBREW: + year -= 3760; break; + case CALTYPE_CHINESE: + year -= 2637; break; + case CALTYPE_INDIAN: + year += 79; break; + case CALTYPE_COPTIC: + year += 284; break; + case CALTYPE_ETHIOPIC: + year += 8; break; + case CALTYPE_ETHIOPIC_AMETE_ALEM: + year -=5492; break; + case CALTYPE_DANGI: + year -= 2333; break; + case CALTYPE_ISLAMIC_CIVIL: + case CALTYPE_ISLAMIC: + case CALTYPE_ISLAMIC_UMALQURA: + case CALTYPE_ISLAMIC_TBLA: + case CALTYPE_ISLAMIC_RGSA: + // ad hoc conversion, improve under #10752 + { + int cycle, offset, shift = 0; + if (year >= 1397) { + cycle = (year - 1397) / 67; + offset = (year - 1397) % 67; + shift = 2*cycle + ((offset >= 33)? 1: 0); + } else { + cycle = (year - 1396) / 67 - 1; + offset = -(year - 1396) % 67; + shift = 2*cycle + ((offset <= 33)? 1: 0); + } + year += 579 - shift; + } + break; + default: + // CALTYPE_GREGORIAN + // CALTYPE_JAPANESE + // CALTYPE_BUDDHIST + // CALTYPE_ROC + // CALTYPE_ISO8601 + // do nothing, EXTENDED_YEAR same as Gregorian + break; + } + return year; +} + +// ------------------------------------- +// For now the full setRelatedYear implementation is here; +// per #10752 move the non-default implementation to subclasses +// (default implementation will do no year adjustment) + +void Calendar::setRelatedYear(int32_t year) +{ + // modify for calendar type + ECalType type = getCalendarType(getType()); + switch (type) { + case CALTYPE_PERSIAN: + year -= 622; break; + case CALTYPE_HEBREW: + year += 3760; break; + case CALTYPE_CHINESE: + year += 2637; break; + case CALTYPE_INDIAN: + year -= 79; break; + case CALTYPE_COPTIC: + year -= 284; break; + case CALTYPE_ETHIOPIC: + year -= 8; break; + case CALTYPE_ETHIOPIC_AMETE_ALEM: + year +=5492; break; + case CALTYPE_DANGI: + year += 2333; break; + case CALTYPE_ISLAMIC_CIVIL: + case CALTYPE_ISLAMIC: + case CALTYPE_ISLAMIC_UMALQURA: + case CALTYPE_ISLAMIC_TBLA: + case CALTYPE_ISLAMIC_RGSA: + // needs adjustment, will do under #10752 + year -= 578; // handles current year +/- a few + break; + default: + // CALTYPE_GREGORIAN + // CALTYPE_JAPANESE + // CALTYPE_BUDDHIST + // CALTYPE_ROC + // CALTYPE_ISO8601 + // do nothing, EXTENDED_YEAR same as Gregorian + break; + } + // set extended year + set(UCAL_EXTENDED_YEAR, year); +} + // ------------------------------------- void diff --git a/icu4c/source/i18n/dtfmtsym.cpp b/icu4c/source/i18n/dtfmtsym.cpp index 270cfe1ea4b..f48c360b386 100644 --- a/icu4c/source/i18n/dtfmtsym.cpp +++ b/icu4c/source/i18n/dtfmtsym.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 1997-2013, International Business Machines Corporation and * +* Copyright (C) 1997-2014, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * @@ -47,18 +47,18 @@ * resource data. */ -#define PATTERN_CHARS_LEN 34 +#define PATTERN_CHARS_LEN 35 /** * Unlocalized date-time pattern characters. For example: 'y', 'd', etc. All * locales use the same these unlocalized pattern characters. */ static const UChar gPatternChars[] = { - // GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXx + // GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXxr 0x47, 0x79, 0x4D, 0x64, 0x6B, 0x48, 0x6D, 0x73, 0x53, 0x45, 0x44, 0x46, 0x77, 0x57, 0x61, 0x68, 0x4B, 0x7A, 0x59, 0x65, 0x75, 0x67, 0x41, 0x5A, 0x76, 0x63, 0x4c, 0x51, 0x71, 0x56, - 0x55, 0x4F, 0x58, 0x78, 0 + 0x55, 0x4F, 0x58, 0x78, 0x72, 0 }; /* length of an array */ @@ -1198,31 +1198,41 @@ DateFormatSymbols::getPatternCharIndex(UChar c) { } } -static const uint32_t kNumericFields = - ((uint32_t)1 << UDAT_YEAR_FIELD) | // y - ((uint32_t)1 << UDAT_MONTH_FIELD) | // M or MM - ((uint32_t)1 << UDAT_DATE_FIELD) | // d - ((uint32_t)1 << UDAT_HOUR_OF_DAY1_FIELD) | // k - ((uint32_t)1 << UDAT_HOUR_OF_DAY0_FIELD) | // H - ((uint32_t)1 << UDAT_MINUTE_FIELD) | // m - ((uint32_t)1 << UDAT_SECOND_FIELD) | // s - ((uint32_t)1 << UDAT_FRACTIONAL_SECOND_FIELD) | // S - ((uint32_t)1 << UDAT_DAY_OF_YEAR_FIELD) | // D - ((uint32_t)1 << UDAT_DAY_OF_WEEK_IN_MONTH_FIELD) | // F - ((uint32_t)1 << UDAT_WEEK_OF_YEAR_FIELD) | // w - ((uint32_t)1 << UDAT_WEEK_OF_MONTH_FIELD) | // W - ((uint32_t)1 << UDAT_HOUR1_FIELD) | // h - ((uint32_t)1 << UDAT_HOUR0_FIELD) | // K - ((uint32_t)1 << UDAT_YEAR_WOY_FIELD) | // Y - ((uint32_t)1 << UDAT_DOW_LOCAL_FIELD) | // e - ((uint32_t)1 << UDAT_EXTENDED_YEAR_FIELD); // u +static const uint64_t kNumericFieldsAlways = + ((uint64_t)1 << UDAT_YEAR_FIELD) | // y + ((uint64_t)1 << UDAT_DATE_FIELD) | // d + ((uint64_t)1 << UDAT_HOUR_OF_DAY1_FIELD) | // k + ((uint64_t)1 << UDAT_HOUR_OF_DAY0_FIELD) | // H + ((uint64_t)1 << UDAT_MINUTE_FIELD) | // m + ((uint64_t)1 << UDAT_SECOND_FIELD) | // s + ((uint64_t)1 << UDAT_FRACTIONAL_SECOND_FIELD) | // S + ((uint64_t)1 << UDAT_DAY_OF_YEAR_FIELD) | // D + ((uint64_t)1 << UDAT_DAY_OF_WEEK_IN_MONTH_FIELD) | // F + ((uint64_t)1 << UDAT_WEEK_OF_YEAR_FIELD) | // w + ((uint64_t)1 << UDAT_WEEK_OF_MONTH_FIELD) | // W + ((uint64_t)1 << UDAT_HOUR1_FIELD) | // h + ((uint64_t)1 << UDAT_HOUR0_FIELD) | // K + ((uint64_t)1 << UDAT_YEAR_WOY_FIELD) | // Y + ((uint64_t)1 << UDAT_EXTENDED_YEAR_FIELD) | // u + ((uint64_t)1 << UDAT_JULIAN_DAY_FIELD) | // g + ((uint64_t)1 << UDAT_MILLISECONDS_IN_DAY_FIELD) | // A + ((uint64_t)1 << UDAT_RELATED_YEAR_FIELD); // r + +static const uint64_t kNumericFieldsForCount12 = + ((uint64_t)1 << UDAT_MONTH_FIELD) | // M or MM + ((uint64_t)1 << UDAT_DOW_LOCAL_FIELD) | // e or ee + ((uint64_t)1 << UDAT_STANDALONE_DAY_FIELD) | // c or cc + ((uint64_t)1 << UDAT_STANDALONE_MONTH_FIELD) | // L or LL + ((uint64_t)1 << UDAT_QUARTER_FIELD) | // Q or QQ + ((uint64_t)1 << UDAT_STANDALONE_QUARTER_FIELD); // q or qq UBool U_EXPORT2 DateFormatSymbols::isNumericField(UDateFormatField f, int32_t count) { - return - f != UDAT_FIELD_COUNT && - (kNumericFields & ((uint32_t)1 << f)) != 0 && - (f != UDAT_MONTH_FIELD || count < 3); + if (f == UDAT_FIELD_COUNT) { + return FALSE; + } + uint64_t flag = ((uint64_t)1 << f); + return ((kNumericFieldsAlways & flag) != 0 || ((kNumericFieldsForCount12 & flag) != 0 && count < 3)); } UBool U_EXPORT2 diff --git a/icu4c/source/i18n/dtitv_impl.h b/icu4c/source/i18n/dtitv_impl.h index 009d9a8b4ae..027bc5e6adb 100644 --- a/icu4c/source/i18n/dtitv_impl.h +++ b/icu4c/source/i18n/dtitv_impl.h @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 2007-2008, International Business Machines Corporation and +* Copyright (C) 2007-2008,2014, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************************* * @@ -74,6 +74,7 @@ #define CAP_Q ((UChar)0x0051) #define CAP_S ((UChar)0x0053) #define CAP_T ((UChar)0x0054) +#define CAP_U ((UChar)0x0055) #define CAP_V ((UChar)0x0056) #define CAP_W ((UChar)0x0057) #define CAP_Y ((UChar)0x0059) diff --git a/icu4c/source/i18n/dtitvfmt.cpp b/icu4c/source/i18n/dtitvfmt.cpp index 33b7e611dc2..e3a2c4ea6bb 100644 --- a/icu4c/source/i18n/dtitvfmt.cpp +++ b/icu4c/source/i18n/dtitvfmt.cpp @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (C) 2008-2013, International Business Machines Corporation and +* Copyright (C) 2008-2014, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************************* * @@ -820,6 +820,8 @@ DateIntervalFormat::getDateTimeSkeleton(const UnicodeString& skeleton, case LOW_G: case LOW_E: case LOW_C: + case CAP_U: + case LOW_R: normalizedDateSkeleton.append(ch); dateSkeleton.append(ch); break; @@ -1470,7 +1472,10 @@ DateIntervalFormat::fgCalendarFieldToPatternLetter[] = /*wWd*/ LOW_W, CAP_W, LOW_D, /*DEF*/ CAP_D, CAP_E, CAP_F, /*ahH*/ LOW_A, LOW_H, CAP_H, - /*m..*/ LOW_M, + /*msS*/ LOW_M, LOW_S, CAP_S, // MINUTE, SECOND, MILLISECOND + /*z.Y*/ LOW_Z, SPACE, CAP_Y, // ZONE_OFFSET, DST_OFFSET, YEAR_WOY, + /*eug*/ LOW_E, LOW_U, LOW_G, // DOW_LOCAL, EXTENDED_YEAR, JULIAN_DAY, + /*A..*/ CAP_A, SPACE, SPACE, // MILLISECONDS_IN_DAY, IS_LEAP_MONTH, FIELD_COUNT }; diff --git a/icu4c/source/i18n/dtptngen.cpp b/icu4c/source/i18n/dtptngen.cpp index c3759a3cc81..30489b71396 100644 --- a/icu4c/source/i18n/dtptngen.cpp +++ b/icu4c/source/i18n/dtptngen.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 2007-2013, International Business Machines Corporation and +* Copyright (C) 2007-2014, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************************* * @@ -144,6 +144,7 @@ static const dtTypeElem dtTypes[] = { {LOW_Y, UDATPG_YEAR_FIELD, DT_NUMERIC, 1, 20}, {CAP_Y, UDATPG_YEAR_FIELD, DT_NUMERIC + DT_DELTA, 1, 20}, {LOW_U, UDATPG_YEAR_FIELD, DT_NUMERIC + 2*DT_DELTA, 1, 20}, + {LOW_R, UDATPG_YEAR_FIELD, DT_NUMERIC + 3*DT_DELTA, 1, 20}, {CAP_U, UDATPG_YEAR_FIELD, DT_SHORT, 1, 3}, {CAP_U, UDATPG_YEAR_FIELD, DT_LONG, 4, 0}, {CAP_U, UDATPG_YEAR_FIELD, DT_NARROW, 5, 0}, diff --git a/icu4c/source/i18n/smpdtfmt.cpp b/icu4c/source/i18n/smpdtfmt.cpp index 5ebb8d5b171..c29b55c2959 100644 --- a/icu4c/source/i18n/smpdtfmt.cpp +++ b/icu4c/source/i18n/smpdtfmt.cpp @@ -126,8 +126,9 @@ static const UDateFormatField kDateFields[] = { UDAT_STANDALONE_MONTH_FIELD, UDAT_QUARTER_FIELD, UDAT_STANDALONE_QUARTER_FIELD, - UDAT_YEAR_NAME_FIELD }; -static const int8_t kDateFieldsCount = 15; + UDAT_YEAR_NAME_FIELD, + UDAT_RELATED_YEAR_FIELD }; +static const int8_t kDateFieldsCount = 16; static const UDateFormatField kTimeFields[] = { UDAT_HOUR_OF_DAY1_FIELD, @@ -203,11 +204,12 @@ static const int32_t gFieldRangeBias[] = { 1, // 'L' - UDAT_STANDALONE_MONTH_FIELD -1, // 'Q' - UDAT_QUARTER_FIELD (1-4?) -1, // 'q' - UDAT_STANDALONE_QUARTER_FIELD - -1 // 'V' - UDAT_TIMEZONE_SPECIAL_FIELD + -1, // 'V' - UDAT_TIMEZONE_SPECIAL_FIELD -1, // 'U' - UDAT_YEAR_NAME_FIELD -1, // 'O' - UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD -1, // 'X' - UDAT_TIMEZONE_ISO_FIELD -1, // 'x' - UDAT_TIMEZONE_ISO_LOCAL_FIELD + -1, // 'r' - UDAT_RELATED_YEAR_FIELD }; // When calendar uses hebr numbering (i.e. he@calendar=hebrew), @@ -956,10 +958,10 @@ SimpleDateFormat::fgCalendarFieldToLevel[] = /*wW*/ 20, 30, /*dDEF*/ 30, 20, 30, 30, /*ahHm*/ 40, 50, 50, 60, - /*sS..*/ 70, 80, + /*sS*/ 70, 80, /*z?Y*/ 0, 0, 10, /*eug*/ 30, 10, 0, - /*A*/ 40 + /*A?.*/ 40, 0, 0 }; @@ -976,7 +978,7 @@ SimpleDateFormat::fgPatternCharToLevel[] = { // a b c d e f g h i j k l m n o -1, 40, -1, 30, 30, 30, -1, 0, 50, -1, -1, 50, -1, 60, -1, -1, // p q r s t u v w x y z - -1, 20, -1, 70, -1, 10, 0, 20, 0, 10, 0, -1, -1, -1, -1, -1 + -1, 20, 10, 70, -1, 10, 0, 20, 0, 10, 0, -1, -1, -1, -1, -1 }; @@ -1001,6 +1003,7 @@ SimpleDateFormat::fgPatternIndexToCalendarField[] = /*U*/ UCAL_YEAR, /*O*/ UCAL_ZONE_OFFSET, /*Xx*/ UCAL_ZONE_OFFSET, UCAL_ZONE_OFFSET, + /*r*/ UCAL_EXTENDED_YEAR, }; // Map index into pattern character string to DateFormat field number @@ -1023,6 +1026,7 @@ SimpleDateFormat::fgPatternIndexToDateFormatField[] = { /*U*/ UDAT_YEAR_NAME_FIELD, /*O*/ UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD, /*Xx*/ UDAT_TIMEZONE_ISO_FIELD, UDAT_TIMEZONE_ISO_LOCAL_FIELD, + /*r*/ UDAT_RELATED_YEAR_FIELD, }; //---------------------------------------------------------------------- @@ -1242,7 +1246,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo, } UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex]; - int32_t value = cal.get(field, status); + int32_t value = (patternCharIndex != UDAT_RELATED_YEAR_FIELD)? cal.get(field, status): cal.getRelatedYear(status); if (U_FAILURE(status)) { return; } @@ -3127,6 +3131,9 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC case UDAT_STANDALONE_QUARTER_FIELD: cal.set(UCAL_MONTH, (value - 1) * 3); break; + case UDAT_RELATED_YEAR_FIELD: + cal.setRelatedYear(value); + break; default: cal.set(field, value); break; diff --git a/icu4c/source/i18n/udat.cpp b/icu4c/source/i18n/udat.cpp index dcbd3caf61d..f28fec673bd 100644 --- a/icu4c/source/i18n/udat.cpp +++ b/icu4c/source/i18n/udat.cpp @@ -67,16 +67,19 @@ static UCalendarDateFields gDateFieldMapping[] = { UCAL_EXTENDED_YEAR, // UDAT_EXTENDED_YEAR_FIELD = 20 UCAL_JULIAN_DAY, // UDAT_JULIAN_DAY_FIELD = 21 UCAL_MILLISECONDS_IN_DAY, // UDAT_MILLISECONDS_IN_DAY_FIELD = 22 - UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_RFC_FIELD = 23 - // UCAL_DST_OFFSET also - UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_GENERIC_FIELD = 24 + UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_RFC_FIELD = 23 (also UCAL_DST_OFFSET) + UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_GENERIC_FIELD = 24 (also UCAL_DST_OFFSET) UCAL_DOW_LOCAL, // UDAT_STANDALONE_DAY_FIELD = 25 UCAL_MONTH, // UDAT_STANDALONE_MONTH_FIELD = 26 UCAL_MONTH, // UDAT_QUARTER_FIELD = 27 UCAL_MONTH, // UDAT_STANDALONE_QUARTER_FIELD = 28 - UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_SPECIAL_FIELD = 29 + UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_SPECIAL_FIELD = 29 (also UCAL_DST_OFFSET) UCAL_YEAR, // UDAT_YEAR_NAME_FIELD = 30 - UCAL_FIELD_COUNT, // UDAT_FIELD_COUNT = 31 + UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD = 31 (also UCAL_DST_OFFSET) + UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_ISO_FIELD = 32 (also UCAL_DST_OFFSET) + UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33 (also UCAL_DST_OFFSET) + UCAL_EXTENDED_YEAR, // UDAT_RELATED_YEAR_FIELD = 34 (not an exact match) + UCAL_FIELD_COUNT, // UDAT_FIELD_COUNT = 35 // UCAL_IS_LEAP_MONTH is not the target of a mapping }; diff --git a/icu4c/source/i18n/unicode/calendar.h b/icu4c/source/i18n/unicode/calendar.h index 83d9140bf4c..c7e221d711a 100644 --- a/icu4c/source/i18n/unicode/calendar.h +++ b/icu4c/source/i18n/unicode/calendar.h @@ -2412,6 +2412,20 @@ private: */ Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const; + /** + * @return The related Gregorian year; will be obtained by modifying the value + * obtained by get from UCAL_EXTENDED_YEAR field + * @internal + */ + virtual int32_t getRelatedYear(UErrorCode &status) const; + + /** + * @param year The related Gregorian year to set; will be modified as necessary then + * set in UCAL_EXTENDED_YEAR field + * @internal + */ + virtual void setRelatedYear(int32_t year); + #ifndef U_HIDE_INTERNAL_API /** Get the locale for this calendar object. You can choose between valid and actual locale. * @param type type of the locale we're looking for (valid or actual) diff --git a/icu4c/source/i18n/unicode/udat.h b/icu4c/source/i18n/unicode/udat.h index 477c0fe3abf..cea9e2dd9fe 100644 --- a/icu4c/source/i18n/unicode/udat.h +++ b/icu4c/source/i18n/unicode/udat.h @@ -756,14 +756,23 @@ typedef enum UDateFormatField { /** * FieldPosition selector for 'x' field alignment, - * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSETfields. + * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSET fields. * This displays the ISO 8601 local time offset format. * @draft ICU 51 */ UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33, #endif /* U_HIDE_DRAFT_API */ +#ifndef U_HIDE_INTERNAL_API /** + * FieldPosition and UFieldPosition selector for 'r' field alignment, + * no directly corresponding UCAL_ field. + * @internal ICU 53 + */ + UDAT_RELATED_YEAR_FIELD = 34, +#endif /* U_HIDE_INTERNAL_API */ + + /** * Number of FieldPosition and UFieldPosition selectors for * DateFormat and UDateFormat. * Valid selectors range from 0 to UDAT_FIELD_COUNT-1. @@ -771,7 +780,7 @@ typedef enum UDateFormatField { * in the future. * @stable ICU 3.0 */ - UDAT_FIELD_COUNT = 34 + UDAT_FIELD_COUNT = 35 } UDateFormatField; diff --git a/icu4c/source/test/cintltst/cdattst.c b/icu4c/source/test/cintltst/cdattst.c index de3ed6fc75d..dd62b9a43d8 100644 --- a/icu4c/source/test/cintltst/cdattst.c +++ b/icu4c/source/test/cintltst/cdattst.c @@ -647,7 +647,7 @@ static void TestSymbols() VerifygetSymbols(def, UDAT_QUARTERS, 3, "4th quarter"); VerifygetSymbols(fr, UDAT_SHORT_QUARTERS, 1, "T2"); VerifygetSymbols(def, UDAT_SHORT_QUARTERS, 2, "Q3"); - VerifygetSymbols(def,UDAT_LOCALIZED_CHARS, 0, "GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXx"); + VerifygetSymbols(def,UDAT_LOCALIZED_CHARS, 0, "GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXxr"); if(result != NULL) { diff --git a/icu4c/source/test/cintltst/cdtrgtst.c b/icu4c/source/test/cintltst/cdtrgtst.c index b635c71ce16..35ca1688caa 100644 --- a/icu4c/source/test/cintltst/cdtrgtst.c +++ b/icu4c/source/test/cintltst/cdtrgtst.c @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2013, International Business Machines Corporation and + * Copyright (c) 1997-2014, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /******************************************************************************** @@ -92,7 +92,7 @@ void Test4029195() udat_applyPattern(df, TRUE, temp, u_strlen(temp)); todayS =myFormatit(df, today); - log_verbose("After teh pattern is applied\n today: %s\n", austrdup(todayS) ); + log_verbose("After the pattern is applied\n today: %s\n", austrdup(todayS) ); parsepos=0; d1=udat_parse(df, todayS, u_strlen(todayS), &parsepos, &status); if(U_FAILURE(status)) @@ -106,7 +106,7 @@ void Test4029195() log_verbose("round trip: %s\n", austrdup(rt) ); if(u_strcmp(rt, todayS)!=0) { - log_err("Fail: Want %s Got %s\n", austrdup(todayS), austrdup(rt) ); + log_err("Fail: Want %s Got %s\n", austrdup(todayS), austrdup(rt) ); } else log_verbose("Pass: parse and format working fine\n"); diff --git a/icu4c/source/test/intltest/dtfmttst.cpp b/icu4c/source/test/intltest/dtfmttst.cpp index f6dae50268c..c38e8a766cb 100644 --- a/icu4c/source/test/intltest/dtfmttst.cpp +++ b/icu4c/source/test/intltest/dtfmttst.cpp @@ -423,7 +423,7 @@ DateFormatTest::escape(UnicodeString& s) /** * This MUST be kept in sync with DateFormatSymbols.gPatternChars. */ -static const char* PATTERN_CHARS = "GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXx"; +static const char* PATTERN_CHARS = "GyMdkHmsSEDFwWahKzYeugAZvcLQqVUOXxr"; /** * A list of the names of all the fields in DateFormat. @@ -464,6 +464,7 @@ static const char* DATEFORMAT_FIELD_NAMES[] = { "TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD", "TIMEZONE_ISO_FIELD", "TIMEZONE_ISO_LOCAL_FIELD", + "RELATED_YEAR_FIELD", }; static const int32_t DATEFORMAT_FIELD_NAMES_LENGTH = @@ -519,22 +520,22 @@ void DateFormatTest::TestFieldPosition() { "", "1997", "August", "13", "", "", "34", "12", "", "Wednesday", "", "", "", "", "PM", "2", "", "Pacific Daylight Time", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", + "", "", "", "", "", "", "1997", "ao\\u00FBt", "13", "", "14", "34", "12", "", "mercredi", "", "", "", "", "", "", "", "heure avanc\\u00e9e du Pacifique", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", + "", "", "", "", "", "AD", "1997", "8", "13", "14", "14", "34", "12", "5", "Wed", "225", "2", "33", "3", "PM", "2", "2", "PDT", "1997", "4", "1997", "2450674", "52452513", "-0700", "PT", "4", "8", "3", "3", "uslax", - "1997", "GMT-7", "-07", "-07", + "1997", "GMT-7", "-07", "-07", "1997", "Anno Domini", "1997", "August", "0013", "0014", "0014", "0034", "0012", "5130", "Wednesday", "0225", "0002", "0033", "0003", "PM", "0002", "0002", "Pacific Daylight Time", "1997", "Wednesday", "1997", "2450674", "52452513", "GMT-07:00", "Pacific Time", "Wednesday", "August", "3rd quarter", "3rd quarter", "Los Angeles Time", - "1997", "GMT-07:00", "-0700", "-0700", + "1997", "GMT-07:00", "-0700", "-0700","1997", }; const int32_t EXPECTED_LENGTH = sizeof(EXPECTED)/sizeof(EXPECTED[0]);