ICU-6691 Use most recently set year field in handleGetExtendedYear

X-SVN-Rev: 27738
This commit is contained in:
Jason Spieth 2010-03-02 16:23:13 +00:00
parent e6b90eac0d
commit 828ca4ece7
2 changed files with 23 additions and 2 deletions

View File

@ -1020,6 +1020,14 @@ Calendar::setTimeInMillis( double millis, UErrorCode& status ) {
fTime = millis;
fAreFieldsSet = fAreAllFieldsSet = FALSE;
fIsTimeSet = fAreFieldsVirtuallySet = TRUE;
for (int32_t i=0; i<UCAL_FIELD_COUNT; ++i) {
fFields[i] = 0;
fStamp[i] = kUnset;
fIsSet[i] = FALSE;
}
}
// -------------------------------------

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1997-2009, International Business Machines Corporation and *
* Copyright (C) 1997-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -1174,8 +1174,21 @@ int32_t GregorianCalendar::getActualMaximum(UCalendarDateFields field, UErrorCod
int32_t GregorianCalendar::handleGetExtendedYear() {
// the year to return
int32_t year = kEpochYear;
switch(resolveFields(kYearPrecedence)) {
// 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;
// based on the "best" year field, get the year
switch(yearField) {
case UCAL_EXTENDED_YEAR:
year = internalGet(UCAL_EXTENDED_YEAR, kEpochYear);
break;