- UBool needsUpdate;
- UMTX_CHECK(NULL, (fgSystemDefaultCenturyStart == fgSystemDefaultCentury), needsUpdate);
-
- if (!needsUpdate) {
- return;
- }
-
- UErrorCode status = U_ZERO_ERROR;
-
- CopticCalendar calendar(Locale("@calendar=coptic"), 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);
- fgSystemDefaultCenturyStartYear = newYear;
- fgSystemDefaultCenturyStart = newStart;
- umtx_unlock(NULL);
- }
- }
- // We have no recourse upon failure unless we want to propagate the failure
- // out.
+ umtx_initOnce(gSystemDefaultCenturyInit, &initializeSystemDefaultCentury);
+ return gSystemDefaultCenturyStartYear;