// --- The cache --
-static icu::UMutex *astroLock() { // Protects access to gChineseCalendarAstro.
- static icu::UMutex *m = STATIC_NEW(icu::UMutex);
- return m;
-}
+static icu::UMutex astroLock;
static icu::CalendarAstronomer *gChineseCalendarAstro = NULL;
// Lazy Creation & Access synchronized by class CalendarCache with a mutex.
//-------------------------------------------------------------------------
-Calendar* ChineseCalendar::clone() const {
+ChineseCalendar* ChineseCalendar::clone() const {
return new ChineseCalendar(*this);
}
UErrorCode status = U_ZERO_ERROR;
fZoneAstroCalc->getOffset(millis, FALSE, rawOffset, dstOffset, status);
if (U_SUCCESS(status)) {
- return millis - (double)(rawOffset + dstOffset);
+ return millis - (double)(rawOffset + dstOffset);
}
}
return millis - (double)CHINA_OFFSET;
UErrorCode status = U_ZERO_ERROR;
fZoneAstroCalc->getOffset(millis, FALSE, rawOffset, dstOffset, status);
if (U_SUCCESS(status)) {
- return ClockMath::floorDivide(millis + (double)(rawOffset + dstOffset), kOneDay);
+ return ClockMath::floorDivide(millis + (double)(rawOffset + dstOffset), kOneDay);
}
}
return ClockMath::floorDivide(millis + (double)CHINA_OFFSET, kOneDay);
// PST 1298 with a final result of Dec 14 10:31:59 PST 1299.
double ms = daysToMillis(Grego::fieldsToDay(gyear, UCAL_DECEMBER, 1));
- umtx_lock(astroLock());
+ umtx_lock(&astroLock);
if(gChineseCalendarAstro == NULL) {
gChineseCalendarAstro = new CalendarAstronomer();
ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup);
}
gChineseCalendarAstro->setTime(ms);
UDate solarLong = gChineseCalendarAstro->getSunTime(CalendarAstronomer::WINTER_SOLSTICE(), TRUE);
- umtx_unlock(astroLock());
+ umtx_unlock(&astroLock);
// Winter solstice is 270 degrees solar longitude aka Dongzhi
cacheValue = (int32_t)millisToDays(solarLong);
// we are out of its range and need to use the full machinery.
UDate newMoon = CalendarAstronomer::getNewMoonTimeInRange(ms, after);
if (newMoon == 0.0) {
- umtx_lock(astroLock());
+ umtx_lock(&astroLock);
if(gChineseCalendarAstro == NULL) {
gChineseCalendarAstro = new CalendarAstronomer();
ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup);
}
gChineseCalendarAstro->setTime(ms);
newMoon = gChineseCalendarAstro->getMoonTime(CalendarAstronomer::NEW_MOON(), after);
- umtx_unlock(astroLock());
+ umtx_unlock(&astroLock);
}
return (int32_t) millisToDays(newMoon);