Logo Search packages:      
Sourcecode: icu version File versions

void Calendar::pinField ( UCalendarDateFields  field,
UErrorCode status 
) [protected, virtual, inherited]

Adjust the specified field so that it is within the allowable range for the date to which this calendar is set. For example, in a Gregorian calendar pinning the DAY_OF_MONTH field for a calendar set to April 31 would cause it to be set to April 30.

Subclassing:
This utility method is intended for use by subclasses that need to implement their own overrides of roll and add.

Note: pinField is implemented in terms of getActualMinimum and getActualMaximum. If either of those methods uses a slow, iterative algorithm for a particular field, it would be unwise to attempt to call pinField for that field. If you really do need to do so, you should override this method to do something more efficient for that field.

Parameters:
field The calendar field whose value should be pinned.
status Output param set to failure code on function return when this function fails.
See also:
getActualMinimum

getActualMaximum ICU 2.0

Adjust the specified field so that it is within the allowable range for the date to which this calendar is set. For example, in a Gregorian calendar pinning the DAY_OF_MONTH field for a calendar set to April 31 would cause it to be set to April 30.

Subclassing:
This utility method is intended for use by subclasses that need to implement their own overrides of roll and add.

Note: pinField is implemented in terms of getActualMinimum and getActualMaximum. If either of those methods uses a slow, iterative algorithm for a particular field, it would be unwise to attempt to call pinField for that field. If you really do need to do so, you should override this method to do something more efficient for that field.

Parameters:
field The calendar field whose value should be pinned.
See also:
getActualMinimum

getActualMaximum ICU 2.0

Definition at line 1182 of file calendar.cpp.

References Calendar::fFields, Calendar::getActualMaximum(), and Calendar::getActualMinimum().

Referenced by HebrewCalendar::add(), Calendar::add(), HebrewCalendar::roll(), and Calendar::roll().

                                                                     {
    int32_t max = getActualMaximum(field, status);
    int32_t min = getActualMinimum(field, status);

    if (fFields[field] > max) {
        set(field, max);
    } else if (fFields[field] < min) {
        set(field, min);
    }
}


Generated by  Doxygen 1.6.0   Back to index