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

int32_t Calendar::getActualMinimum ( UCalendarDateFields  field,
UErrorCode status 
) const [virtual, inherited]

Return the minimum value that this field could have, given the current date. For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().

The version of this function on Calendar uses an iterative algorithm to determine the actual minimum value for the field. There is almost always a more efficient way to accomplish this (in most cases, you can simply return getMinimum()). GregorianCalendar overrides this function with a more efficient implementation.

field the field to determine the minimum of
status Fill-in parameter which receives the status of this operation.
the minimum of the given field for the current date of this Calendar ICU 2.6.

Reimplemented in GregorianCalendar.

Definition at line 2313 of file calendar.cpp.

References Calendar::clone(), Calendar::get(), Calendar::getGreatestMinimum(), Calendar::getMinimum(), NULL, Calendar::set(), Calendar::setLenient(), TRUE, U_FAILURE, and U_MEMORY_ALLOCATION_ERROR.

    int32_t fieldValue = getGreatestMinimum(field);
    int32_t endValue = getMinimum(field);

    // if we know that the minimum value is always the same, just return it
    if (fieldValue == endValue) {
        return fieldValue;

    // clone the calendar so we don't mess with the real one, and set it to
    // accept anything for the field values
    Calendar *work = (Calendar*)this->clone();
    if (work == NULL) {
        return 0;

    // now try each value from getLeastMaximum() to getMaximum() one by one until
    // we get a value that normalizes to another value.  The last value that
    // normalizes to itself is the actual minimum for the current date
    int32_t result = fieldValue;

    do {
        work->set(field, fieldValue);
        if (work->get(field, status) != fieldValue) {
        else {
            result = fieldValue;
    } while (fieldValue >= endValue);

    delete work;

    /* Test for buffer overflows */
    if(U_FAILURE(status)) {
        return 0;
    return result;

Generated by  Doxygen 1.6.0   Back to index