// initialize systemDefaultCentury and systemDefaultCenturyYear based
// on the current time. They'll be set to 80 years before
// the current time.
- // No point in locking as it should be idempotent.
- if (fgSystemDefaultCenturyStart == fgSystemDefaultCentury)
+ UErrorCode status = U_ZERO_ERROR;
+ TaiwanCalendar calendar(Locale("@calendar=roc"),status);
+ if (U_SUCCESS(status))
{
- UErrorCode status = U_ZERO_ERROR;
- TaiwanCalendar calendar(Locale("@calendar=roc"),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)
{
- 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);
- fgSystemDefaultCenturyStart = newStart;
- fgSystemDefaultCenturyStartYear = newYear;
- umtx_unlock(NULL);
- }
+ fgSystemDefaultCenturyStartYear = newYear;
+ fgSystemDefaultCenturyStart = newStart;
}
- // We have no recourse upon failure unless we want to propagate the failure
- // out.
+ umtx_unlock(NULL);
}
+ // We have no recourse upon failure unless we want to propagate the failure
+ // out.
}