mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 23:10:40 +00:00
ICU-8959 Add UDAT_YEAR_NAME_FIELD for pattern char 'U', implement format/parse for it (C)
X-SVN-Rev: 31215
This commit is contained in:
parent
e577fc8ae0
commit
0ab713c4fb
9 changed files with 124 additions and 37 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2011, International Business Machines Corporation and *
|
||||
* Copyright (C) 1997-2012, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -47,17 +47,17 @@
|
|||
* resource data.
|
||||
*/
|
||||
|
||||
#define PATTERN_CHARS_LEN 30
|
||||
#define PATTERN_CHARS_LEN 31
|
||||
|
||||
/**
|
||||
* Unlocalized date-time pattern characters. For example: 'y', 'd', etc. All
|
||||
* locales use the same these unlocalized pattern characters.
|
||||
*/
|
||||
static const UChar gPatternChars[] = {
|
||||
// GyMdkHmsSEDFwWahKzYeugAZvcLQqV
|
||||
// GyMdkHmsSEDFwWahKzYeugAZvcLQqVU
|
||||
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, 0
|
||||
0x75, 0x67, 0x41, 0x5A, 0x76, 0x63, 0x4c, 0x51, 0x71, 0x56, 0x55, 0
|
||||
};
|
||||
|
||||
/* length of an array */
|
||||
|
@ -180,6 +180,8 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateFormatSymbols)
|
|||
* with a locale and calendar
|
||||
*/
|
||||
static const char gErasTag[]="eras";
|
||||
static const char gCyclicNameSetsTag[]="cyclicNameSets";
|
||||
static const char gNameSetYearsTag[]="years";
|
||||
static const char gMonthNamesTag[]="monthNames";
|
||||
static const char gMonthPatternsTag[]="monthPatterns";
|
||||
static const char gDayNamesTag[]="dayNames";
|
||||
|
@ -188,6 +190,7 @@ static const char gNamesAbbrTag[]="abbreviated";
|
|||
static const char gNamesNarrowTag[]="narrow";
|
||||
static const char gNamesAllTag[]="all";
|
||||
static const char gNamesLeapTag[]="leap";
|
||||
static const char gNamesFormatTag[]="format";
|
||||
static const char gNamesStandaloneTag[]="stand-alone";
|
||||
static const char gNamesNumericTag[]="numeric";
|
||||
static const char gAmPmMarkersTag[]="AmPmMarkers";
|
||||
|
@ -335,7 +338,18 @@ DateFormatSymbols::copyData(const DateFormatSymbols& other) {
|
|||
assignArray(fShortQuarters, fShortQuartersCount, other.fShortQuarters, other.fShortQuartersCount);
|
||||
assignArray(fStandaloneQuarters, fStandaloneQuartersCount, other.fStandaloneQuarters, other.fStandaloneQuartersCount);
|
||||
assignArray(fStandaloneShortQuarters, fStandaloneShortQuartersCount, other.fStandaloneShortQuarters, other.fStandaloneShortQuartersCount);
|
||||
assignArray(fLeapMonthPatterns, fLeapMonthPatternsCount, other.fLeapMonthPatterns, other.fLeapMonthPatternsCount);
|
||||
if (other.fLeapMonthPatterns != NULL) {
|
||||
assignArray(fLeapMonthPatterns, fLeapMonthPatternsCount, other.fLeapMonthPatterns, other.fLeapMonthPatternsCount);
|
||||
} else {
|
||||
fLeapMonthPatterns = NULL;
|
||||
fLeapMonthPatternsCount = 0;
|
||||
}
|
||||
if (other.fShortYearNames != NULL) {
|
||||
assignArray(fShortYearNames, fShortYearNamesCount, other.fShortYearNames, other.fShortYearNamesCount);
|
||||
} else {
|
||||
fShortYearNames = NULL;
|
||||
fShortYearNamesCount = 0;
|
||||
}
|
||||
fGmtZero = other.fGmtZero;
|
||||
fGmtFormat = other.fGmtFormat;
|
||||
assignArray(fGmtHourFormats, fGmtHourFormatsCount, other.fGmtHourFormats, other.fGmtHourFormatsCount);
|
||||
|
@ -397,6 +411,7 @@ void DateFormatSymbols::dispose()
|
|||
if (fStandaloneQuarters) delete[] fStandaloneQuarters;
|
||||
if (fStandaloneShortQuarters) delete[] fStandaloneShortQuarters;
|
||||
if (fLeapMonthPatterns) delete[] fLeapMonthPatterns;
|
||||
if (fShortYearNames) delete[] fShortYearNames;
|
||||
if (fGmtHourFormats) delete[] fGmtHourFormats;
|
||||
|
||||
disposeZoneStrings();
|
||||
|
@ -465,6 +480,7 @@ DateFormatSymbols::operator==(const DateFormatSymbols& other) const
|
|||
fStandaloneQuartersCount == other.fStandaloneQuartersCount &&
|
||||
fStandaloneShortQuartersCount == other.fStandaloneShortQuartersCount &&
|
||||
fLeapMonthPatternsCount == other.fLeapMonthPatternsCount &&
|
||||
fShortYearNamesCount == other.fShortYearNamesCount &&
|
||||
fGmtHourFormatsCount == other.fGmtHourFormatsCount &&
|
||||
fGmtZero == other.fGmtZero &&
|
||||
fGmtFormat == other.fGmtFormat)
|
||||
|
@ -491,6 +507,7 @@ DateFormatSymbols::operator==(const DateFormatSymbols& other) const
|
|||
arrayCompare(fStandaloneQuarters, other.fStandaloneQuarters, fStandaloneQuartersCount) &&
|
||||
arrayCompare(fStandaloneShortQuarters, other.fStandaloneShortQuarters, fStandaloneShortQuartersCount) &&
|
||||
arrayCompare(fLeapMonthPatterns, other.fLeapMonthPatterns, fLeapMonthPatternsCount) &&
|
||||
arrayCompare(fShortYearNames, other.fShortYearNames, fShortYearNamesCount) &&
|
||||
arrayCompare(fGmtHourFormats, other.fGmtHourFormats, fGmtHourFormatsCount))
|
||||
{
|
||||
// Compare the contents of fZoneStrings
|
||||
|
@ -1286,6 +1303,8 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
fStandaloneShortQuartersCount = 0;
|
||||
fLeapMonthPatterns = NULL;
|
||||
fLeapMonthPatternsCount = 0;
|
||||
fShortYearNames = NULL;
|
||||
fShortYearNamesCount = 0;
|
||||
fGmtHourFormats = NULL;
|
||||
fGmtHourFormatsCount = 0;
|
||||
fZoneStringsRowCount = 0;
|
||||
|
@ -1352,6 +1371,24 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
}
|
||||
}
|
||||
|
||||
UErrorCode cyclicNamesStatus = U_ZERO_ERROR;
|
||||
UResourceBundle *cyclicNameSets= calData.getByKey(gCyclicNameSetsTag, cyclicNamesStatus);
|
||||
if (U_SUCCESS(cyclicNamesStatus) && cyclicNameSets != NULL) {
|
||||
UResourceBundle *nameSetYears = ures_getByKeyWithFallback(cyclicNameSets, gNameSetYearsTag, NULL, &cyclicNamesStatus);
|
||||
if (U_SUCCESS(cyclicNamesStatus)) {
|
||||
UResourceBundle *nameSetYearsFmt = ures_getByKeyWithFallback(nameSetYears, gNamesFormatTag, NULL, &cyclicNamesStatus);
|
||||
if (U_SUCCESS(cyclicNamesStatus)) {
|
||||
UResourceBundle *nameSetYearsFmtAbbrev = ures_getByKeyWithFallback(nameSetYearsFmt, gNamesAbbrTag, NULL, &cyclicNamesStatus);
|
||||
if (U_SUCCESS(cyclicNamesStatus)) {
|
||||
initField(&fShortYearNames, fShortYearNamesCount, nameSetYearsFmtAbbrev, cyclicNamesStatus);
|
||||
ures_close(nameSetYearsFmtAbbrev);
|
||||
}
|
||||
ures_close(nameSetYearsFmt);
|
||||
}
|
||||
ures_close(nameSetYears);
|
||||
}
|
||||
}
|
||||
|
||||
UResourceBundle *lsweekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *weekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *narrowWeekdaysData = NULL; // Data closed by calData
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007-2011, International Business Machines Corporation and
|
||||
* Copyright (C) 2007-2012, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -144,6 +144,9 @@ 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},
|
||||
{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},
|
||||
{CAP_Q, UDATPG_QUARTER_FIELD, DT_NUMERIC, 1, 2},
|
||||
{CAP_Q, UDATPG_QUARTER_FIELD, DT_SHORT, 3, 0},
|
||||
{CAP_Q, UDATPG_QUARTER_FIELD, DT_LONG, 4, 0},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007-2011, International Business Machines Corporation and
|
||||
* Copyright (C) 2007-2012, International Business Machines Corporation and
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -51,6 +51,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)
|
||||
|
|
|
@ -122,8 +122,9 @@ static const UDateFormatField kDateFields[] = {
|
|||
UDAT_STANDALONE_DAY_FIELD,
|
||||
UDAT_STANDALONE_MONTH_FIELD,
|
||||
UDAT_QUARTER_FIELD,
|
||||
UDAT_STANDALONE_QUARTER_FIELD };
|
||||
static const int8_t kDateFieldsCount = 13;
|
||||
UDAT_STANDALONE_QUARTER_FIELD,
|
||||
UDAT_YEAR_NAME_FIELD };
|
||||
static const int8_t kDateFieldsCount = 15;
|
||||
|
||||
static const UDateFormatField kTimeFields[] = {
|
||||
UDAT_HOUR_OF_DAY1_FIELD,
|
||||
|
@ -199,6 +200,7 @@ static const int32_t gFieldRangeBias[] = {
|
|||
-1, // 'Q' - UDAT_QUARTER_FIELD (1-4?)
|
||||
-1, // 'q' - UDAT_STANDALONE_QUARTER_FIELD
|
||||
-1 // 'V' - UDAT_TIMEZONE_SPECIAL_FIELD
|
||||
-1, // 'U' - UDAT_YEAR_NAME_FIELD
|
||||
};
|
||||
|
||||
static UMTX LOCK;
|
||||
|
@ -931,7 +933,7 @@ SimpleDateFormat::fgPatternCharToLevel[] = {
|
|||
// A B C D E F G H I J K L M N O
|
||||
-1, 40, -1, -1, 20, 30, 30, 0, 50, -1, -1, 50, 20, 20, -1, -1,
|
||||
// P Q R S T U V W X Y Z
|
||||
-1, 20, -1, 80, -1, -1, 0, 30, -1, 10, 0, -1, -1, -1, -1, -1,
|
||||
-1, 20, -1, 80, -1, 10, 0, 30, -1, 10, 0, -1, -1, -1, -1, -1,
|
||||
// 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
|
||||
|
@ -957,6 +959,7 @@ SimpleDateFormat::fgPatternIndexToCalendarField[] =
|
|||
/*Q*/ UCAL_MONTH,
|
||||
/*q*/ UCAL_MONTH,
|
||||
/*V*/ UCAL_ZONE_OFFSET,
|
||||
/*U*/ UCAL_YEAR,
|
||||
};
|
||||
|
||||
// Map index into pattern character string to DateFormat field number
|
||||
|
@ -976,6 +979,7 @@ SimpleDateFormat::fgPatternIndexToDateFormatField[] = {
|
|||
/*Q*/ UDAT_QUARTER_FIELD,
|
||||
/*q*/ UDAT_STANDALONE_QUARTER_FIELD,
|
||||
/*V*/ UDAT_TIMEZONE_SPECIAL_FIELD,
|
||||
/*U*/ UDAT_YEAR_NAME_FIELD,
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1603,6 +1607,11 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
|
|||
zeroPaddingNumber(currentNumberFormat, appendTo, value, count, maxIntCount);
|
||||
break;
|
||||
|
||||
case UDAT_YEAR_NAME_FIELD:
|
||||
// the Calendar YEAR field runs 1 through 60 for cyclic years
|
||||
_appendSymbol(appendTo, value - 1, fSymbols->fShortYearNames, fSymbols->fShortYearNamesCount);
|
||||
break;
|
||||
|
||||
// for "MMMM"/"LLLL", write out the whole month name, for "MMM"/"LLL", write out the month
|
||||
// abbreviation, for "M"/"L" or "MM"/"LL", write out the month as a number with the
|
||||
// appropriate number of digits
|
||||
|
@ -2552,6 +2561,9 @@ int32_t SimpleDateFormat::matchString(const UnicodeString& text,
|
|||
cal.set(field,6);
|
||||
}
|
||||
else {
|
||||
if (field == UCAL_YEAR) {
|
||||
bestMatch++; // only get here for cyclic year names, which match 1-based years 1-60
|
||||
}
|
||||
cal.set(field, bestMatch);
|
||||
}
|
||||
if (monthPattern != NULL) {
|
||||
|
@ -2844,6 +2856,9 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
|
|||
cal.set(UCAL_YEAR_WOY, value);
|
||||
return pos.getIndex();
|
||||
|
||||
case UDAT_YEAR_NAME_FIELD:
|
||||
return matchString(text, start, UCAL_YEAR, fSymbols->fShortYearNames, fSymbols->fShortYearNamesCount, NULL, cal);
|
||||
|
||||
case UDAT_MONTH_FIELD:
|
||||
case UDAT_STANDALONE_MONTH_FIELD:
|
||||
if (gotNumber) // i.e., M or MM.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines
|
||||
* Copyright (C) 1996-2012, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -73,7 +73,8 @@ static UCalendarDateFields gDateFieldMapping[] = {
|
|||
UCAL_MONTH, // UDAT_QUARTER_FIELD = 27
|
||||
UCAL_MONTH, // UDAT_STANDALONE_QUARTER_FIELD = 28
|
||||
UCAL_ZONE_OFFSET, // UDAT_TIMEZONE_SPECIAL_FIELD = 29
|
||||
UCAL_FIELD_COUNT, // UDAT_FIELD_COUNT = 30
|
||||
UCAL_YEAR, // UDAT_YEAR_NAME_FIELD = 30
|
||||
UCAL_FIELD_COUNT, // UDAT_FIELD_COUNT = 31
|
||||
// UCAL_IS_LEAP_MONTH is not the target of a mapping
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 1997-2011, International Business Machines
|
||||
* Copyright (C) 1997-2012, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
|
@ -638,6 +638,12 @@ private:
|
|||
UnicodeString *fLeapMonthPatterns;
|
||||
int32_t fLeapMonthPatternsCount;
|
||||
|
||||
/**
|
||||
* (Format) Short cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai"
|
||||
*/
|
||||
UnicodeString* fShortYearNames;
|
||||
int32_t fShortYearNamesCount;
|
||||
|
||||
/**
|
||||
* Localized names of time zones in this locale. This is a
|
||||
* two-dimensional array of strings of size n by m,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines
|
||||
* Copyright (C) 1996-2012, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -484,6 +484,15 @@ typedef enum UDateFormatField {
|
|||
*/
|
||||
UDAT_TIMEZONE_SPECIAL_FIELD = 29,
|
||||
|
||||
/**
|
||||
* FieldPosition selector for "U" field alignment,
|
||||
* corresponding to cyclic year names. This is implemented
|
||||
* using the {@link #UCAL_YEAR} field. This displays
|
||||
* the cyclic year name, if available.
|
||||
* @draft ICU 49
|
||||
*/
|
||||
UDAT_YEAR_NAME_FIELD = 30,
|
||||
|
||||
/**
|
||||
* Number of FieldPosition and UFieldPosition selectors for
|
||||
* DateFormat and UDateFormat.
|
||||
|
@ -492,7 +501,7 @@ typedef enum UDateFormatField {
|
|||
* in the future.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
UDAT_FIELD_COUNT = 30
|
||||
UDAT_FIELD_COUNT = 31
|
||||
|
||||
} UDateFormatField;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2011, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2012, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/********************************************************************************
|
||||
|
@ -620,7 +620,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, "GyMdkHmsSEDFwWahKzYeugAZvcLQqV");
|
||||
VerifygetSymbols(def,UDAT_LOCALIZED_CHARS, 0, "GyMdkHmsSEDFwWahKzYeugAZvcLQqVU");
|
||||
|
||||
|
||||
if(result != NULL) {
|
||||
|
|
|
@ -301,7 +301,7 @@ DateFormatTest::escape(UnicodeString& s)
|
|||
/**
|
||||
* This MUST be kept in sync with DateFormatSymbols.gPatternChars.
|
||||
*/
|
||||
static const char* PATTERN_CHARS = "GyMdkHmsSEDFwWahKzYeugAZvcLQqV";
|
||||
static const char* PATTERN_CHARS = "GyMdkHmsSEDFwWahKzYeugAZvcLQqVU";
|
||||
|
||||
/**
|
||||
* A list of the names of all the fields in DateFormat.
|
||||
|
@ -337,7 +337,8 @@ static const char* DATEFORMAT_FIELD_NAMES[] = {
|
|||
"STAND_ALONE_MONTH_FIELD",
|
||||
"QUARTER_FIELD",
|
||||
"STAND_ALONE_QUARTER_FIELD",
|
||||
"TIMEZONE_SPECIAL_FIELD"
|
||||
"TIMEZONE_SPECIAL_FIELD",
|
||||
"YEAR_NAME_FIELD"
|
||||
};
|
||||
|
||||
static const int32_t DATEFORMAT_FIELD_NAMES_LENGTH =
|
||||
|
@ -391,17 +392,17 @@ void DateFormatTest::TestFieldPosition() {
|
|||
// Fields are given in order of DateFormat field number
|
||||
const char* EXPECTED[] = {
|
||||
"", "1997", "August", "13", "", "", "34", "12", "",
|
||||
"Wednesday", "", "", "", "", "PM", "2", "", "Pacific Daylight Time", "", "", "", "", "", "", "", "", "", "", "","",
|
||||
"Wednesday", "", "", "", "", "PM", "2", "", "Pacific Daylight Time", "", "", "", "", "", "", "", "", "", "", "","","",
|
||||
|
||||
"", "1997", "ao\\u00FBt", "13", "", "14", "34", "12", "",
|
||||
"mercredi", "", "", "", "", "", "", "", "heure avanc\\u00e9e du Pacifique", "", "", "", "", "", "", "", "", "", "", "", "",
|
||||
"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","PDT",
|
||||
"Wed", "225", "2", "33", "3", "PM", "2", "2", "PDT", "1997", "4", "1997", "2450674", "52452513", "-0700", "PT", "4", "8", "3", "3","PDT","",
|
||||
|
||||
"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", "United States Time (Los Angeles)"
|
||||
"Pacific Time", "Wednesday", "August", "3rd quarter", "3rd quarter", "United States Time (Los Angeles)",""
|
||||
};
|
||||
|
||||
const int32_t EXPECTED_LENGTH = sizeof(EXPECTED)/sizeof(EXPECTED[0]);
|
||||
|
@ -3737,24 +3738,38 @@ void DateFormatTest::TestMonthPatterns()
|
|||
|
||||
const MonthPatternItem items[] = {
|
||||
// locale date style; expected formats for the 3 dates above
|
||||
{ "root@calendar=chinese", DateFormat::kLong, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
|
||||
{ "root@calendar=chinese", DateFormat::kShort, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
|
||||
{ "root@calendar=chinese", -1, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
|
||||
{ "root@calendar=chinese", -2, { UnicodeString("78x29-4-2"), UnicodeString("78x29-4bis-2"), UnicodeString("78x29-5-2") } },
|
||||
{ "en@calendar=chinese", DateFormat::kLong, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
|
||||
{ "en@calendar=chinese", DateFormat::kShort, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
|
||||
{ "zh@calendar=chinese", DateFormat::kLong, { CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u56DB\\u6708\\u4E8C\\u65E5"), CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u95F0\\u56DB\\u6708\\u4E8C\\u65E5"), CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u4E94\\u6708\\u4E8C\\u65E5") } },
|
||||
{ "zh@calendar=chinese", DateFormat::kShort, { UnicodeString("29-4-2"), CharsToUnicodeString("29-\\u95F04-2"), UnicodeString("29-5-2") } },
|
||||
{ "zh_Hant@calendar=chinese", DateFormat::kLong, { CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u56DB\\u6708\\u4E8C\\u65E5"), CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u95F0\\u56DB\\u6708\\u4E8C\\u65E5"), CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u4E94\\u6708\\u4E8C\\u65E5") } },
|
||||
{ "zh_Hant@calendar=chinese", DateFormat::kShort, { UnicodeString("29-4-2"), CharsToUnicodeString("29-\\u95F04-2"), UnicodeString("29-5-2") } },
|
||||
{ "fr@calendar=chinese", DateFormat::kLong, { CharsToUnicodeString("2 s\\u00ECyu\\u00E8 29"), CharsToUnicodeString("2 s\\u00ECyu\\u00E8bis 29"), CharsToUnicodeString("2 w\\u01D4yu\\u00E8 29") } },
|
||||
{ "fr@calendar=chinese", DateFormat::kShort, { UnicodeString("2/4/29"), UnicodeString("2/4bis/29"), UnicodeString("2/5/29") } },
|
||||
{ "root@calendar=chinese", DateFormat::kLong, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
|
||||
{ "root@calendar=chinese", DateFormat::kShort, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
|
||||
{ "root@calendar=chinese", -1, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
|
||||
{ "root@calendar=chinese", -2, { UnicodeString("78x29-4-2"), UnicodeString("78x29-4bis-2"), UnicodeString("78x29-5-2") } },
|
||||
{ "root@calendar=chinese", -3, { UnicodeString("ren-chen-4-2"), UnicodeString("ren-chen-4bis-2"), UnicodeString("ren-chen-5-2") } },
|
||||
{ "root@calendar=chinese", -4, { UnicodeString("ren-chen 4 2"), UnicodeString("ren-chen 4bis 2"), UnicodeString("ren-chen 5 2") } },
|
||||
{ "en@calendar=chinese", DateFormat::kLong, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
|
||||
{ "en@calendar=chinese", DateFormat::kShort, { UnicodeString("29-4-2"), UnicodeString("29-4bis-2"), UnicodeString("29-5-2") } },
|
||||
{ "zh@calendar=chinese", DateFormat::kLong, { CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u56DB\\u6708\\u4E8C\\u65E5"),
|
||||
CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u95F0\\u56DB\\u6708\\u4E8C\\u65E5"),
|
||||
CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u4E94\\u6708\\u4E8C\\u65E5") } },
|
||||
{ "zh@calendar=chinese", DateFormat::kShort, { UnicodeString("29-4-2"), CharsToUnicodeString("29-\\u95F04-2"), UnicodeString("29-5-2") } },
|
||||
{ "zh@calendar=chinese", -3, { CharsToUnicodeString("\\u58EC\\u8FB0-4-2"),
|
||||
CharsToUnicodeString("\\u58EC\\u8FB0-\\u95F04-2"),
|
||||
CharsToUnicodeString("\\u58EC\\u8FB0-5-2") } },
|
||||
{ "zh@calendar=chinese", -4, { CharsToUnicodeString("\\u58EC\\u8FB0 \\u56DB\\u6708 2"),
|
||||
CharsToUnicodeString("\\u58EC\\u8FB0 \\u95F0\\u56DB\\u6708 2"),
|
||||
CharsToUnicodeString("\\u58EC\\u8FB0 \\u4E94\\u6708 2") } },
|
||||
{ "zh_Hant@calendar=chinese", DateFormat::kLong, { CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u56DB\\u6708\\u4E8C\\u65E5"),
|
||||
CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u95F0\\u56DB\\u6708\\u4E8C\\u65E5"),
|
||||
CharsToUnicodeString("\\u4E8C\\u4E5D\\u5E74\\u4E94\\u6708\\u4E8C\\u65E5") } },
|
||||
{ "zh_Hant@calendar=chinese", DateFormat::kShort, { UnicodeString("29-4-2"), CharsToUnicodeString("29-\\u95F04-2"), UnicodeString("29-5-2") } },
|
||||
{ "fr@calendar=chinese", DateFormat::kLong, { CharsToUnicodeString("2 s\\u00ECyu\\u00E8 29"),
|
||||
CharsToUnicodeString("2 s\\u00ECyu\\u00E8bis 29"),
|
||||
CharsToUnicodeString("2 w\\u01D4yu\\u00E8 29") } },
|
||||
{ "fr@calendar=chinese", DateFormat::kShort, { UnicodeString("2/4/29"), UnicodeString("2/4bis/29"), UnicodeString("2/5/29") } },
|
||||
// terminator
|
||||
{ NULL, 0, { UnicodeString(""), UnicodeString(""), UnicodeString("") } }
|
||||
};
|
||||
|
||||
//. style -1 style -2
|
||||
const UnicodeString customPatterns[] = { "y-Ml-d", "G'x'y-Ml-d" }; // like old root pattern, using 'l'
|
||||
//. style: -1 -2 -3 -4
|
||||
const UnicodeString customPatterns[] = { "y-Ml-d", "G'x'y-Ml-d", "U-M-d", "U MMM d" }; // like old root pattern, using 'l'
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
Locale rootChineseCalLocale = Locale::createFromName("root@calendar=chinese");
|
||||
|
|
Loading…
Add table
Reference in a new issue