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

void HebrewCalendar::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 729 of file hebrwcal.cpp.

References 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;
    HebrewCalendar calendar(Locale("@calendar=hebrew"),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);
        if (fgSystemDefaultCenturyStart == fgSystemDefaultCentury) {
            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