ICU-3009 calendar code bug fixes - make factory-fresh calendars have the current time, and make calendar subclasses initialize properly

X-SVN-Rev: 12407
This commit is contained in:
Steven R. Loomis 2003-06-10 03:58:41 +00:00
parent 477dbae103
commit 51ea41bfc5
3 changed files with 6 additions and 0 deletions

View file

@ -33,6 +33,7 @@ static const int32_t kGregorianEpoch = 1970;
BuddhistCalendar::BuddhistCalendar(const Locale& aLocale, UErrorCode& success)
: GregorianCalendar(aLocale, success)
{
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
}
BuddhistCalendar::~BuddhistCalendar()

View file

@ -544,7 +544,11 @@ Calendar::createInstance(TimeZone* zone, const Locale& aLocale, UErrorCode& succ
// a calendar was returned - we assume the factory did the right thing.
c = (Calendar*)u;
}
// Now, reset calendar to default state:
c->clear();
c->adoptTimeZone(zone); // Set the correct time zone
c->setTimeInMillis(getNow(), success); // let the new calendar have the current time.
return c;
}

View file

@ -281,6 +281,7 @@ const uint32_t JapaneseCalendar::kCurrentEra = (kEraCount-1);
JapaneseCalendar::JapaneseCalendar(const Locale& aLocale, UErrorCode& success)
: GregorianCalendar(aLocale, success)
{
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
}
JapaneseCalendar::~JapaneseCalendar()