Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICU-22991 Remove protected direct access to fStamp #3302

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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