ICU-6585 Formats with c,cc should use local day of week (and ee should have zero pad)

X-SVN-Rev: 24869
This commit is contained in:
Peter Edberg 2008-10-24 03:36:26 +00:00
parent 35f8ea1402
commit 7364736f03
2 changed files with 21 additions and 14 deletions

View file

@ -632,7 +632,7 @@ SimpleDateFormat::fgPatternIndexToCalendarField[] =
/*Yeu*/ UCAL_YEAR_WOY, UCAL_DOW_LOCAL, UCAL_EXTENDED_YEAR,
/*gAZ*/ UCAL_JULIAN_DAY, UCAL_MILLISECONDS_IN_DAY, UCAL_ZONE_OFFSET,
/*v*/ UCAL_ZONE_OFFSET,
/*c*/ UCAL_DAY_OF_WEEK,
/*c*/ UCAL_DOW_LOCAL,
/*L*/ UCAL_MONTH,
/*Q*/ UCAL_MONTH,
/*q*/ UCAL_MONTH,
@ -1141,7 +1141,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
// for "EEE" or "EE" or "E" or "eee", write out the abbreviated day-of-the-week name
case UDAT_DOW_LOCAL_FIELD:
if ( count < 3 ) {
zeroPaddingNumber(appendTo, value, 1, maxIntCount);
zeroPaddingNumber(appendTo, value, count, maxIntCount);
break;
}
// fall through to EEEEE-EEE handling, but for that we don't want local day-of-week,
@ -1167,17 +1167,25 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
// for "cccc", write out the wide day-of-the-week name
// for "ccccc", use the narrow day-of-the-week name
case UDAT_STANDALONE_DAY_FIELD:
if ( count < 3 ) {
zeroPaddingNumber(appendTo, value, 1, maxIntCount);
break;
}
// fall through to alpha DOW handling, but for that we don't want local day-of-week,
// we want standard day-of-week, so first fix value.
value = cal.get(UCAL_DAY_OF_WEEK, status);
if (U_FAILURE(status)) {
return;
}
if (count == 5)
_appendSymbol(appendTo, value, fSymbols->fStandaloneNarrowWeekdays,
fSymbols->fStandaloneNarrowWeekdaysCount);
else if (count == 4)
_appendSymbol(appendTo, value, fSymbols->fStandaloneWeekdays,
fSymbols->fStandaloneWeekdaysCount);
else if (count == 3)
else // count == 3
_appendSymbol(appendTo, value, fSymbols->fStandaloneShortWeekdays,
fSymbols->fStandaloneShortWeekdaysCount);
else
zeroPaddingNumber(appendTo, value, 1, maxIntCount);
break;
// for and "a" symbol, write out the whole AM/PM string
@ -2097,7 +2105,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
if (count <= 2) // c or cc
{
// [We computed 'value' above.]
cal.set(UCAL_DAY_OF_WEEK, value);
cal.set(UCAL_DOW_LOCAL, value);
return pos.getIndex();
}
// Want to be able to parse both short and long forms.

View file

@ -565,8 +565,8 @@ static const UChar eMyPattern[] = { 0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,
static const UChar eeMyPattern[] = { 0x65,0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "ee dd MMM yyyy" */
static const UChar cMyPattern[] = { 0x63,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "c dd MMM yyyy" */
static const UChar ccMyPattern[] = { 0x63,0x63,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "cc dd MMM yyyy" */
static const UChar eMyText[] = { 0x33,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "3 02 Jul 2008" since it uses UCAL_DOW_LOCAL */
static const UChar cMyText[] = { 0x34,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "4 02 Jul 2008" since it uses UCAL_DAY_OF_WEEK - error, ticket 6585 */
static const UChar eMyText[] = { 0x33,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "3 02 Jul 2008" */
static const UChar eeMyText[] = { 0x30,0x33,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "03 02 Jul 2008" */
static const UChar eeeMyPattern[] = { 0x65,0x65,0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "eee dd MMM yyyy" */
static const UChar EEEMyPattern[] = { 0x45,0x45,0x45,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "EEE dd MMM yyyy" */
static const UChar EEMyPattern[] = { 0x45,0x45,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "EE dd MMM yyyy" */
@ -577,21 +577,20 @@ static const UChar eeeeeMyPattern[] = { 0x65,0x65,0x65,0x65,0x65,0x20,0x64,0x64,
static const UChar eeeeeMyText[] = { 0x57,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "W 02 Jul 2008" */
static const UChar ewYPattern[] = { 0x65,0x20,0x77,0x77,0x20,0x59,0x59,0x59,0x59,0 }; /* "e ww YYYY" */
static const UChar cwYPattern[] = { 0x63,0x20,0x77,0x77,0x20,0x59,0x59,0x59,0x59,0 }; /* "c ww YYYY" */
static const UChar ewYText[] = { 0x33,0x20,0x32,0x37,0x20,0x32,0x30,0x30,0x38,0 }; /* "3 27 2008" since it uses UCAL_DOW_LOCAL */
static const UChar cwYText[] = { 0x34,0x20,0x32,0x37,0x20,0x32,0x30,0x30,0x38,0 }; /* "4 27 2008" since it uses UCAL_DAY_OF_WEEK - error, ticket 6585 */
static const UChar ewYText[] = { 0x33,0x20,0x32,0x37,0x20,0x32,0x30,0x30,0x38,0 }; /* "3 27 2008" */
static const DatePatternAndText datePatternsAndText[] = {
{ eMyPattern, eMyText, "e dd MMM" },
{ eeMyPattern, eMyText, "ee dd MMM" },
{ cMyPattern, cMyText, "c dd MMM" },
{ ccMyPattern, cMyText, "cc dd MMM" },
{ eeMyPattern, eeMyText, "ee dd MMM" },
{ cMyPattern, eMyText, "c dd MMM" },
{ ccMyPattern, eMyText, "cc dd MMM" },
{ eeeMyPattern, eeeMyText, "eee dd MMM" },
{ EEEMyPattern, eeeMyText, "EEE dd MMM" },
{ EEMyPattern, eeeMyText, "EE dd MMM" },
{ eeeeMyPattern, eeeeMyText, "eeee dd MMM" },
{ eeeeeMyPattern, eeeeeMyText, "eeeee dd MMM" },
{ ewYPattern, ewYText, "e ww" },
{ cwYPattern, cwYText, "c ww" },
{ cwYPattern, ewYText, "c ww" },
{ NULL, NULL, NULL }
};
void TestJ5726(void)