// --- The cache --
// cache of months
-static UMutex astroLock = U_MUTEX_INITIALIZER; // pod bay door lock
static icu::CalendarCache *gMonthCache = NULL;
static icu::CalendarAstronomer *gIslamicCalendarAstro = NULL;
sType = "islamic-umalqura";
break;
default:
- U_ASSERT(false); // out of range
- sType = "islamic"; // "islamic" is used as the generic type
- break;
+ UPRV_UNREACHABLE; // out of range
}
return sType;
}
{
double age = 0;
- umtx_lock(&astroLock);
+ static UMutex *astroLock = STATIC_NEW(UMutex); // pod bay door lock
+ umtx_lock(astroLock);
if(gIslamicCalendarAstro == NULL) {
gIslamicCalendarAstro = new CalendarAstronomer();
if (gIslamicCalendarAstro == NULL) {
}
gIslamicCalendarAstro->setTime(time);
age = gIslamicCalendarAstro->getMoonAge();
- umtx_unlock(&astroLock);
+ umtx_unlock(astroLock);
// Convert to degrees and normalize...
age = age * 180 / CalendarAstronomer::PI;
days = julianDay - ASTRONOMICAL_EPOC;
}
// Use the civil calendar approximation, which is just arithmetic
- year = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631.0 );
+ year = (int32_t)ClockMath::floorDivide(30 * (int64_t)days + 10646, (int64_t)10631);
month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 );
month = month<11?month:11;
startDate = monthStart(year, month);
month = m;
}
} else { // invalid 'civil'
- U_ASSERT(false); // should not get here, out of range
- year=month=0;
+ UPRV_UNREACHABLE; // should not get here, out of range
}
dayOfMonth = (days - monthStart(year, month)) + 1;