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

void PersianCalendar::initializeSystemDefaultCentury ( void   )  [static, private]

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.

Definition at line 435 of file persncal.cpp.

References Calendar::add(), fgSystemDefaultCentury, fgSystemDefaultCenturyStart, fgSystemDefaultCenturyStartYear, Calendar::get(), Calendar::getNow(), Calendar::getTime(), NULL, 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;
    PersianCalendar calendar(Locale("@calendar=persian"),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.
}


Generated by  Doxygen 1.6.0   Back to index