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

void EthiopicCalendar::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 161 of file ethpccal.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 defaultCenturyStart(), and defaultCenturyStartYear().

    // lazy-evaluate systemDefaultCenturyStart
    UBool needsUpdate;
    UMTX_CHECK(NULL, (fgSystemDefaultCenturyStart == fgSystemDefaultCentury), needsUpdate);

    if (!needsUpdate) {

    UErrorCode status = U_ZERO_ERROR;

    EthiopicCalendar calendar(Locale("@calendar=ethiopic"), 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);
            fgSystemDefaultCenturyStartYear = newYear;
            fgSystemDefaultCenturyStart = newStart;
    // We have no recourse upon failure unless we want to propagate the failure
    // out.

Generated by  Doxygen 1.6.0   Back to index