ICU-22991 Remove protected direct access to fStamp

This commit is contained in:
Frank Tang 2024-12-13 10:22:53 -08:00 committed by Frank Yung-Fong Tang
parent 4ff5d6a070
commit 81d047524c
2 changed files with 5 additions and 7 deletions

View file

@ -219,7 +219,9 @@ int32_t ChineseCalendar::handleGetExtendedYear(UErrorCode& status) {
}
int32_t year;
if (newestStamp(UCAL_ERA, UCAL_YEAR, kUnset) <= fStamp[UCAL_EXTENDED_YEAR]) {
// if UCAL_EXTENDED_YEAR is not older than UCAL_ERA nor UCAL_YEAR
if (newerField(UCAL_EXTENDED_YEAR, newerField(UCAL_ERA, UCAL_YEAR)) ==
UCAL_EXTENDED_YEAR) {
year = internalGet(UCAL_EXTENDED_YEAR, 1); // Default to year 1
} else {
// adjust to the instance specific epoch

View file

@ -1186,14 +1186,10 @@ int32_t GregorianCalendar::handleGetExtendedYear(UErrorCode& status) {
int32_t year = kEpochYear;
// year field to use
int32_t yearField = UCAL_EXTENDED_YEAR;
// There are three separate fields which could be used to
// derive the proper year. Use the one most recently set.
if (fStamp[yearField] < fStamp[UCAL_YEAR])
yearField = UCAL_YEAR;
if (fStamp[yearField] < fStamp[UCAL_YEAR_WOY])
yearField = UCAL_YEAR_WOY;
UCalendarDateFields yearField = newerField(
newerField(UCAL_EXTENDED_YEAR, UCAL_YEAR), UCAL_YEAR_WOY);
// based on the "best" year field, get the year
switch(yearField) {