Skip to content

Commit

Permalink
ICU-22991 Remove protected direct access to fStamp
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang committed Dec 16, 2024
1 parent 4ff5d6a commit 81d0475
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 3 additions & 1 deletion icu4c/source/i18n/chnsecal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions icu4c/source/i18n/gregocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 81d0475

Please sign in to comment.