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

int32_t Calendar::getLimit ( UCalendarDateFields  field,
ELimitType  limitType 
) const [protected, virtual, inherited]

Return a limit for a field.

Parameters:
field the field, from 0..UCAL_MAX_FIELD
limitType the type specifier for the limit
See also:
ELimitType

For internal use only.

Definition at line 2154 of file calendar.cpp.

References Calendar::getMinimalDaysInFirstWeek(), Calendar::handleGetLimit(), UCAL_AM_PM, UCAL_DAY_OF_MONTH, UCAL_DAY_OF_WEEK, UCAL_DOW_LOCAL, UCAL_DST_OFFSET, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_IS_LEAP_MONTH, UCAL_JULIAN_DAY, UCAL_MILLISECOND, UCAL_MILLISECONDS_IN_DAY, UCAL_MINUTE, UCAL_SECOND, UCAL_WEEK_OF_MONTH, and UCAL_ZONE_OFFSET.

Referenced by Calendar::getGreatestMinimum(), Calendar::getLeastMaximum(), Calendar::getMaximum(), and Calendar::getMinimum().

                                                                                {
    switch (field) {
    case UCAL_DAY_OF_WEEK:
    case UCAL_AM_PM:
    case UCAL_HOUR:
    case UCAL_HOUR_OF_DAY:
    case UCAL_MINUTE:
    case UCAL_SECOND:
    case UCAL_MILLISECOND:
    case UCAL_ZONE_OFFSET:
    case UCAL_DST_OFFSET:
    case UCAL_DOW_LOCAL:
    case UCAL_JULIAN_DAY:
    case UCAL_MILLISECONDS_IN_DAY:
    case UCAL_IS_LEAP_MONTH:
        return kCalendarLimits[field][limitType];

    case UCAL_WEEK_OF_MONTH:
        {
            int32_t limit;
            if (limitType == UCAL_LIMIT_MINIMUM) {
                limit = getMinimalDaysInFirstWeek() == 1 ? 1 : 0;
            } else if (limitType == UCAL_LIMIT_GREATEST_MINIMUM) {
                limit = 1;
            } else {
                int32_t minDaysInFirst = getMinimalDaysInFirstWeek();
                int32_t daysInMonth = handleGetLimit(UCAL_DAY_OF_MONTH, limitType);
                if (limitType == UCAL_LIMIT_LEAST_MAXIMUM) {
                    limit = (daysInMonth + (7 - minDaysInFirst)) / 7;
                } else { // limitType == UCAL_LIMIT_MAXIMUM
                    limit = (daysInMonth + 6 + (7 - minDaysInFirst)) / 7;
                }
            }
            return limit;
        }
    default:
        return handleGetLimit(field, limitType);
    }
}


Generated by  Doxygen 1.6.0   Back to index