Logo Search packages:      
Sourcecode: icu version File versions  Download package

U_STABLE int32_t U_EXPORT2 ucal_getTimeZoneDisplayName ( const UCalendar cal,
UCalendarDisplayNameType  type,
const char *  locale,
UChar result,
int32_t  resultLength,
UErrorCode status 
)

Get the display name for a UCalendar's TimeZone. A display name is suitable for presentation to a user.

Parameters:
calThe UCalendar to query.
typeThe desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD, UCAL_DST, UCAL_SHORT_DST
localeThe desired locale for the display name.
resultA pointer to a buffer to receive the formatted number.
resultLengthThe maximum size of result.
statusA pointer to an UErrorCode to receive any errors
Returns:
The total buffer size needed; if greater than resultLength, the output was truncated. ICU 2.0

Definition at line 190 of file ucal.cpp.

References UnicodeString::extract(), FALSE, TimeZone::getDisplayName(), TimeZone::LONG, NULL, UnicodeString::setTo(), TimeZone::SHORT, TRUE, U_FAILURE, UCAL_DST, UCAL_SHORT_DST, UCAL_SHORT_STANDARD, and UCAL_STANDARD.

{

    if(U_FAILURE(*status)) return -1;

    const TimeZone& tz = ((Calendar*)cal)->getTimeZone();
    UnicodeString id;
    if(!(result==NULL && resultLength==0)) {
        // NULL destination for pure preflighting: empty dummy string
        // otherwise, alias the destination buffer
        id.setTo(result, 0, resultLength);
    }

    switch(type) {
  case UCAL_STANDARD:
      tz.getDisplayName(FALSE, TimeZone::LONG, Locale(locale), id);
      break;

  case UCAL_SHORT_STANDARD:
      tz.getDisplayName(FALSE, TimeZone::SHORT, Locale(locale), id);
      break;

  case UCAL_DST:
      tz.getDisplayName(TRUE, TimeZone::LONG, Locale(locale), id);
      break;

  case UCAL_SHORT_DST:
      tz.getDisplayName(TRUE, TimeZone::SHORT, Locale(locale), id);
      break;
    }

    return id.extract(result, resultLength, *status);
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index