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

DateIntervalInfo::IntervalPatternIndex DateIntervalInfo::calendarFieldToIntervalIndex ( UCalendarDateFields  field,
UErrorCode status 
) [static, private]

Convert calendar field to the interval pattern index in hash table.

Since we only support the following calendar fields: ERA, YEAR, MONTH, DATE, DAY_OF_MONTH, DAY_OF_WEEK, AM_PM, HOUR, HOUR_OF_DAY, and MINUTE, We reserve only 4 interval patterns for a skeleton.

Parameters:
field calendar field
status output param set to success/failure code on exit
Returns:
interval pattern index in hash table

For internal use only.

ICU 4.0

Definition at line 512 of file dtitvinf.cpp.

References U_FAILURE, U_ILLEGAL_ARGUMENT_ERROR, UCAL_AM_PM, UCAL_DATE, UCAL_DAY_OF_WEEK, UCAL_ERA, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_MONTH, and UCAL_YEAR.

Referenced by DateIntervalFormat::concatSingleDate2TimeInterval(), DateIntervalFormat::format(), getIntervalPattern(), and DateIntervalFormat::setPatternInfo().

                                                                   {
    if ( U_FAILURE(status) ) {
        return kIPI_MAX_INDEX;
    }
    IntervalPatternIndex index = kIPI_MAX_INDEX;
    switch ( field ) {
      case UCAL_ERA:
        index = kIPI_ERA;
        break;
      case UCAL_YEAR:
        index = kIPI_YEAR;
        break;
      case UCAL_MONTH:
        index = kIPI_MONTH;
        break;
      case UCAL_DATE:
      case UCAL_DAY_OF_WEEK:
      //case UCAL_DAY_OF_MONTH:
        index = kIPI_DATE;
        break;
      case UCAL_AM_PM:
        index = kIPI_AM_PM;
        break;
      case UCAL_HOUR:
      case UCAL_HOUR_OF_DAY:
        index = kIPI_HOUR;
        break;
      case UCAL_MINUTE:
        index = kIPI_MINUTE;
        break;
      default:
        status = U_ILLEGAL_ARGUMENT_ERROR;
    }
    return index;
}


Generated by  Doxygen 1.6.0   Back to index