ICU-4643 Add setters for narrow/standalone months/weekdays

X-SVN-Rev: 18702
This commit is contained in:
John Emmons 2005-10-19 17:55:18 +00:00
parent 86c1e8d7dd
commit c642152760
2 changed files with 158 additions and 3 deletions

View file

@ -16,6 +16,7 @@
* 11/16/99 weiv Added 'Y' and 'e' to fgPatternChars
* 03/27/00 weiv Keeping resource bundle around!
* 06/30/05 emmons Added eraNames, narrow month/day, standalone context
* 10/12/05 emmons Added setters for eraNames, month/day by width/context
*******************************************************************************
*/
@ -610,6 +611,19 @@ DateFormatSymbols::setEras(const UnicodeString* erasArray, int32_t count)
fErasCount = count;
}
void
DateFormatSymbols::setEraNames(const UnicodeString* eraNamesArray, int32_t count)
{
// delete the old list if we own it
if (fEraNames) delete[] fEraNames;
// we always own the new list, which we create here (we duplicate rather
// than adopting the list passed in)
fEraNames = newUnicodeStringArray(count);
uprv_arrayCopy(eraNamesArray,fEraNames, count);
fEraNamesCount = count;
}
void
DateFormatSymbols::setMonths(const UnicodeString* monthsArray, int32_t count)
{
@ -636,6 +650,62 @@ DateFormatSymbols::setShortMonths(const UnicodeString* shortMonthsArray, int32_t
fShortMonthsCount = count;
}
void
DateFormatSymbols::setMonths(const UnicodeString* monthsArray, int32_t count, DtContextType context, DtWidthType width)
{
// delete the old list if we own it
// we always own the new list, which we create here (we duplicate rather
// than adopting the list passed in)
switch (context) {
case FORMAT :
switch (width) {
case WIDE :
if (fMonths) delete[] fMonths;
fMonths = newUnicodeStringArray(count);
uprv_arrayCopy( monthsArray,fMonths,count);
fMonthsCount = count;
break;
case ABBREVIATED :
if (fShortMonths) delete[] fShortMonths;
fShortMonths = newUnicodeStringArray(count);
uprv_arrayCopy( monthsArray,fShortMonths,count);
fShortMonthsCount = count;
break;
case NARROW :
if (fNarrowMonths) delete[] fNarrowMonths;
fNarrowMonths = newUnicodeStringArray(count);
uprv_arrayCopy( monthsArray,fNarrowMonths,count);
fNarrowMonthsCount = count;
break;
}
break;
case STANDALONE :
switch (width) {
case WIDE :
if (fStandaloneMonths) delete[] fStandaloneMonths;
fStandaloneMonths = newUnicodeStringArray(count);
uprv_arrayCopy( monthsArray,fStandaloneMonths,count);
fStandaloneMonthsCount = count;
break;
case ABBREVIATED :
if (fStandaloneShortMonths) delete[] fStandaloneShortMonths;
fStandaloneShortMonths = newUnicodeStringArray(count);
uprv_arrayCopy( monthsArray,fStandaloneShortMonths,count);
fStandaloneShortMonthsCount = count;
break;
case NARROW :
if (fStandaloneNarrowMonths) delete[] fStandaloneNarrowMonths;
fStandaloneNarrowMonths = newUnicodeStringArray(count);
uprv_arrayCopy( monthsArray,fStandaloneNarrowMonths,count);
fStandaloneNarrowMonthsCount = count;
break;
}
break;
}
}
void DateFormatSymbols::setWeekdays(const UnicodeString* weekdaysArray, int32_t count)
{
// delete the old list if we own it
@ -661,6 +731,62 @@ DateFormatSymbols::setShortWeekdays(const UnicodeString* shortWeekdaysArray, int
fShortWeekdaysCount = count;
}
void
DateFormatSymbols::setWeekdays(const UnicodeString* weekdaysArray, int32_t count, DtContextType context, DtWidthType width)
{
// delete the old list if we own it
// we always own the new list, which we create here (we duplicate rather
// than adopting the list passed in)
switch (context) {
case FORMAT :
switch (width) {
case WIDE :
if (fWeekdays) delete[] fWeekdays;
fWeekdays = newUnicodeStringArray(count);
uprv_arrayCopy( weekdaysArray,fWeekdays,count);
fWeekdaysCount = count;
break;
case ABBREVIATED :
if (fShortWeekdays) delete[] fShortWeekdays;
fShortWeekdays = newUnicodeStringArray(count);
uprv_arrayCopy( weekdaysArray,fShortWeekdays,count);
fShortWeekdaysCount = count;
break;
case NARROW :
if (fNarrowWeekdays) delete[] fNarrowWeekdays;
fNarrowWeekdays = newUnicodeStringArray(count);
uprv_arrayCopy( weekdaysArray,fNarrowWeekdays,count);
fNarrowWeekdaysCount = count;
break;
}
break;
case STANDALONE :
switch (width) {
case WIDE :
if (fStandaloneWeekdays) delete[] fStandaloneWeekdays;
fStandaloneWeekdays = newUnicodeStringArray(count);
uprv_arrayCopy( weekdaysArray,fStandaloneWeekdays,count);
fStandaloneWeekdaysCount = count;
break;
case ABBREVIATED :
if (fStandaloneShortWeekdays) delete[] fStandaloneShortWeekdays;
fStandaloneShortWeekdays = newUnicodeStringArray(count);
uprv_arrayCopy( weekdaysArray,fStandaloneShortWeekdays,count);
fStandaloneShortWeekdaysCount = count;
break;
case NARROW :
if (fStandaloneNarrowWeekdays) delete[] fStandaloneNarrowWeekdays;
fStandaloneNarrowWeekdays = newUnicodeStringArray(count);
uprv_arrayCopy( weekdaysArray,fStandaloneNarrowWeekdays,count);
fStandaloneNarrowWeekdaysCount = count;
break;
}
break;
}
}
void
DateFormatSymbols::setAmPmStrings(const UnicodeString* amPmsArray, int32_t count)
{

View file

@ -202,6 +202,14 @@ public:
*/
const UnicodeString* getEraNames(int32_t& count) const;
/**
* Sets era name strings. For example: "Anno Domini" and "Before Christ".
* @param eraNames Array of era name strings (DateFormatSymbols retains ownership.)
* @param count Filled in with length of the array.
* @draft ICU 3.6
*/
void setEraNames(const UnicodeString* eraNames, int32_t count);
/**
* Gets month strings. For example: "January", "February", etc.
* @param count Filled in with length of the array.
@ -270,13 +278,24 @@ public:
/**
* Gets month strings by width and context. For example: "January", "February", etc.
* @param count Filled in with length of the array.
* @param context The day formatting context, either FORMAT or STANDALONE
* @param context The formatting context, either FORMAT or STANDALONE
* @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
* @return the month strings. (DateFormatSymbols retains ownership.)
* @draft ICU 3.4
*/
const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
/**
* Sets month strings by width and context. For example: "January", "February", etc.
*
* @param months The new month 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.
* @draft ICU 3.6
*/
void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
/**
* Gets weekday strings. For example: "Sunday", "Monday", etc.
* @param count Filled in with length of the array.
@ -313,13 +332,23 @@ public:
/**
* Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
* @param count Filled in with length of the array.
* @param context The day formatting context, either FORMAT or STANDALONE
* @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
* @param context The formatting context, either FORMAT or STANDALONE
* @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW
* @return the month strings. (DateFormatSymbols retains ownership.)
* @draft ICU 3.4
*/
const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
/**
* Sets weekday strings by width and context. 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.
* @param context The formatting context, either FORMAT or STANDALONE
* @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW
* @draft ICU 3.6
*/
void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
/**
* Gets AM/PM strings. For example: "AM" and "PM".
* @param count Filled in with length of the array.