/*
*******************************************************************************
-* Copyright (C) 1997-2012, International Business Machines Corporation and *
+* Copyright (C) 1997-2013, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
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";
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);
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();
}
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 &&
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) &&
returnValue = fMonths;
break;
case ABBREVIATED :
+ case SHORT : // no month data for this, defaults to ABBREVIATED
count = fShortMonthsCount;
returnValue = fShortMonths;
break;
returnValue = fStandaloneMonths;
break;
case ABBREVIATED :
+ case SHORT : // no month data for this, defaults to ABBREVIATED
count = fStandaloneShortMonthsCount;
returnValue = fStandaloneShortMonths;
break;
count = fShortWeekdaysCount;
returnValue = fShortWeekdays;
break;
+ case SHORT :
+ count = fShorterWeekdaysCount;
+ returnValue = fShorterWeekdays;
+ break;
case NARROW :
count = fNarrowWeekdaysCount;
returnValue = fNarrowWeekdays;
count = fStandaloneShortWeekdaysCount;
returnValue = fStandaloneShortWeekdays;
break;
+ case SHORT :
+ count = fStandaloneShorterWeekdaysCount;
+ returnValue = fStandaloneShorterWeekdays;
+ break;
case NARROW :
count = fStandaloneNarrowWeekdaysCount;
returnValue = fStandaloneNarrowWeekdays;
returnValue = fQuarters;
break;
case ABBREVIATED :
+ case SHORT : // no quarter data for this, defaults to ABBREVIATED
count = fShortQuartersCount;
returnValue = fShortQuarters;
break;
returnValue = fStandaloneQuarters;
break;
case ABBREVIATED :
+ case SHORT : // no quarter data for this, defaults to ABBREVIATED
count = fStandaloneShortQuartersCount;
returnValue = fStandaloneShortQuarters;
break;
uprv_arrayCopy( monthsArray,fNarrowMonths,count);
fNarrowMonthsCount = count;
break;
- case DT_WIDTH_COUNT :
+ default :
break;
}
break;
uprv_arrayCopy( monthsArray,fStandaloneNarrowMonths,count);
fStandaloneNarrowMonthsCount = count;
break;
- case DT_WIDTH_COUNT :
+ default :
break;
}
break;
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;
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;
fNarrowQuartersCount = count;
*/
break;
- case DT_WIDTH_COUNT :
+ default :
break;
}
break;
fStandaloneNarrowQuartersCount = count;
*/
break;
- case DT_WIDTH_COUNT :
+ default :
break;
}
break;
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;
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);
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);
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);
*/
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);
}
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) {
}
// 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;
}
fNarrowWeekdaysCount++;
+ // Stand-alone wide weekdays -> fStandaloneWeekdays
standaloneWeekdaysData = calData.getByKey3(gDayNamesTag, gNamesStandaloneTag, gNamesWideTag, status);
if ( status == U_MISSING_RESOURCE_ERROR ) {
status = U_ZERO_ERROR;
}
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) {
}
// 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;
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
_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);
// 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);
_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);
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;
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
/*
*******************************************************************************
-* Copyright (C) 1996-2012, International Business Machines
+* Copyright (C) 1996-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
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;
}
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;
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;
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;
}
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;
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;
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)
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)
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;
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;
/*
********************************************************************************
-* Copyright (C) 1997-2012, International Business Machines
+* Copyright (C) 1997-2013, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************************
*
ABBREVIATED,
WIDE,
NARROW,
+ /**
+ * Short width is currently only supported for weekday names.
+ * @draft ICU 51
+ */
+ SHORT,
+ /**
+ */
DT_WIDTH_COUNT
};
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
/**
- * 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
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
*/
* @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);
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.
*/
/*
*******************************************************************************
- * Copyright (C) 1996-2012, International Business Machines
+ * Copyright (C) 1996-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
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,
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,
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;
TESTCASE_AUTO(TestHost);
TESTCASE_AUTO(TestEras);
TESTCASE_AUTO(TestNarrowNames);
+ TESTCASE_AUTO(TestShortDays);
TESTCASE_AUTO(TestStandAloneDays);
TESTCASE_AUTO(TestStandAloneMonths);
TESTCASE_AUTO(TestQuarters);
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[] = {
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2012, International Business Machines Corporation and
+ * Copyright (c) 1997-2013, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
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);
/********************************************************************
- * Copyright (c) 1997-2011, International Business Machines
+ * Copyright (c) 1997-2013, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************/
TESTCASE(2,TestGetMonths2);
TESTCASE(3,TestGetWeekdays2);
TESTCASE(4,TestGetEraNames);
+ TESTCASE(5,TestGetSetSpecificItems);
default: name = ""; break;
}
}
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.
*/
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2013, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
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 */