mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-9497 Add support for short weekday names: format, parse, get/set symbols (C)
X-SVN-Rev: 33047
This commit is contained in:
parent
f9bc84be0b
commit
54098be451
9 changed files with 333 additions and 83 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2012, International Business Machines Corporation and *
|
||||
* Copyright (C) 1997-2013, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -162,6 +162,7 @@ static const char gMonthPatternsTag[]="monthPatterns";
|
|||
static const char gDayNamesTag[]="dayNames";
|
||||
static const char gNamesWideTag[]="wide";
|
||||
static const char gNamesAbbrTag[]="abbreviated";
|
||||
static const char gNamesShortTag[]="short";
|
||||
static const char gNamesNarrowTag[]="narrow";
|
||||
static const char gNamesAllTag[]="all";
|
||||
static const char gNamesLeapTag[]="leap";
|
||||
|
@ -303,9 +304,11 @@ DateFormatSymbols::copyData(const DateFormatSymbols& other) {
|
|||
assignArray(fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, other.fStandaloneNarrowMonths, other.fStandaloneNarrowMonthsCount);
|
||||
assignArray(fWeekdays, fWeekdaysCount, other.fWeekdays, other.fWeekdaysCount);
|
||||
assignArray(fShortWeekdays, fShortWeekdaysCount, other.fShortWeekdays, other.fShortWeekdaysCount);
|
||||
assignArray(fShorterWeekdays, fShorterWeekdaysCount, other.fShorterWeekdays, other.fShorterWeekdaysCount);
|
||||
assignArray(fNarrowWeekdays, fNarrowWeekdaysCount, other.fNarrowWeekdays, other.fNarrowWeekdaysCount);
|
||||
assignArray(fStandaloneWeekdays, fStandaloneWeekdaysCount, other.fStandaloneWeekdays, other.fStandaloneWeekdaysCount);
|
||||
assignArray(fStandaloneShortWeekdays, fStandaloneShortWeekdaysCount, other.fStandaloneShortWeekdays, other.fStandaloneShortWeekdaysCount);
|
||||
assignArray(fStandaloneShorterWeekdays, fStandaloneShorterWeekdaysCount, other.fStandaloneShorterWeekdays, other.fStandaloneShorterWeekdaysCount);
|
||||
assignArray(fStandaloneNarrowWeekdays, fStandaloneNarrowWeekdaysCount, other.fStandaloneNarrowWeekdays, other.fStandaloneNarrowWeekdaysCount);
|
||||
assignArray(fAmPms, fAmPmsCount, other.fAmPms, other.fAmPmsCount);
|
||||
assignArray(fQuarters, fQuartersCount, other.fQuarters, other.fQuartersCount);
|
||||
|
@ -363,28 +366,30 @@ DateFormatSymbols::~DateFormatSymbols()
|
|||
|
||||
void DateFormatSymbols::dispose()
|
||||
{
|
||||
if (fEras) delete[] fEras;
|
||||
if (fEraNames) delete[] fEraNames;
|
||||
if (fNarrowEras) delete[] fNarrowEras;
|
||||
if (fMonths) delete[] fMonths;
|
||||
if (fShortMonths) delete[] fShortMonths;
|
||||
if (fNarrowMonths) delete[] fNarrowMonths;
|
||||
if (fStandaloneMonths) delete[] fStandaloneMonths;
|
||||
if (fStandaloneShortMonths) delete[] fStandaloneShortMonths;
|
||||
if (fStandaloneNarrowMonths) delete[] fStandaloneNarrowMonths;
|
||||
if (fWeekdays) delete[] fWeekdays;
|
||||
if (fShortWeekdays) delete[] fShortWeekdays;
|
||||
if (fNarrowWeekdays) delete[] fNarrowWeekdays;
|
||||
if (fStandaloneWeekdays) delete[] fStandaloneWeekdays;
|
||||
if (fStandaloneShortWeekdays) delete[] fStandaloneShortWeekdays;
|
||||
if (fStandaloneNarrowWeekdays) delete[] fStandaloneNarrowWeekdays;
|
||||
if (fAmPms) delete[] fAmPms;
|
||||
if (fQuarters) delete[] fQuarters;
|
||||
if (fShortQuarters) delete[] fShortQuarters;
|
||||
if (fStandaloneQuarters) delete[] fStandaloneQuarters;
|
||||
if (fStandaloneShortQuarters) delete[] fStandaloneShortQuarters;
|
||||
if (fLeapMonthPatterns) delete[] fLeapMonthPatterns;
|
||||
if (fShortYearNames) delete[] fShortYearNames;
|
||||
if (fEras) delete[] fEras;
|
||||
if (fEraNames) delete[] fEraNames;
|
||||
if (fNarrowEras) delete[] fNarrowEras;
|
||||
if (fMonths) delete[] fMonths;
|
||||
if (fShortMonths) delete[] fShortMonths;
|
||||
if (fNarrowMonths) delete[] fNarrowMonths;
|
||||
if (fStandaloneMonths) delete[] fStandaloneMonths;
|
||||
if (fStandaloneShortMonths) delete[] fStandaloneShortMonths;
|
||||
if (fStandaloneNarrowMonths) delete[] fStandaloneNarrowMonths;
|
||||
if (fWeekdays) delete[] fWeekdays;
|
||||
if (fShortWeekdays) delete[] fShortWeekdays;
|
||||
if (fShorterWeekdays) delete[] fShorterWeekdays;
|
||||
if (fNarrowWeekdays) delete[] fNarrowWeekdays;
|
||||
if (fStandaloneWeekdays) delete[] fStandaloneWeekdays;
|
||||
if (fStandaloneShortWeekdays) delete[] fStandaloneShortWeekdays;
|
||||
if (fStandaloneShorterWeekdays) delete[] fStandaloneShorterWeekdays;
|
||||
if (fStandaloneNarrowWeekdays) delete[] fStandaloneNarrowWeekdays;
|
||||
if (fAmPms) delete[] fAmPms;
|
||||
if (fQuarters) delete[] fQuarters;
|
||||
if (fShortQuarters) delete[] fShortQuarters;
|
||||
if (fStandaloneQuarters) delete[] fStandaloneQuarters;
|
||||
if (fStandaloneShortQuarters) delete[] fStandaloneShortQuarters;
|
||||
if (fLeapMonthPatterns) delete[] fLeapMonthPatterns;
|
||||
if (fShortYearNames) delete[] fShortYearNames;
|
||||
|
||||
disposeZoneStrings();
|
||||
}
|
||||
|
@ -442,9 +447,11 @@ DateFormatSymbols::operator==(const DateFormatSymbols& other) const
|
|||
fStandaloneNarrowMonthsCount == other.fStandaloneNarrowMonthsCount &&
|
||||
fWeekdaysCount == other.fWeekdaysCount &&
|
||||
fShortWeekdaysCount == other.fShortWeekdaysCount &&
|
||||
fShorterWeekdaysCount == other.fShorterWeekdaysCount &&
|
||||
fNarrowWeekdaysCount == other.fNarrowWeekdaysCount &&
|
||||
fStandaloneWeekdaysCount == other.fStandaloneWeekdaysCount &&
|
||||
fStandaloneShortWeekdaysCount == other.fStandaloneShortWeekdaysCount &&
|
||||
fStandaloneShorterWeekdaysCount == other.fStandaloneShorterWeekdaysCount &&
|
||||
fStandaloneNarrowWeekdaysCount == other.fStandaloneNarrowWeekdaysCount &&
|
||||
fAmPmsCount == other.fAmPmsCount &&
|
||||
fQuartersCount == other.fQuartersCount &&
|
||||
|
@ -467,9 +474,11 @@ DateFormatSymbols::operator==(const DateFormatSymbols& other) const
|
|||
arrayCompare(fStandaloneNarrowMonths, other.fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount) &&
|
||||
arrayCompare(fWeekdays, other.fWeekdays, fWeekdaysCount) &&
|
||||
arrayCompare(fShortWeekdays, other.fShortWeekdays, fShortWeekdaysCount) &&
|
||||
arrayCompare(fShorterWeekdays, other.fShorterWeekdays, fShorterWeekdaysCount) &&
|
||||
arrayCompare(fNarrowWeekdays, other.fNarrowWeekdays, fNarrowWeekdaysCount) &&
|
||||
arrayCompare(fStandaloneWeekdays, other.fStandaloneWeekdays, fStandaloneWeekdaysCount) &&
|
||||
arrayCompare(fStandaloneShortWeekdays, other.fStandaloneShortWeekdays, fStandaloneShortWeekdaysCount) &&
|
||||
arrayCompare(fStandaloneShorterWeekdays, other.fStandaloneShorterWeekdays, fStandaloneShorterWeekdaysCount) &&
|
||||
arrayCompare(fStandaloneNarrowWeekdays, other.fStandaloneNarrowWeekdays, fStandaloneNarrowWeekdaysCount) &&
|
||||
arrayCompare(fAmPms, other.fAmPms, fAmPmsCount) &&
|
||||
arrayCompare(fQuarters, other.fQuarters, fQuartersCount) &&
|
||||
|
@ -550,6 +559,7 @@ DateFormatSymbols::getMonths(int32_t &count, DtContextType context, DtWidthType
|
|||
returnValue = fMonths;
|
||||
break;
|
||||
case ABBREVIATED :
|
||||
case SHORT : // no month data for this, defaults to ABBREVIATED
|
||||
count = fShortMonthsCount;
|
||||
returnValue = fShortMonths;
|
||||
break;
|
||||
|
@ -568,6 +578,7 @@ DateFormatSymbols::getMonths(int32_t &count, DtContextType context, DtWidthType
|
|||
returnValue = fStandaloneMonths;
|
||||
break;
|
||||
case ABBREVIATED :
|
||||
case SHORT : // no month data for this, defaults to ABBREVIATED
|
||||
count = fStandaloneShortMonthsCount;
|
||||
returnValue = fStandaloneShortMonths;
|
||||
break;
|
||||
|
@ -614,6 +625,10 @@ DateFormatSymbols::getWeekdays(int32_t &count, DtContextType context, DtWidthTyp
|
|||
count = fShortWeekdaysCount;
|
||||
returnValue = fShortWeekdays;
|
||||
break;
|
||||
case SHORT :
|
||||
count = fShorterWeekdaysCount;
|
||||
returnValue = fShorterWeekdays;
|
||||
break;
|
||||
case NARROW :
|
||||
count = fNarrowWeekdaysCount;
|
||||
returnValue = fNarrowWeekdays;
|
||||
|
@ -632,6 +647,10 @@ DateFormatSymbols::getWeekdays(int32_t &count, DtContextType context, DtWidthTyp
|
|||
count = fStandaloneShortWeekdaysCount;
|
||||
returnValue = fStandaloneShortWeekdays;
|
||||
break;
|
||||
case SHORT :
|
||||
count = fStandaloneShorterWeekdaysCount;
|
||||
returnValue = fStandaloneShorterWeekdays;
|
||||
break;
|
||||
case NARROW :
|
||||
count = fStandaloneNarrowWeekdaysCount;
|
||||
returnValue = fStandaloneNarrowWeekdays;
|
||||
|
@ -659,6 +678,7 @@ DateFormatSymbols::getQuarters(int32_t &count, DtContextType context, DtWidthTyp
|
|||
returnValue = fQuarters;
|
||||
break;
|
||||
case ABBREVIATED :
|
||||
case SHORT : // no quarter data for this, defaults to ABBREVIATED
|
||||
count = fShortQuartersCount;
|
||||
returnValue = fShortQuarters;
|
||||
break;
|
||||
|
@ -677,6 +697,7 @@ DateFormatSymbols::getQuarters(int32_t &count, DtContextType context, DtWidthTyp
|
|||
returnValue = fStandaloneQuarters;
|
||||
break;
|
||||
case ABBREVIATED :
|
||||
case SHORT : // no quarter data for this, defaults to ABBREVIATED
|
||||
count = fStandaloneShortQuartersCount;
|
||||
returnValue = fStandaloneShortQuarters;
|
||||
break;
|
||||
|
@ -811,7 +832,7 @@ DateFormatSymbols::setMonths(const UnicodeString* monthsArray, int32_t count, Dt
|
|||
uprv_arrayCopy( monthsArray,fNarrowMonths,count);
|
||||
fNarrowMonthsCount = count;
|
||||
break;
|
||||
case DT_WIDTH_COUNT :
|
||||
default :
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -838,7 +859,7 @@ DateFormatSymbols::setMonths(const UnicodeString* monthsArray, int32_t count, Dt
|
|||
uprv_arrayCopy( monthsArray,fStandaloneNarrowMonths,count);
|
||||
fStandaloneNarrowMonthsCount = count;
|
||||
break;
|
||||
case DT_WIDTH_COUNT :
|
||||
default :
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -898,6 +919,13 @@ DateFormatSymbols::setWeekdays(const UnicodeString* weekdaysArray, int32_t count
|
|||
uprv_arrayCopy(weekdaysArray, fShortWeekdays, count);
|
||||
fShortWeekdaysCount = count;
|
||||
break;
|
||||
case SHORT :
|
||||
if (fShorterWeekdays)
|
||||
delete[] fShorterWeekdays;
|
||||
fShorterWeekdays = newUnicodeStringArray(count);
|
||||
uprv_arrayCopy(weekdaysArray, fShorterWeekdays, count);
|
||||
fShorterWeekdaysCount = count;
|
||||
break;
|
||||
case NARROW :
|
||||
if (fNarrowWeekdays)
|
||||
delete[] fNarrowWeekdays;
|
||||
|
@ -925,6 +953,13 @@ DateFormatSymbols::setWeekdays(const UnicodeString* weekdaysArray, int32_t count
|
|||
uprv_arrayCopy(weekdaysArray, fStandaloneShortWeekdays, count);
|
||||
fStandaloneShortWeekdaysCount = count;
|
||||
break;
|
||||
case SHORT :
|
||||
if (fStandaloneShorterWeekdays)
|
||||
delete[] fStandaloneShorterWeekdays;
|
||||
fStandaloneShorterWeekdays = newUnicodeStringArray(count);
|
||||
uprv_arrayCopy(weekdaysArray, fStandaloneShorterWeekdays, count);
|
||||
fStandaloneShorterWeekdaysCount = count;
|
||||
break;
|
||||
case NARROW :
|
||||
if (fStandaloneNarrowWeekdays)
|
||||
delete[] fStandaloneNarrowWeekdays;
|
||||
|
@ -974,7 +1009,7 @@ DateFormatSymbols::setQuarters(const UnicodeString* quartersArray, int32_t count
|
|||
fNarrowQuartersCount = count;
|
||||
*/
|
||||
break;
|
||||
case DT_WIDTH_COUNT :
|
||||
default :
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -1003,7 +1038,7 @@ DateFormatSymbols::setQuarters(const UnicodeString* quartersArray, int32_t count
|
|||
fStandaloneNarrowQuartersCount = count;
|
||||
*/
|
||||
break;
|
||||
case DT_WIDTH_COUNT :
|
||||
default :
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -1317,12 +1352,16 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
fWeekdaysCount=0;
|
||||
fShortWeekdays = NULL;
|
||||
fShortWeekdaysCount=0;
|
||||
fShorterWeekdays = NULL;
|
||||
fShorterWeekdaysCount=0;
|
||||
fNarrowWeekdays = NULL;
|
||||
fNarrowWeekdaysCount=0;
|
||||
fStandaloneWeekdays = NULL;
|
||||
fStandaloneWeekdaysCount=0;
|
||||
fStandaloneShortWeekdays = NULL;
|
||||
fStandaloneShortWeekdaysCount=0;
|
||||
fStandaloneShorterWeekdays = NULL;
|
||||
fStandaloneShorterWeekdaysCount=0;
|
||||
fStandaloneNarrowWeekdays = NULL;
|
||||
fStandaloneNarrowWeekdaysCount=0;
|
||||
fAmPms = NULL;
|
||||
|
@ -1425,19 +1464,19 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
while ( (contextTransformUsage = ures_getNextResource(contextTransforms, NULL, &tempStatus)) != NULL ) {
|
||||
const int32_t * intVector = ures_getIntVector(contextTransformUsage, &len, &status);
|
||||
if (U_SUCCESS(tempStatus) && intVector != NULL && len >= 2) {
|
||||
const char* usageType = ures_getKey(contextTransformUsage);
|
||||
if (usageType != NULL) {
|
||||
const ContextUsageTypeNameToEnumValue * typeMapPtr = contextUsageTypeMap;
|
||||
int32_t compResult = 0;
|
||||
// linear search; list is short and we cannot be sure that bsearch is available
|
||||
while ( typeMapPtr->usageTypeName != NULL && (compResult = uprv_strcmp(usageType, typeMapPtr->usageTypeName)) > 0 ) {
|
||||
++typeMapPtr;
|
||||
}
|
||||
if (typeMapPtr->usageTypeName != NULL && compResult == 0) {
|
||||
fCapitalization[typeMapPtr->usageTypeEnumValue][0] = intVector[0];
|
||||
fCapitalization[typeMapPtr->usageTypeEnumValue][1] = intVector[1];
|
||||
}
|
||||
}
|
||||
const char* usageType = ures_getKey(contextTransformUsage);
|
||||
if (usageType != NULL) {
|
||||
const ContextUsageTypeNameToEnumValue * typeMapPtr = contextUsageTypeMap;
|
||||
int32_t compResult = 0;
|
||||
// linear search; list is short and we cannot be sure that bsearch is available
|
||||
while ( typeMapPtr->usageTypeName != NULL && (compResult = uprv_strcmp(usageType, typeMapPtr->usageTypeName)) > 0 ) {
|
||||
++typeMapPtr;
|
||||
}
|
||||
if (typeMapPtr->usageTypeName != NULL && compResult == 0) {
|
||||
fCapitalization[typeMapPtr->usageTypeEnumValue][0] = intVector[0];
|
||||
fCapitalization[typeMapPtr->usageTypeEnumValue][1] = intVector[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
tempStatus = U_ZERO_ERROR;
|
||||
ures_close(contextTransformUsage);
|
||||
|
@ -1447,11 +1486,13 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
ures_close(localeBundle);
|
||||
}
|
||||
|
||||
UResourceBundle *lsweekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *weekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *abbrWeekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *shorterWeekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *narrowWeekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *standaloneWeekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *standaloneShortWeekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *standaloneAbbrWeekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *standaloneShorterWeekdaysData = NULL; // Data closed by calData
|
||||
UResourceBundle *standaloneNarrowWeekdaysData = NULL; // Data closed by calData
|
||||
|
||||
U_LOCALE_BASED(locBased, *this);
|
||||
|
@ -1477,9 +1518,11 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
initField(&fStandaloneNarrowMonths, fStandaloneNarrowMonthsCount, (const UChar *)gLastResortMonthNames, kMonthNum, kMonthLen, status);
|
||||
initField(&fWeekdays, fWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
|
||||
initField(&fShortWeekdays, fShortWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
|
||||
initField(&fShorterWeekdays, fShorterWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
|
||||
initField(&fNarrowWeekdays, fNarrowWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
|
||||
initField(&fStandaloneWeekdays, fStandaloneWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
|
||||
initField(&fStandaloneShortWeekdays, fStandaloneShortWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
|
||||
initField(&fStandaloneShorterWeekdays, fStandaloneShorterWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
|
||||
initField(&fStandaloneNarrowWeekdays, fStandaloneNarrowWeekdaysCount, (const UChar *)gLastResortDayNames, kDayNum, kDayLen, status);
|
||||
initField(&fAmPms, fAmPmsCount, (const UChar *)gLastResortAmPmMarkers, kAmPmNum, kAmPmLen, status);
|
||||
initField(&fQuarters, fQuartersCount, (const UChar *)gLastResortQuarters, kQuarterNum, kQuarterLen, status);
|
||||
|
@ -1563,6 +1606,7 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
*/
|
||||
fLocalPatternChars.setTo(TRUE, gPatternChars, PATTERN_CHARS_LEN);
|
||||
|
||||
// Format wide weekdays -> fWeekdays
|
||||
// {sfb} fixed to handle 1-based weekdays
|
||||
weekdaysData = calData.getByKey2(gDayNamesTag, gNamesWideTag, status);
|
||||
fWeekdaysCount = ures_getSize(weekdaysData);
|
||||
|
@ -1580,8 +1624,9 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
}
|
||||
fWeekdaysCount++;
|
||||
|
||||
lsweekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status);
|
||||
fShortWeekdaysCount = ures_getSize(lsweekdaysData);
|
||||
// Format abbreviated weekdays -> fShortWeekdays
|
||||
abbrWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status);
|
||||
fShortWeekdaysCount = ures_getSize(abbrWeekdaysData);
|
||||
fShortWeekdays = new UnicodeString[fShortWeekdaysCount+1];
|
||||
/* test for NULL */
|
||||
if (fShortWeekdays == 0) {
|
||||
|
@ -1590,12 +1635,34 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
}
|
||||
// leave fShortWeekdays[0] empty
|
||||
for(i = 0; i<fShortWeekdaysCount; i++) {
|
||||
resStr = ures_getStringByIndex(lsweekdaysData, i, &len, &status);
|
||||
resStr = ures_getStringByIndex(abbrWeekdaysData, i, &len, &status);
|
||||
// setTo() - see assignArray comments
|
||||
fShortWeekdays[i+1].setTo(TRUE, resStr, len);
|
||||
}
|
||||
fShortWeekdaysCount++;
|
||||
|
||||
// Format short weekdays -> fShorterWeekdays (fall back to abbreviated)
|
||||
shorterWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesShortTag, status);
|
||||
if ( status == U_MISSING_RESOURCE_ERROR ) {
|
||||
status = U_ZERO_ERROR;
|
||||
shorterWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status);
|
||||
}
|
||||
fShorterWeekdaysCount = ures_getSize(shorterWeekdaysData);
|
||||
fShorterWeekdays = new UnicodeString[fShorterWeekdaysCount+1];
|
||||
/* test for NULL */
|
||||
if (fShorterWeekdays == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
// leave fShorterWeekdays[0] empty
|
||||
for(i = 0; i<fShorterWeekdaysCount; i++) {
|
||||
resStr = ures_getStringByIndex(shorterWeekdaysData, i, &len, &status);
|
||||
// setTo() - see assignArray comments
|
||||
fShorterWeekdays[i+1].setTo(TRUE, resStr, len);
|
||||
}
|
||||
fShorterWeekdaysCount++;
|
||||
|
||||
// Format narrow weekdays -> fNarrowWeekdays
|
||||
narrowWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesNarrowTag, status);
|
||||
if(status == U_MISSING_RESOURCE_ERROR) {
|
||||
status = U_ZERO_ERROR;
|
||||
|
@ -1620,6 +1687,7 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
}
|
||||
fNarrowWeekdaysCount++;
|
||||
|
||||
// Stand-alone wide weekdays -> fStandaloneWeekdays
|
||||
standaloneWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesWideTag, status);
|
||||
if ( status == U_MISSING_RESOURCE_ERROR ) {
|
||||
status = U_ZERO_ERROR;
|
||||
|
@ -1640,12 +1708,13 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
}
|
||||
fStandaloneWeekdaysCount++;
|
||||
|
||||
standaloneShortWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesAbbrTag, status);
|
||||
// Stand-alone abbreviated weekdays -> fStandaloneShortWeekdays
|
||||
standaloneAbbrWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesAbbrTag, status);
|
||||
if ( status == U_MISSING_RESOURCE_ERROR ) {
|
||||
status = U_ZERO_ERROR;
|
||||
standaloneShortWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status);
|
||||
standaloneAbbrWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status);
|
||||
}
|
||||
fStandaloneShortWeekdaysCount = ures_getSize(standaloneShortWeekdaysData);
|
||||
fStandaloneShortWeekdaysCount = ures_getSize(standaloneAbbrWeekdaysData);
|
||||
fStandaloneShortWeekdays = new UnicodeString[fStandaloneShortWeekdaysCount+1];
|
||||
/* test for NULL */
|
||||
if (fStandaloneShortWeekdays == 0) {
|
||||
|
@ -1654,12 +1723,34 @@ DateFormatSymbols::initializeData(const Locale& locale, const char *type, UError
|
|||
}
|
||||
// leave fStandaloneShortWeekdays[0] empty
|
||||
for(i = 0; i<fStandaloneShortWeekdaysCount; i++) {
|
||||
resStr = ures_getStringByIndex(standaloneShortWeekdaysData, i, &len, &status);
|
||||
resStr = ures_getStringByIndex(standaloneAbbrWeekdaysData, i, &len, &status);
|
||||
// setTo() - see assignArray comments
|
||||
fStandaloneShortWeekdays[i+1].setTo(TRUE, resStr, len);
|
||||
}
|
||||
fStandaloneShortWeekdaysCount++;
|
||||
|
||||
// Stand-alone short weekdays -> fStandaloneShorterWeekdays (fall back to format abbreviated)
|
||||
standaloneShorterWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesShortTag, status);
|
||||
if ( status == U_MISSING_RESOURCE_ERROR ) {
|
||||
status = U_ZERO_ERROR;
|
||||
standaloneShorterWeekdaysData = calData.getByKey2(gDayNamesTag, gNamesAbbrTag, status);
|
||||
}
|
||||
fStandaloneShorterWeekdaysCount = ures_getSize(standaloneShorterWeekdaysData);
|
||||
fStandaloneShorterWeekdays = new UnicodeString[fStandaloneShorterWeekdaysCount+1];
|
||||
/* test for NULL */
|
||||
if (fStandaloneShorterWeekdays == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
// leave fStandaloneShorterWeekdays[0] empty
|
||||
for(i = 0; i<fStandaloneShorterWeekdaysCount; i++) {
|
||||
resStr = ures_getStringByIndex(standaloneShorterWeekdaysData, i, &len, &status);
|
||||
// setTo() - see assignArray comments
|
||||
fStandaloneShorterWeekdays[i+1].setTo(TRUE, resStr, len);
|
||||
}
|
||||
fStandaloneShorterWeekdaysCount++;
|
||||
|
||||
// Stand-alone narrow weekdays -> fStandaloneNarrowWeekdays
|
||||
standaloneNarrowWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesNarrowTag, status);
|
||||
if ( status == U_MISSING_RESOURCE_ERROR ) {
|
||||
status = U_ZERO_ERROR;
|
||||
|
|
|
@ -1343,6 +1343,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
|
|||
break;
|
||||
|
||||
// for "ee" or "e", use local numeric day-of-the-week
|
||||
// for "EEEEEE" or "eeeeee", write out the short day-of-the-week name
|
||||
// for "EEEEE" or "eeeee", write out the narrow day-of-the-week name
|
||||
// for "EEEE" or "eeee", write out the wide day-of-the-week name
|
||||
// for "EEE" or "EE" or "E" or "eee", write out the abbreviated day-of-the-week name
|
||||
|
@ -1367,6 +1368,10 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
|
|||
_appendSymbol(appendTo, value, fSymbols->fWeekdays,
|
||||
fSymbols->fWeekdaysCount);
|
||||
capContextUsageType = DateFormatSymbols::kCapContextUsageDayFormat;
|
||||
} else if (count == 6) {
|
||||
_appendSymbol(appendTo, value, fSymbols->fShorterWeekdays,
|
||||
fSymbols->fShorterWeekdaysCount);
|
||||
capContextUsageType = DateFormatSymbols::kCapContextUsageDayFormat;
|
||||
} else {
|
||||
_appendSymbol(appendTo, value, fSymbols->fShortWeekdays,
|
||||
fSymbols->fShortWeekdaysCount);
|
||||
|
@ -1377,6 +1382,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
|
|||
// for "ccc", write out the abbreviated day-of-the-week name
|
||||
// for "cccc", write out the wide day-of-the-week name
|
||||
// for "ccccc", use the narrow day-of-the-week name
|
||||
// for "ccccc", use the short day-of-the-week name
|
||||
case UDAT_STANDALONE_DAY_FIELD:
|
||||
if ( count < 3 ) {
|
||||
zeroPaddingNumber(currentNumberFormat,appendTo, value, 1, maxIntCount);
|
||||
|
@ -1396,6 +1402,10 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
|
|||
_appendSymbol(appendTo, value, fSymbols->fStandaloneWeekdays,
|
||||
fSymbols->fStandaloneWeekdaysCount);
|
||||
capContextUsageType = DateFormatSymbols::kCapContextUsageDayStandalone;
|
||||
} else if (count == 6) {
|
||||
_appendSymbol(appendTo, value, fSymbols->fStandaloneShorterWeekdays,
|
||||
fSymbols->fStandaloneShorterWeekdaysCount);
|
||||
capContextUsageType = DateFormatSymbols::kCapContextUsageDayStandalone;
|
||||
} else { // count == 3
|
||||
_appendSymbol(appendTo, value, fSymbols->fStandaloneShortWeekdays,
|
||||
fSymbols->fStandaloneShortWeekdaysCount);
|
||||
|
@ -2706,16 +2716,20 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
|
|||
case UDAT_DAY_OF_WEEK_FIELD:
|
||||
{
|
||||
// Want to be able to parse both short and long forms.
|
||||
// Try count == 4 (EEEE) first:
|
||||
// Try count == 4 (EEEE) wide first:
|
||||
int32_t newStart = 0;
|
||||
if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
|
||||
fSymbols->fWeekdays, fSymbols->fWeekdaysCount, NULL, cal)) > 0)
|
||||
return newStart;
|
||||
// EEEE failed, now try EEE
|
||||
// EEEE wide failed, now try EEE abbreviated
|
||||
else if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
|
||||
fSymbols->fShortWeekdays, fSymbols->fShortWeekdaysCount, NULL, cal)) > 0)
|
||||
return newStart;
|
||||
// EEE failed, now try EEEEE
|
||||
// EEE abbreviated failed, now try EEEEEE short
|
||||
else if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
|
||||
fSymbols->fShorterWeekdays, fSymbols->fShorterWeekdaysCount, NULL, cal)) > 0)
|
||||
return newStart;
|
||||
// EEEEEE short failed, now try EEEEE narrow
|
||||
else if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
|
||||
fSymbols->fNarrowWeekdays, fSymbols->fNarrowWeekdaysCount, NULL, cal)) > 0)
|
||||
return newStart;
|
||||
|
@ -2742,6 +2756,9 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
|
|||
else if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
|
||||
fSymbols->fStandaloneShortWeekdays, fSymbols->fStandaloneShortWeekdaysCount, NULL, cal)) > 0)
|
||||
return newStart;
|
||||
else if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
|
||||
fSymbols->fStandaloneShorterWeekdays, fSymbols->fStandaloneShorterWeekdaysCount, NULL, cal)) > 0)
|
||||
return newStart;
|
||||
else if (!lenient)
|
||||
return newStart;
|
||||
// else we allowing parsing as number, below
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2012, International Business Machines
|
||||
* Copyright (C) 1996-2013, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -432,9 +432,9 @@ udat_getSymbols(const UDateFormat *fmt,
|
|||
const SimpleDateFormat* sdtfmt;
|
||||
const RelativeDateFormat* rdtfmt;
|
||||
if ((sdtfmt = dynamic_cast<const SimpleDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
|
||||
syms = sdtfmt->getDateFormatSymbols();
|
||||
syms = sdtfmt->getDateFormatSymbols();
|
||||
} else if ((rdtfmt = dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
|
||||
syms = rdtfmt->getDateFormatSymbols();
|
||||
syms = rdtfmt->getDateFormatSymbols();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
@ -486,6 +486,10 @@ udat_getSymbols(const UDateFormat *fmt,
|
|||
res = syms->getMonths(count, DateFormatSymbols::FORMAT, DateFormatSymbols::NARROW);
|
||||
break;
|
||||
|
||||
case UDAT_SHORTER_WEEKDAYS:
|
||||
res = syms->getWeekdays(count, DateFormatSymbols::FORMAT, DateFormatSymbols::SHORT);
|
||||
break;
|
||||
|
||||
case UDAT_NARROW_WEEKDAYS:
|
||||
res = syms->getWeekdays(count, DateFormatSymbols::FORMAT, DateFormatSymbols::NARROW);
|
||||
break;
|
||||
|
@ -510,6 +514,10 @@ udat_getSymbols(const UDateFormat *fmt,
|
|||
res = syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::ABBREVIATED);
|
||||
break;
|
||||
|
||||
case UDAT_STANDALONE_SHORTER_WEEKDAYS:
|
||||
res = syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::SHORT);
|
||||
break;
|
||||
|
||||
case UDAT_STANDALONE_NARROW_WEEKDAYS:
|
||||
res = syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::NARROW);
|
||||
break;
|
||||
|
@ -547,9 +555,9 @@ udat_countSymbols( const UDateFormat *fmt,
|
|||
const SimpleDateFormat* sdtfmt;
|
||||
const RelativeDateFormat* rdtfmt;
|
||||
if ((sdtfmt = dynamic_cast<const SimpleDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
|
||||
syms = sdtfmt->getDateFormatSymbols();
|
||||
syms = sdtfmt->getDateFormatSymbols();
|
||||
} else if ((rdtfmt = dynamic_cast<const RelativeDateFormat*>(reinterpret_cast<const DateFormat*>(fmt))) != NULL) {
|
||||
syms = rdtfmt->getDateFormatSymbols();
|
||||
syms = rdtfmt->getDateFormatSymbols();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -592,6 +600,10 @@ udat_countSymbols( const UDateFormat *fmt,
|
|||
syms->getMonths(count, DateFormatSymbols::FORMAT, DateFormatSymbols::NARROW);
|
||||
break;
|
||||
|
||||
case UDAT_SHORTER_WEEKDAYS:
|
||||
syms->getWeekdays(count, DateFormatSymbols::FORMAT, DateFormatSymbols::SHORT);
|
||||
break;
|
||||
|
||||
case UDAT_NARROW_WEEKDAYS:
|
||||
syms->getWeekdays(count, DateFormatSymbols::FORMAT, DateFormatSymbols::NARROW);
|
||||
break;
|
||||
|
@ -616,6 +628,10 @@ udat_countSymbols( const UDateFormat *fmt,
|
|||
syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::ABBREVIATED);
|
||||
break;
|
||||
|
||||
case UDAT_STANDALONE_SHORTER_WEEKDAYS:
|
||||
syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::SHORT);
|
||||
break;
|
||||
|
||||
case UDAT_STANDALONE_NARROW_WEEKDAYS:
|
||||
syms->getWeekdays(count, DateFormatSymbols::STANDALONE, DateFormatSymbols::NARROW);
|
||||
break;
|
||||
|
@ -754,6 +770,13 @@ public:
|
|||
setSymbol(syms->fShortWeekdays, syms->fShortWeekdaysCount, index, value, valueLength, errorCode);
|
||||
}
|
||||
|
||||
static void
|
||||
setShorterWeekday(DateFormatSymbols *syms, int32_t index,
|
||||
const UChar *value, int32_t valueLength, UErrorCode &errorCode)
|
||||
{
|
||||
setSymbol(syms->fShorterWeekdays, syms->fShorterWeekdaysCount, index, value, valueLength, errorCode);
|
||||
}
|
||||
|
||||
static void
|
||||
setNarrowWeekday(DateFormatSymbols *syms, int32_t index,
|
||||
const UChar *value, int32_t valueLength, UErrorCode &errorCode)
|
||||
|
@ -775,6 +798,13 @@ public:
|
|||
setSymbol(syms->fStandaloneShortWeekdays, syms->fStandaloneShortWeekdaysCount, index, value, valueLength, errorCode);
|
||||
}
|
||||
|
||||
static void
|
||||
setStandaloneShorterWeekday(DateFormatSymbols *syms, int32_t index,
|
||||
const UChar *value, int32_t valueLength, UErrorCode &errorCode)
|
||||
{
|
||||
setSymbol(syms->fStandaloneShorterWeekdays, syms->fStandaloneShorterWeekdaysCount, index, value, valueLength, errorCode);
|
||||
}
|
||||
|
||||
static void
|
||||
setStandaloneNarrowWeekday(DateFormatSymbols *syms, int32_t index,
|
||||
const UChar *value, int32_t valueLength, UErrorCode &errorCode)
|
||||
|
@ -881,6 +911,10 @@ udat_setSymbols( UDateFormat *format,
|
|||
DateFormatSymbolsSingleSetter::setShortWeekday(syms, index, value, valueLength, *status);
|
||||
break;
|
||||
|
||||
case UDAT_SHORTER_WEEKDAYS:
|
||||
DateFormatSymbolsSingleSetter::setShorterWeekday(syms, index, value, valueLength, *status);
|
||||
break;
|
||||
|
||||
case UDAT_NARROW_WEEKDAYS:
|
||||
DateFormatSymbolsSingleSetter::setNarrowWeekday(syms, index, value, valueLength, *status);
|
||||
break;
|
||||
|
@ -893,6 +927,10 @@ udat_setSymbols( UDateFormat *format,
|
|||
DateFormatSymbolsSingleSetter::setStandaloneShortWeekday(syms, index, value, valueLength, *status);
|
||||
break;
|
||||
|
||||
case UDAT_STANDALONE_SHORTER_WEEKDAYS:
|
||||
DateFormatSymbolsSingleSetter::setStandaloneShorterWeekday(syms, index, value, valueLength, *status);
|
||||
break;
|
||||
|
||||
case UDAT_STANDALONE_NARROW_WEEKDAYS:
|
||||
DateFormatSymbolsSingleSetter::setStandaloneNarrowWeekday(syms, index, value, valueLength, *status);
|
||||
break;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 1997-2012, International Business Machines
|
||||
* Copyright (C) 1997-2013, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
|
@ -283,6 +283,13 @@ public:
|
|||
ABBREVIATED,
|
||||
WIDE,
|
||||
NARROW,
|
||||
/**
|
||||
* Short width is currently only supported for weekday names.
|
||||
* @draft ICU 51
|
||||
*/
|
||||
SHORT,
|
||||
/**
|
||||
*/
|
||||
DT_WIDTH_COUNT
|
||||
};
|
||||
|
||||
|
@ -308,7 +315,7 @@ public:
|
|||
void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
|
||||
|
||||
/**
|
||||
* Gets weekday strings. For example: "Sunday", "Monday", etc.
|
||||
* Gets wide weekday strings. For example: "Sunday", "Monday", etc.
|
||||
* @param count Filled in with length of the array.
|
||||
* @return the weekday strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 2.0
|
||||
|
@ -317,7 +324,7 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* Sets weekday strings. For example: "Sunday", "Monday", etc.
|
||||
* Sets wide weekday strings. For example: "Sunday", "Monday", etc.
|
||||
* @param weekdays the new weekday strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* @stable ICU 2.0
|
||||
|
@ -325,26 +332,28 @@ public:
|
|||
void setWeekdays(const UnicodeString* weekdays, int32_t count);
|
||||
|
||||
/**
|
||||
* Gets short weekday strings. For example: "Sun", "Mon", etc.
|
||||
* Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
|
||||
* misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
|
||||
* @param count Filled in with length of the array.
|
||||
* @return the short weekday strings. (DateFormatSymbols retains ownership.)
|
||||
* @return the abbreviated weekday strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
const UnicodeString* getShortWeekdays(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Sets short weekday strings. For example: "Sun", "Mon", etc.
|
||||
* @param shortWeekdays the new short weekday strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
|
||||
* misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
|
||||
* @param abbrevWeekdays the new abbreviated weekday strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setShortWeekdays(const UnicodeString* shortWeekdays, int32_t count);
|
||||
void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
|
||||
|
||||
/**
|
||||
* Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
|
||||
* @param count Filled in with length of the array.
|
||||
* @param context The formatting context, either FORMAT or STANDALONE
|
||||
* @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW
|
||||
* @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
|
||||
* @return the month strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
|
@ -355,7 +364,7 @@ public:
|
|||
* @param weekdays The new weekday strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* @param context The formatting context, either FORMAT or STANDALONE
|
||||
* @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW
|
||||
* @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
|
||||
|
@ -593,35 +602,47 @@ private:
|
|||
int32_t fStandaloneNarrowMonthsCount;
|
||||
|
||||
/**
|
||||
* Weekday strings. For example: "Sunday", "Monday", etc.
|
||||
* CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc.
|
||||
*/
|
||||
UnicodeString* fWeekdays;
|
||||
int32_t fWeekdaysCount;
|
||||
|
||||
/**
|
||||
* Short weekday strings. For example: "Sun", "Mon", etc.
|
||||
* CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
|
||||
*/
|
||||
UnicodeString* fShortWeekdays;
|
||||
int32_t fShortWeekdaysCount;
|
||||
|
||||
/**
|
||||
* Narrow weekday strings. For example: "Sun", "Mon", etc.
|
||||
* CLDR-style format short weekday strings. For example: "Su", "Mo", etc.
|
||||
*/
|
||||
UnicodeString* fShorterWeekdays;
|
||||
int32_t fShorterWeekdaysCount;
|
||||
|
||||
/**
|
||||
* CLDR-style format narrow weekday strings. For example: "S", "M", etc.
|
||||
*/
|
||||
UnicodeString* fNarrowWeekdays;
|
||||
int32_t fNarrowWeekdaysCount;
|
||||
|
||||
/**
|
||||
* Standalone Weekday strings. For example: "Sunday", "Monday", etc.
|
||||
* CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc.
|
||||
*/
|
||||
UnicodeString* fStandaloneWeekdays;
|
||||
int32_t fStandaloneWeekdaysCount;
|
||||
|
||||
/**
|
||||
* Standalone Short weekday strings. For example: "Sun", "Mon", etc.
|
||||
* CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
|
||||
*/
|
||||
UnicodeString* fStandaloneShortWeekdays;
|
||||
int32_t fStandaloneShortWeekdaysCount;
|
||||
|
||||
/**
|
||||
* CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc.
|
||||
*/
|
||||
UnicodeString* fStandaloneShorterWeekdays;
|
||||
int32_t fStandaloneShorterWeekdaysCount;
|
||||
|
||||
/**
|
||||
* Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2012, International Business Machines
|
||||
* Copyright (C) 1996-2013, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -1077,9 +1077,12 @@ typedef enum UDateFormatSymbolType {
|
|||
UDAT_MONTHS,
|
||||
/** The short month names, for example Feb. */
|
||||
UDAT_SHORT_MONTHS,
|
||||
/** The weekday names, for example Monday */
|
||||
/** The CLDR-style format "wide" weekday names, for example Monday */
|
||||
UDAT_WEEKDAYS,
|
||||
/** The short weekday names, for example Mon. */
|
||||
/**
|
||||
* The CLDR-style format "abbreviated" (not "short") weekday names, for example "Mon."
|
||||
* For the CLDR-style format "short" weekday names, use UDAT_SHORTER_WEEKDAYS.
|
||||
*/
|
||||
UDAT_SHORT_WEEKDAYS,
|
||||
/** The AM/PM names, for example AM */
|
||||
UDAT_AM_PMS,
|
||||
|
@ -1089,15 +1092,20 @@ typedef enum UDateFormatSymbolType {
|
|||
UDAT_ERA_NAMES,
|
||||
/** The narrow month names, for example F */
|
||||
UDAT_NARROW_MONTHS,
|
||||
/** The narrow weekday names, for example N */
|
||||
/** The CLDR-style format "narrow" weekday names, for example "M" */
|
||||
UDAT_NARROW_WEEKDAYS,
|
||||
/** Standalone context versions of months */
|
||||
UDAT_STANDALONE_MONTHS,
|
||||
UDAT_STANDALONE_SHORT_MONTHS,
|
||||
UDAT_STANDALONE_NARROW_MONTHS,
|
||||
/** Standalone context versions of weekdays */
|
||||
/** The CLDR-style stand-alone "wide" weekday names */
|
||||
UDAT_STANDALONE_WEEKDAYS,
|
||||
/**
|
||||
* The CLDR-style stand-alone "abbreviated" (not "short") weekday names.
|
||||
* For the CLDR-style stand-alone "short" weekday names, use UDAT_STANDALONE_SHORTER_WEEKDAYS.
|
||||
*/
|
||||
UDAT_STANDALONE_SHORT_WEEKDAYS,
|
||||
/** The CLDR-style stand-alone "narrow" weekday names */
|
||||
UDAT_STANDALONE_NARROW_WEEKDAYS,
|
||||
/** The quarters, for example 1st Quarter */
|
||||
UDAT_QUARTERS,
|
||||
|
@ -1105,7 +1113,16 @@ typedef enum UDateFormatSymbolType {
|
|||
UDAT_SHORT_QUARTERS,
|
||||
/** Standalone context versions of quarters */
|
||||
UDAT_STANDALONE_QUARTERS,
|
||||
UDAT_STANDALONE_SHORT_QUARTERS
|
||||
UDAT_STANDALONE_SHORT_QUARTERS,
|
||||
/**
|
||||
* The CLDR-style short weekday names, e.g. "Su", Mo", etc.
|
||||
* These are named "SHORTER" to contrast with the constants using _SHORT_
|
||||
* above, which actually get the CLDR-style *abbreviated* versions of the
|
||||
* corresponding names.
|
||||
* @draft ICU 51
|
||||
*/
|
||||
UDAT_SHORTER_WEEKDAYS,
|
||||
UDAT_STANDALONE_SHORTER_WEEKDAYS
|
||||
|
||||
} UDateFormatSymbolType;
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ void DateFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &nam
|
|||
TESTCASE_AUTO(TestHost);
|
||||
TESTCASE_AUTO(TestEras);
|
||||
TESTCASE_AUTO(TestNarrowNames);
|
||||
TESTCASE_AUTO(TestShortDays);
|
||||
TESTCASE_AUTO(TestStandAloneDays);
|
||||
TESTCASE_AUTO(TestStandAloneMonths);
|
||||
TESTCASE_AUTO(TestQuarters);
|
||||
|
@ -1616,6 +1617,30 @@ void DateFormatTest::TestStandAloneDays()
|
|||
expect(CS_DATA, ARRAY_SIZE(CS_DATA), Locale("cs", "", ""));
|
||||
}
|
||||
|
||||
void DateFormatTest::TestShortDays()
|
||||
{
|
||||
const char *EN_DATA[] = {
|
||||
"yyyy MM dd HH:mm:ss",
|
||||
|
||||
"EEEEEE, MMM d y", "fp", "2013 01 13 0:00:00", "Su, Jan 13 2013", "2013 01 13 0:00:00",
|
||||
"EEEEEE, MMM d y", "fp", "2013 01 16 0:00:00", "We, Jan 16 2013", "2013 01 16 0:00:00",
|
||||
"EEEEEE d", "fp", "1970 01 17 0:00:00", "Sa 17", "1970 01 17 0:00:00",
|
||||
"cccccc d", "fp", "1970 01 17 0:00:00", "Sa 17", "1970 01 17 0:00:00",
|
||||
"cccccc", "fp", "1970 01 03 0:00:00", "Sa", "1970 01 03 0:00:00",
|
||||
};
|
||||
const char *SV_DATA[] = {
|
||||
"yyyy MM dd HH:mm:ss",
|
||||
|
||||
"EEEEEE d MMM y", "fp", "2013 01 13 0:00:00", "s\\u00F6 13 jan 2013", "2013 01 13 0:00:00",
|
||||
"EEEEEE d MMM y", "fp", "2013 01 16 0:00:00", "on 16 jan 2013", "2013 01 16 0:00:00",
|
||||
"EEEEEE d", "fp", "1970 01 17 0:00:00", "l\\u00F6 17", "1970 01 17 0:00:00",
|
||||
"cccccc d", "fp", "1970 01 17 0:00:00", "L\\u00F6 17", "1970 01 17 0:00:00",
|
||||
"cccccc", "fp", "1970 01 03 0:00:00", "L\\u00F6", "1970 01 03 0:00:00",
|
||||
};
|
||||
expect(EN_DATA, ARRAY_SIZE(EN_DATA), Locale("en", "", ""));
|
||||
expect(SV_DATA, ARRAY_SIZE(SV_DATA), Locale("sv", "", ""));
|
||||
}
|
||||
|
||||
void DateFormatTest::TestNarrowNames()
|
||||
{
|
||||
const char *EN_DATA[] = {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2012, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2013, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
|
||||
|
@ -194,12 +194,14 @@ public:
|
|||
|
||||
public:
|
||||
/**
|
||||
* Test patterns added in CLDR 1.4
|
||||
* Test patterns added in CLDR 1.4, CLDR 23
|
||||
*/
|
||||
void TestEras(void);
|
||||
|
||||
void TestNarrowNames(void);
|
||||
|
||||
void TestShortDays(void);
|
||||
|
||||
void TestStandAloneDays(void);
|
||||
|
||||
void TestStandAloneMonths(void);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/********************************************************************
|
||||
* Copyright (c) 1997-2011, International Business Machines
|
||||
* Copyright (c) 1997-2013, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
|
||||
|
@ -26,6 +26,7 @@ void IntlTestDateFormatSymbols::runIndexedTest( int32_t index, UBool exec, const
|
|||
TESTCASE(2,TestGetMonths2);
|
||||
TESTCASE(3,TestGetWeekdays2);
|
||||
TESTCASE(4,TestGetEraNames);
|
||||
TESTCASE(5,TestGetSetSpecificItems);
|
||||
default: name = ""; break;
|
||||
}
|
||||
}
|
||||
|
@ -126,6 +127,41 @@ void IntlTestDateFormatSymbols::TestGetEraNames()
|
|||
delete symbol;
|
||||
}
|
||||
|
||||
UBool IntlTestDateFormatSymbols::UnicodeStringsArePrefixes(int32_t count, int32_t prefixLen, const UnicodeString *prefixArray, const UnicodeString *baseArray)
|
||||
{
|
||||
int32_t i;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (baseArray[i].compare(0, prefixLen, prefixArray[i]) != 0) {
|
||||
errln("ERROR: Mismatch example: expect prefix \"" + prefixArray[i] + "\" of base \"" + baseArray[i] + "\".");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void IntlTestDateFormatSymbols::TestGetSetSpecificItems()
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
DateFormatSymbols *symbol=new DateFormatSymbols(Locale::getEnglish(), status);
|
||||
if(U_FAILURE(status)) {
|
||||
dataerrln("ERROR: Couldn't create English DateFormatSymbols " + (UnicodeString)u_errorName(status));
|
||||
return;
|
||||
}
|
||||
int32_t cntFmtAbbrev, cntFmtShort, cntStdAloneShort;
|
||||
const UnicodeString * wdFmtAbbrev = symbol->getWeekdays(cntFmtAbbrev,DateFormatSymbols::FORMAT,DateFormatSymbols::ABBREVIATED);
|
||||
const UnicodeString * wdFmtShort = symbol->getWeekdays(cntFmtShort,DateFormatSymbols::FORMAT,DateFormatSymbols::SHORT);
|
||||
const UnicodeString * wdStdAloneShort = symbol->getWeekdays(cntStdAloneShort,DateFormatSymbols::STANDALONE,DateFormatSymbols::SHORT);
|
||||
// Expect that English short names are prefixes of abbreviated names
|
||||
if (cntFmtShort != cntFmtAbbrev || !UnicodeStringsArePrefixes(cntFmtAbbrev, 2, wdFmtShort, wdFmtAbbrev)) {
|
||||
errln("ERROR: English format short weekday names don't match prefixes of format abbreviated names");
|
||||
}
|
||||
if (cntStdAloneShort != cntFmtAbbrev || !UnicodeStringsArePrefixes(cntFmtAbbrev, 2, wdStdAloneShort, wdFmtAbbrev)) {
|
||||
errln("ERROR: English standalone short weekday names don't match prefixes of format abbreviated names");
|
||||
}
|
||||
|
||||
delete symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the API of DateFormatSymbols; primarily a simple get/set set.
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2005, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2013, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
|
||||
|
@ -32,6 +32,9 @@ private:
|
|||
|
||||
void TestGetWeekdays2(void);
|
||||
void TestGetEraNames(void);
|
||||
void TestGetSetSpecificItems(void);
|
||||
|
||||
UBool UnicodeStringsArePrefixes(int32_t count, int32_t prefixLen, const UnicodeString *prefixArray, const UnicodeString *baseArray);
|
||||
};
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
|
Loading…
Add table
Reference in a new issue