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

Initializes the 100-year window that dates with 2-digit years are considered to fall within so that its start date is 80 years before the current time.

Reimplemented from GregorianCalendar.

Definition at line 185 of file buddhcal.cpp.

References Calendar::add(), fgSystemDefaultCentury, fgSystemDefaultCenturyStart, fgSystemDefaultCenturyStartYear, Calendar::get(), Calendar::getNow(), Calendar::getTime(), Calendar::setTime(), U_SUCCESS, U_ZERO_ERROR, and UCAL_YEAR.

Referenced by internalGetDefaultCenturyStart(), and internalGetDefaultCenturyStartYear().

{
    // initialize systemDefaultCentury and systemDefaultCenturyYear based
    // on the current time.  They'll be set to 80 years before
    // the current time.
    UErrorCode status = U_ZERO_ERROR;
    BuddhistCalendar calendar(Locale("@calendar=buddhist"),status);
    if (U_SUCCESS(status))
    {
        calendar.setTime(Calendar::getNow(), status);
        calendar.add(UCAL_YEAR, -80, status);
        UDate    newStart =  calendar.getTime(status);
        int32_t  newYear  =  calendar.get(UCAL_YEAR, status);
        umtx_lock(NULL);
        if (fgSystemDefaultCenturyStart == fgSystemDefaultCentury) {
            fgSystemDefaultCenturyStartYear = newYear;
            fgSystemDefaultCenturyStart = newStart;
        }
        umtx_unlock(NULL);
    }
    // We have no recourse upon failure unless we want to propagate the failure
    // out.
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index