//------------------------------------------------------------------------- // Functions for converting from field values to milliseconds.... //------------------------------------------------------------------------- staticdouble IndianToJD(int32_t year, int32_t month, int32_t date) {
int32_t leapMonth, gyear, m; double start, jd;
gyear = year + INDIAN_ERA_START;
if(isGregorianLeap(gyear)) {
leapMonth = 31;
start = gregorianToJD(gyear, 2/* The third month in 0 based month */, 21);
} else {
leapMonth = 30;
start = gregorianToJD(gyear, 2/* The third month in 0 based month */, 22);
}
//month is 0 based; converting it to 1-based
int32_t imonth;
// If the month is out of range, adjust it into range, and adjust the extended year accordingly if (month < 0 || month > 11) { if (uprv_add32_overflow(eyear, ClockMath::floorDivide(month, 12, &month), &eyear)) {
status = U_ILLEGAL_ARGUMENT_ERROR; return0;
}
}
//------------------------------------------------------------------------- // Functions for converting from milliseconds to field values //-------------------------------------------------------------------------
if (newerField(UCAL_EXTENDED_YEAR, UCAL_YEAR) == UCAL_EXTENDED_YEAR) {
year = internalGet(UCAL_EXTENDED_YEAR, 1); // Default to year 1
} else {
year = internalGet(UCAL_YEAR, 1); // Default to year 1
}
IndianYear = gregorianYear - INDIAN_ERA_START; // Year in Saka era
jdAtStartOfGregYear = gregorianToJD(gregorianYear, 0, 1); // JD at start of Gregorian year
yday = static_cast<int32_t>(julianDay - jdAtStartOfGregYear); // Day number in Gregorian year (starting from 0)
if (yday < INDIAN_YEAR_START) { // Day is at the end of the preceding Saka year
IndianYear -= 1;
leapMonth = isGregorianLeap(gregorianYear - 1) ? 31 : 30; // Days in leapMonth this year, previous Gregorian year
yday += leapMonth + (31 * 5) + (30 * 3) + 10;
} else {
leapMonth = isGregorianLeap(gregorianYear) ? 31 : 30; // Days in leapMonth this year
yday -= INDIAN_YEAR_START;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.