int32_t JapaneseCalendar::getDefaultDayInMonth(int32_t month) { UErrorCode status = U_ZERO_ERROR; int32_t era = internalGetEra(); computeFields(status); // slow int32_t year = getGregorianYear(); int32_t day = GregorianCalendar::getDefaultDayInMonth(month); if(year == kEraInfo[era].year) { if(month == (kEraInfo[era].month-1)) { return kEraInfo[era].day; } } return day; }
/** * Sets this Calendar's current time from the given long value. * @param date the new time in UTC milliseconds from the epoch. */ void Calendar::setTimeInMillis( double millis, UErrorCode& status ) { if(U_FAILURE(status)) return; fIsTimeSet = TRUE; fTime = millis; fAreFieldsSet = FALSE; computeFields(status); /* Test for buffer overflows */ if(U_FAILURE(status)) { return; } fAreFieldsSet = TRUE; fAreAllFieldsSet = TRUE; }
int32_t JapaneseCalendar::getDefaultMonthInYear() { UErrorCode status = U_ZERO_ERROR; int32_t era = internalGetEra(); computeFields(status); // slow int32_t year = getGregorianYear(); // TODO do we assume we can trust 'era'? What if it is denormalized? int32_t month = GregorianCalendar::getDefaultMonthInYear(); // Find out if we are at the edge of an era if(year == kEraInfo[era].year) { // Yes, we're in the first year of this era. return kEraInfo[era].month-1; } return month; }
void Calendar::complete(UErrorCode& status) { if (!fIsTimeSet) { updateTime(status); /* Test for buffer overflows */ if(U_FAILURE(status)) { return; } } if (!fAreFieldsSet) { computeFields(status); // fills in unset fields /* Test for buffer overflows */ if(U_FAILURE(status)) { return; } fAreFieldsSet = TRUE; fAreAllFieldsSet = TRUE; } }