ICU-23077 Correct the internalGet call inside Calendar

See #3439
This commit is contained in:
Frank Tang 2025-03-18 23:13:34 +00:00 committed by Frank Yung-Fong Tang
parent 3edd9c828a
commit b65650bc5f
2 changed files with 17 additions and 10 deletions

View file

@ -4251,17 +4251,20 @@ int32_t Calendar::internalGetMonth(UErrorCode& status) const {
if (U_FAILURE(status)) {
return 0;
}
if (resolveFields(kMonthPrecedence) == UCAL_MONTH) {
return internalGet(UCAL_MONTH, status);
if (resolveFields(kMonthPrecedence) == UCAL_ORDINAL_MONTH) {
return internalGet(UCAL_ORDINAL_MONTH);
}
return internalGet(UCAL_ORDINAL_MONTH, status);
return internalGet(UCAL_MONTH);
}
int32_t Calendar::internalGetMonth(int32_t defaultValue, UErrorCode& /* status */) const {
if (resolveFields(kMonthPrecedence) == UCAL_MONTH) {
return internalGet(UCAL_MONTH, defaultValue);
int32_t Calendar::internalGetMonth(int32_t defaultValue, UErrorCode& status) const {
if (U_FAILURE(status)) {
return 0;
}
return internalGet(UCAL_ORDINAL_MONTH);
if (resolveFields(kMonthPrecedence) == UCAL_ORDINAL_MONTH) {
return internalGet(UCAL_ORDINAL_MONTH);
}
return internalGet(UCAL_MONTH, defaultValue);
}
BasicTimeZone*

View file

@ -1177,10 +1177,14 @@ int32_t ChineseCalendar::internalGetMonth(int32_t defaultValue, UErrorCode& stat
if (U_FAILURE(status)) {
return 0;
}
if (resolveFields(kMonthPrecedence) == UCAL_MONTH) {
return internalGet(UCAL_MONTH, defaultValue);
switch (resolveFields(kMonthPrecedence)) {
case UCAL_MONTH:
return internalGet(UCAL_MONTH);
case UCAL_ORDINAL_MONTH:
return internalGetMonth(status);
default:
return defaultValue;
}
return internalGetMonth(status);
}
ChineseCalendar::Setting ChineseCalendar::getSetting(UErrorCode&) const {