ICU-2222 Deprecate C++ enums that duplicate C enums

X-SVN-Rev: 11137
This commit is contained in:
GCL Shanghai 2003-02-21 08:32:22 +00:00
parent 919141a5d6
commit 513a23fdae
56 changed files with 1360 additions and 1358 deletions

View file

@ -168,9 +168,9 @@ Calendar::operator=(const Calendar &right)
{
if (this != &right)
{
uprv_arrayCopy(right.fFields, fFields, FIELD_COUNT);
uprv_arrayCopy(right.fIsSet, fIsSet, FIELD_COUNT);
uprv_arrayCopy(right.fStamp, fStamp, FIELD_COUNT);
uprv_arrayCopy(right.fFields, fFields, UCAL_FIELD_COUNT);
uprv_arrayCopy(right.fIsSet, fIsSet, UCAL_FIELD_COUNT);
uprv_arrayCopy(right.fStamp, fStamp, UCAL_FIELD_COUNT);
fTime = right.fTime;
fIsTimeSet = right.fIsTimeSet;
fAreAllFieldsSet = right.fAreAllFieldsSet;
@ -389,7 +389,7 @@ Calendar::setTimeInMillis( double millis, UErrorCode& status ) {
// -------------------------------------
int32_t
Calendar::get(EDateFields field, UErrorCode& status) const
Calendar::get(UCalendarDateFields field, UErrorCode& status) const
{
// field values are only computed when actually requested; for more on when computation
// of various things happens, see the "data flow in Calendar" description at the top
@ -401,7 +401,7 @@ Calendar::get(EDateFields field, UErrorCode& status) const
// -------------------------------------
void
Calendar::set(EDateFields field, int32_t value)
Calendar::set(UCalendarDateFields field, int32_t value)
{
fIsTimeSet = FALSE;
fFields[field] = value;
@ -415,9 +415,9 @@ Calendar::set(EDateFields field, int32_t value)
void
Calendar::set(int32_t year, int32_t month, int32_t date)
{
set(YEAR, year);
set(MONTH, month);
set(DATE, date);
set(UCAL_YEAR, year);
set(UCAL_MONTH, month);
set(UCAL_DATE, date);
}
// -------------------------------------
@ -425,11 +425,11 @@ Calendar::set(int32_t year, int32_t month, int32_t date)
void
Calendar::set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute)
{
set(YEAR, year);
set(MONTH, month);
set(DATE, date);
set(HOUR_OF_DAY, hour);
set(MINUTE, minute);
set(UCAL_YEAR, year);
set(UCAL_MONTH, month);
set(UCAL_DATE, date);
set(UCAL_HOUR_OF_DAY, hour);
set(UCAL_MINUTE, minute);
}
// -------------------------------------
@ -437,12 +437,12 @@ Calendar::set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t m
void
Calendar::set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second)
{
set(YEAR, year);
set(MONTH, month);
set(DATE, date);
set(HOUR_OF_DAY, hour);
set(MINUTE, minute);
set(SECOND, second);
set(UCAL_YEAR, year);
set(UCAL_MONTH, month);
set(UCAL_DATE, date);
set(UCAL_HOUR_OF_DAY, hour);
set(UCAL_MINUTE, minute);
set(UCAL_SECOND, second);
}
// -------------------------------------
@ -450,7 +450,7 @@ Calendar::set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t m
void
Calendar::clear()
{
for (int32_t i=0; i<FIELD_COUNT; ++i) {
for (int32_t i=0; i<UCAL_FIELD_COUNT; ++i) {
fFields[i] = 0; // Must do this; other code depends on it
fIsSet[i] = FALSE;
fStamp[i] = kUnset;
@ -464,7 +464,7 @@ Calendar::clear()
// -------------------------------------
void
Calendar::clear(EDateFields field)
Calendar::clear(UCalendarDateFields field)
{
fFields[field] = 0;
fStamp[field] = kUnset;
@ -477,7 +477,7 @@ Calendar::clear(EDateFields field)
// -------------------------------------
UBool
Calendar::isSet(EDateFields field) const
Calendar::isSet(UCalendarDateFields field) const
{
return fStamp[field] != kUnset;
}
@ -507,7 +507,7 @@ Calendar::complete(UErrorCode& status)
// -------------------------------------
int32_t Calendar::fieldDifference(UDate targetMs, EDateFields field, UErrorCode& ec) {
int32_t Calendar::fieldDifference(UDate targetMs, UCalendarDateFields field, UErrorCode& ec) {
if (U_FAILURE(ec)) return 0;
int32_t min = 0;
double startMs = getTimeInMillis(ec);
@ -656,14 +656,14 @@ Calendar::isLenient() const
// -------------------------------------
void
Calendar::setFirstDayOfWeek(EDaysOfWeek value)
Calendar::setFirstDayOfWeek(UCalendarDaysOfWeek value)
{
fFirstDayOfWeek = value;
}
// -------------------------------------
Calendar::EDaysOfWeek
UCalendarDaysOfWeek
Calendar::getFirstDayOfWeek() const
{
return fFirstDayOfWeek;
@ -688,7 +688,7 @@ Calendar::getMinimalDaysInFirstWeek() const
// -------------------------------------
int32_t
Calendar::getActualMinimum(EDateFields field, UErrorCode& status) const
Calendar::getActualMinimum(UCalendarDateFields field, UErrorCode& status) const
{
int32_t fieldValue = getGreatestMinimum(field);
int32_t endValue = getMinimum(field);
@ -731,7 +731,7 @@ Calendar::getActualMinimum(EDateFields field, UErrorCode& status) const
// -------------------------------------
int32_t
Calendar::getActualMaximum(EDateFields field, UErrorCode& status) const
Calendar::getActualMaximum(UCalendarDateFields field, UErrorCode& status) const
{
int32_t fieldValue = getLeastMaximum(field);
int32_t endValue = getMaximum(field);
@ -748,8 +748,8 @@ Calendar::getActualMaximum(EDateFields field, UErrorCode& status) const
// if we're counting weeks, set the day of the week to Sunday. We know the
// last week of a month or year will contain the first day of the week.
if (field == WEEK_OF_YEAR || field == WEEK_OF_MONTH)
work->set(DAY_OF_WEEK, fFirstDayOfWeek);
if (field == UCAL_WEEK_OF_YEAR || field == UCAL_WEEK_OF_MONTH)
work->set(UCAL_DAY_OF_WEEK, fFirstDayOfWeek);
// now try each value from getLeastMaximum() to getMaximum() one by one until
// we get a value that normalizes to another value. The last value that
@ -794,7 +794,7 @@ Calendar::setWeekCountData(const Locale& desiredLocale, UErrorCode& status)
if (U_FAILURE(status)) return;
fFirstDayOfWeek = Calendar::SUNDAY;
fFirstDayOfWeek = UCAL_SUNDAY;
fMinimalDaysInFirstWeek = 1;
UResourceBundle *resource = ures_open(NULL, desiredLocale.getName(), &status);
@ -818,7 +818,7 @@ Calendar::setWeekCountData(const Locale& desiredLocale, UErrorCode& status)
&& 1 <= dateTimeElementsArr[0] && dateTimeElementsArr[0] <= 7
&& 1 <= dateTimeElementsArr[1] && dateTimeElementsArr[1] <= 7)
{
fFirstDayOfWeek = (Calendar::EDaysOfWeek)dateTimeElementsArr[0];
fFirstDayOfWeek = (UCalendarDaysOfWeek)dateTimeElementsArr[0];
fMinimalDaysInFirstWeek = (uint8_t)dateTimeElementsArr[1];
}
else {

View file

@ -126,19 +126,19 @@ Collator::createInstance(const Locale &loc,
UBool Collator::equals(const UnicodeString& source,
const UnicodeString& target) const
{
return (compare(source, target) == EQUAL);
return (compare(source, target) == UCOL_EQUAL);
}
UBool Collator::greaterOrEqual(const UnicodeString& source,
const UnicodeString& target) const
{
return (compare(source, target) != LESS);
return (compare(source, target) != UCOL_LESS);
}
UBool Collator::greater(const UnicodeString& source,
const UnicodeString& target) const
{
return (compare(source, target) == GREATER);
return (compare(source, target) == UCOL_GREATER);
}
const Locale* Collator::getAvailableLocales(int32_t& count)

View file

@ -208,10 +208,10 @@ GregorianCalendar::GregorianCalendar(int32_t year, int32_t month, int32_t date,
fNormalizedGregorianCutover(fGregorianCutover),
fGregorianCutoverYear(1582)
{
set(Calendar::ERA, AD);
set(Calendar::YEAR, year);
set(Calendar::MONTH, month);
set(Calendar::DATE, date);
set(UCAL_ERA, AD);
set(UCAL_YEAR, year);
set(UCAL_MONTH, month);
set(UCAL_DATE, date);
}
// -------------------------------------
@ -223,12 +223,12 @@ GregorianCalendar::GregorianCalendar(int32_t year, int32_t month, int32_t date,
fNormalizedGregorianCutover(fGregorianCutover),
fGregorianCutoverYear(1582)
{
set(Calendar::ERA, AD);
set(Calendar::YEAR, year);
set(Calendar::MONTH, month);
set(Calendar::DATE, date);
set(Calendar::HOUR_OF_DAY, hour);
set(Calendar::MINUTE, minute);
set(UCAL_ERA, AD);
set(UCAL_YEAR, year);
set(UCAL_MONTH, month);
set(UCAL_DATE, date);
set(UCAL_HOUR_OF_DAY, hour);
set(UCAL_MINUTE, minute);
}
// -------------------------------------
@ -241,13 +241,13 @@ GregorianCalendar::GregorianCalendar(int32_t year, int32_t month, int32_t date,
fNormalizedGregorianCutover(fGregorianCutover),
fGregorianCutoverYear(1582)
{
set(Calendar::ERA, AD);
set(Calendar::YEAR, year);
set(Calendar::MONTH, month);
set(Calendar::DATE, date);
set(Calendar::HOUR_OF_DAY, hour);
set(Calendar::MINUTE, minute);
set(Calendar::SECOND, second);
set(UCAL_ERA, AD);
set(UCAL_YEAR, year);
set(UCAL_MONTH, month);
set(UCAL_DATE, date);
set(UCAL_HOUR_OF_DAY, hour);
set(UCAL_MINUTE, minute);
set(UCAL_SECOND, second);
}
// -------------------------------------
@ -338,8 +338,8 @@ GregorianCalendar::setGregorianChange(UDate date, UErrorCode& status)
if(U_FAILURE(status))
return;
cal->setTime(date, status);
fGregorianCutoverYear = cal->get(YEAR, status);
if (cal->get(ERA, status) == BC)
fGregorianCutoverYear = cal->get(UCAL_YEAR, status);
if (cal->get(UCAL_ERA, status) == BC)
fGregorianCutoverYear = 1 - fGregorianCutoverYear;
delete cal;
@ -440,7 +440,7 @@ GregorianCalendar::timeToFields(UDate theTime, UBool quick, UErrorCode& status)
(isLeap ? kLeapNumDays[month] : kNumDays[month]) + 1; // one-based DOM
// Normalize day of week
dayOfWeek += (dayOfWeek < 0) ? (SUNDAY+7) : SUNDAY;
dayOfWeek += (dayOfWeek < 0) ? (UCAL_SUNDAY+7) : UCAL_SUNDAY;
era = AD;
@ -460,12 +460,12 @@ GregorianCalendar::timeToFields(UDate theTime, UBool quick, UErrorCode& status)
// Calculate year of week of year
internalSet(ERA, era);
internalSet(YEAR, year);
internalSet(MONTH, month + JANUARY); // 0-based
internalSet(DATE, date);
internalSet(DAY_OF_WEEK, dayOfWeek);
internalSet(DAY_OF_YEAR, ++dayOfYear); // Convert from 0-based to 1-based
internalSet(UCAL_ERA, era);
internalSet(UCAL_YEAR, year);
internalSet(UCAL_MONTH, month + UCAL_JANUARY); // 0-based
internalSet(UCAL_DATE, date);
internalSet(UCAL_DAY_OF_WEEK, dayOfWeek);
internalSet(UCAL_DAY_OF_YEAR, ++dayOfYear); // Convert from 0-based to 1-based
if (quick)
return;
@ -502,16 +502,16 @@ GregorianCalendar::timeToFields(UDate theTime, UBool quick, UErrorCode& status)
}
internalSet(WEEK_OF_YEAR, woy);
internalSet(YEAR_WOY, yearOfWeekOfYear);
internalSet(UCAL_WEEK_OF_YEAR, woy);
internalSet(UCAL_YEAR_WOY, yearOfWeekOfYear);
internalSet(WEEK_OF_MONTH, weekNumber(date, dayOfWeek));
internalSet(DAY_OF_WEEK_IN_MONTH, (date-1) / 7 + 1);
internalSet(UCAL_WEEK_OF_MONTH, weekNumber(date, dayOfWeek));
internalSet(UCAL_DAY_OF_WEEK_IN_MONTH, (date-1) / 7 + 1);
// Calculate localized day of week
locDayOfWeek = dayOfWeek-getFirstDayOfWeek()+1;
locDayOfWeek += (locDayOfWeek<1?7:0);
internalSet(DOW_LOCAL, locDayOfWeek);
internalSet(UCAL_DOW_LOCAL, locDayOfWeek);
}
// -------------------------------------
@ -559,7 +559,7 @@ GregorianCalendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek)
int32_t
GregorianCalendar::monthLength(int32_t month) const
{
int32_t year = internalGet(YEAR);
int32_t year = internalGet(UCAL_YEAR);
if(internalGetEra() == BC) {
year = 1 - year;
}
@ -588,7 +588,7 @@ GregorianCalendar::yearLength(int32_t year) const
int32_t
GregorianCalendar::yearLength() const
{
return isLeapYear(internalGet(YEAR)) ? 366 : 365;
return isLeapYear(internalGet(UCAL_YEAR)) ? 366 : 365;
}
// -------------------------------------
@ -635,10 +635,10 @@ GregorianCalendar::computeFields(UErrorCode& status)
timeToFields(localMillis, FALSE, status);
uint8_t era = (uint8_t) internalGetEra();
int32_t year = internalGet(YEAR);
int32_t month = internalGet(MONTH);
int32_t date = internalGet(DATE);
uint8_t dayOfWeek = (uint8_t) internalGet(DAY_OF_WEEK);
int32_t year = internalGet(UCAL_YEAR);
int32_t month = internalGet(UCAL_MONTH);
int32_t date = internalGet(UCAL_DATE);
uint8_t dayOfWeek = (uint8_t) internalGet(UCAL_DAY_OF_WEEK);
double days = uprv_floor(localMillis / kOneDay);
int32_t millisInDay = (int32_t) (localMillis - (days * kOneDay));
@ -674,23 +674,23 @@ GregorianCalendar::computeFields(UErrorCode& status)
// Fill in all time-related fields based on millisInDay. Call internalSet()
// so as not to perturb flags.
internalSet(MILLISECOND, millisInDay % 1000);
internalSet(UCAL_MILLISECOND, millisInDay % 1000);
millisInDay /= 1000;
internalSet(SECOND, millisInDay % 60);
internalSet(UCAL_SECOND, millisInDay % 60);
millisInDay /= 60;
internalSet(MINUTE, millisInDay % 60);
internalSet(UCAL_MINUTE, millisInDay % 60);
millisInDay /= 60;
internalSet(HOUR_OF_DAY, millisInDay);
internalSet(AM_PM, millisInDay / 12); // Assume AM == 0
internalSet(HOUR, millisInDay % 12);
internalSet(UCAL_HOUR_OF_DAY, millisInDay);
internalSet(UCAL_AM_PM, millisInDay / 12); // Assume AM == 0
internalSet(UCAL_HOUR, millisInDay % 12);
internalSet(ZONE_OFFSET, rawOffset);
internalSet(DST_OFFSET, dstOffset);
internalSet(UCAL_ZONE_OFFSET, rawOffset);
internalSet(UCAL_DST_OFFSET, dstOffset);
// Careful here: We are manually setting the time stamps[] flags to
// INTERNALLY_SET, so we must be sure that the above code actually does
// set all these fields.
for (int i=0; i<FIELD_COUNT; ++i) {
for (int i=0; i<UCAL_FIELD_COUNT; ++i) {
fStamp[i] = kInternallySet;
fIsSet[i] = TRUE; // Remove later
}
@ -707,10 +707,10 @@ GregorianCalendar::computeFields(UErrorCode& status)
void
GregorianCalendar::pinDayOfMonth()
{
int32_t monthLen = monthLength(internalGet(MONTH));
int32_t dom = internalGet(DAY_OF_MONTH);
int32_t monthLen = monthLength(internalGet(UCAL_MONTH));
int32_t dom = internalGet(UCAL_DATE);
if(dom > monthLen)
set(DAY_OF_MONTH, monthLen);
set(UCAL_DATE, monthLen);
}
// -------------------------------------
@ -718,36 +718,36 @@ GregorianCalendar::pinDayOfMonth()
UBool
GregorianCalendar::validateFields() const
{
for (int32_t field = 0; field < FIELD_COUNT; field++) {
for (int32_t field = 0; field < UCAL_FIELD_COUNT; field++) {
// Ignore DATE and DAY_OF_YEAR which are handled below
if (field != DATE &&
field != DAY_OF_YEAR &&
isSet((EDateFields)field) &&
! boundsCheck(internalGet((EDateFields)field), (EDateFields)field))
if (field != UCAL_DATE &&
field != UCAL_DAY_OF_YEAR &&
isSet((UCalendarDateFields)field) &&
! boundsCheck(internalGet((UCalendarDateFields)field), (UCalendarDateFields)field))
return FALSE;
}
// Values differ in Least-Maximum and Maximum should be handled
// specially.
if (isSet(DATE)) {
int32_t date = internalGet(DATE);
if (date < getMinimum(DATE) ||
date > monthLength(internalGet(MONTH))) {
if (isSet(UCAL_DATE)) {
int32_t date = internalGet(UCAL_DATE);
if (date < getMinimum(UCAL_DATE) ||
date > monthLength(internalGet(UCAL_MONTH))) {
return FALSE;
}
}
if (isSet(DAY_OF_YEAR)) {
int32_t days = internalGet(DAY_OF_YEAR);
if (isSet(UCAL_DAY_OF_YEAR)) {
int32_t days = internalGet(UCAL_DAY_OF_YEAR);
if (days < 1 || days > yearLength())
return FALSE;
}
// Handle DAY_OF_WEEK_IN_MONTH, which must not have the value zero.
// We've checked against minimum and maximum above already.
if (isSet(DAY_OF_WEEK_IN_MONTH) &&
0 == internalGet(DAY_OF_WEEK_IN_MONTH))
if (isSet(UCAL_DAY_OF_WEEK_IN_MONTH) &&
0 == internalGet(UCAL_DAY_OF_WEEK_IN_MONTH))
return FALSE;
return TRUE;
@ -756,7 +756,7 @@ GregorianCalendar::validateFields() const
// -------------------------------------
UBool
GregorianCalendar::boundsCheck(int32_t value, EDateFields field) const
GregorianCalendar::boundsCheck(int32_t value, UCalendarDateFields field) const
{
return value >= getMinimum(field) && value <= getMaximum(field);
}
@ -769,7 +769,7 @@ GregorianCalendar::getEpochDay(UErrorCode& status)
complete(status);
// Divide by 1000 (convert to seconds) in order to prevent overflow when
// dealing with UDate(Long.MIN_VALUE) and UDate(Long.MAX_VALUE).
double wallSec = internalGetTime()/1000 + (internalGet(ZONE_OFFSET) + internalGet(DST_OFFSET))/1000;
double wallSec = internalGetTime()/1000 + (internalGet(UCAL_ZONE_OFFSET) + internalGet(UCAL_DST_OFFSET))/1000;
// {sfb} force conversion to double
return uprv_trunc(wallSec / (kOneDay/1000.0));
@ -794,10 +794,10 @@ GregorianCalendar::computeTime(UErrorCode& status)
// The year is either the YEAR or the epoch year. YEAR_WOY is
// used only if WOY is the predominant field; see computeJulianDay.
int32_t year = (fStamp[YEAR] != kUnset) ? internalGet(YEAR) : kEpochYear;
int32_t year = (fStamp[UCAL_YEAR] != kUnset) ? internalGet(UCAL_YEAR) : kEpochYear;
int32_t era = AD;
if (fStamp[ERA] != kUnset) {
era = internalGet(ERA);
if (fStamp[UCAL_ERA] != kUnset) {
era = internalGet(UCAL_ERA);
if (era == BC)
year = 1 - year;
// Even in lenient mode we disallow ERA values other than AD & BC
@ -845,8 +845,8 @@ GregorianCalendar::computeTime(UErrorCode& status)
// Find the best set of fields specifying the time of day. There
// are only two possibilities here; the HOUR_OF_DAY or the
// AM_PM and the HOUR.
int32_t hourOfDayStamp = fStamp[HOUR_OF_DAY];
int32_t hourStamp = fStamp[HOUR];
int32_t hourOfDayStamp = fStamp[UCAL_HOUR_OF_DAY];
int32_t hourStamp = fStamp[UCAL_HOUR];
int32_t bestStamp = (hourStamp > hourOfDayStamp) ? hourStamp : hourOfDayStamp;
// Hours
@ -854,25 +854,25 @@ GregorianCalendar::computeTime(UErrorCode& status)
if (bestStamp == hourOfDayStamp)
// Don't normalize here; let overflow bump into the next period.
// This is consistent with how we handle other fields.
millisInDay += internalGet(HOUR_OF_DAY);
millisInDay += internalGet(UCAL_HOUR_OF_DAY);
else {
// Don't normalize here; let overflow bump into the next period.
// This is consistent with how we handle other fields.
millisInDay += internalGet(HOUR);
millisInDay += internalGet(UCAL_HOUR);
millisInDay += 12 * internalGet(AM_PM); // Default works for unset AM_PM
millisInDay += 12 * internalGet(UCAL_AM_PM); // Default works for unset AM_PM
}
}
// We use the fact that unset == 0; we start with millisInDay
// == HOUR_OF_DAY.
millisInDay *= 60;
millisInDay += internalGet(MINUTE); // now have minutes
millisInDay += internalGet(UCAL_MINUTE); // now have minutes
millisInDay *= 60;
millisInDay += internalGet(SECOND); // now have seconds
millisInDay += internalGet(UCAL_SECOND); // now have seconds
millisInDay *= 1000;
millisInDay += internalGet(MILLISECOND); // now have millis
millisInDay += internalGet(UCAL_MILLISECOND); // now have millis
// Compute the time zone offset and DST offset. There are two potential
// ambiguities here. We'll assume a 2:00 am (wall time) switchover time
@ -888,18 +888,18 @@ GregorianCalendar::computeTime(UErrorCode& status)
// We use the TimeZone object, unless the user has explicitly set the ZONE_OFFSET
// or DST_OFFSET fields; then we use those fields.
const TimeZone& zone = getTimeZone();
int32_t zoneOffset = (fStamp[ZONE_OFFSET] >= kMinimumUserStamp)
int32_t zoneOffset = (fStamp[UCAL_ZONE_OFFSET] >= kMinimumUserStamp)
/*isSet(ZONE_OFFSET) && userSetZoneOffset*/ ?
internalGet(ZONE_OFFSET) : zone.getRawOffset();
internalGet(UCAL_ZONE_OFFSET) : zone.getRawOffset();
// Now add date and millisInDay together, to make millis contain local wall
// millis, with no zone or DST adjustments
millis += millisInDay;
int32_t dstOffset = 0;
if (fStamp[ZONE_OFFSET] >= kMinimumUserStamp
if (fStamp[UCAL_ZONE_OFFSET] >= kMinimumUserStamp
/*isSet(DST_OFFSET) && userSetDSTOffset*/)
dstOffset = internalGet(DST_OFFSET);
dstOffset = internalGet(UCAL_DST_OFFSET);
else {
/* Normalize the millisInDay to 0..ONE_DAY-1. If the millis is out
* of range, then we must call timeToFields() to recompute our
@ -912,10 +912,10 @@ GregorianCalendar::computeTime(UErrorCode& status)
// If we're lenient then we need to call timeToFields() to
// normalize the year, month, and date numbers.
uint8_t dow;
if (isLenient() || fStamp[MONTH] == kUnset || fStamp[DATE] == kUnset
if (isLenient() || fStamp[UCAL_MONTH] == kUnset || fStamp[UCAL_DATE] == kUnset
|| millisInDay != normalizedMillisInDay[0]) {
timeToFields(millis, TRUE, status); // Use wall time; true == do quick computation
dow = (uint8_t) internalGet(DAY_OF_WEEK); // DOW is computed by timeToFields
dow = (uint8_t) internalGet(UCAL_DAY_OF_WEEK); // DOW is computed by timeToFields
}
else {
// It's tempting to try to use DAY_OF_WEEK here, if it
@ -932,12 +932,12 @@ GregorianCalendar::computeTime(UErrorCode& status)
// the Julian day number, which has been computed correctly
// using the disambiguation algorithm above. [LIU]
dstOffset = zone.getOffset((uint8_t)era,
internalGet(YEAR),
internalGet(MONTH),
internalGet(DATE),
internalGet(UCAL_YEAR),
internalGet(UCAL_MONTH),
internalGet(UCAL_DATE),
dow,
normalizedMillisInDay[0],
monthLength(internalGet(MONTH)),
monthLength(internalGet(UCAL_MONTH)),
status) -
zoneOffset;
// Note: Because we pass in wall millisInDay, rather than
@ -980,10 +980,10 @@ double GregorianCalendar::computeJulianDayOfYear(UBool isGregorian,
*/
int32_t GregorianCalendar::computeRelativeDOW() const {
int32_t relDow = 0;
if (fStamp[DOW_LOCAL] > fStamp[DAY_OF_WEEK]) {
relDow = internalGet(DOW_LOCAL) - 1; // 1-based
} else if (fStamp[DAY_OF_WEEK] != kUnset) {
relDow = internalGet(DAY_OF_WEEK) - getFirstDayOfWeek();
if (fStamp[UCAL_DOW_LOCAL] > fStamp[UCAL_DAY_OF_WEEK]) {
relDow = internalGet(UCAL_DOW_LOCAL) - 1; // 1-based
} else if (fStamp[UCAL_DAY_OF_WEEK] != kUnset) {
relDow = internalGet(UCAL_DAY_OF_WEEK) - getFirstDayOfWeek();
if (relDow < 0) relDow += 7;
}
return relDow;
@ -1020,7 +1020,7 @@ int32_t GregorianCalendar::computeDOYfromWOY(double julianDayOfYear) const {
? (8 - fdy) : (1 - fdy))
// Adjust for the week number.
+ (7 * (internalGet(WEEK_OF_YEAR) - 1))
+ (7 * (internalGet(UCAL_WEEK_OF_YEAR) - 1))
// Adjust for the DOW
+ computeRelativeDOW();
@ -1041,12 +1041,12 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
// fields are missing, we use their default values, which are those of
// the epoch start, or in the case of DAY_OF_WEEK, the first day in
// the week.
int32_t monthStamp = fStamp[MONTH];
int32_t domStamp = fStamp[DAY_OF_MONTH];
int32_t womStamp = fStamp[WEEK_OF_MONTH];
int32_t dowimStamp = fStamp[DAY_OF_WEEK_IN_MONTH];
int32_t doyStamp = fStamp[DAY_OF_YEAR];
int32_t woyStamp = fStamp[WEEK_OF_YEAR];
int32_t monthStamp = fStamp[UCAL_MONTH];
int32_t domStamp = fStamp[UCAL_DATE];
int32_t womStamp = fStamp[UCAL_WEEK_OF_MONTH];
int32_t dowimStamp = fStamp[UCAL_DAY_OF_WEEK_IN_MONTH];
int32_t doyStamp = fStamp[UCAL_DAY_OF_YEAR];
int32_t woyStamp = fStamp[UCAL_WEEK_OF_YEAR];
UBool isLeap;
double julianDay;
@ -1061,9 +1061,9 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
// specific handling of unset will be used below, or (b) all
// stamps are kInternallySet. In the latter case we want to
// use the YEAR_WOY if it is newer.
if (fStamp[YEAR_WOY] > fStamp[YEAR]) {
year = internalGet(YEAR_WOY);
if (fStamp[ERA] != kUnset && internalGet(ERA) == BC) {
if (fStamp[UCAL_YEAR_WOY] > fStamp[UCAL_YEAR]) {
year = internalGet(UCAL_YEAR_WOY);
if (fStamp[UCAL_ERA] != kUnset && internalGet(UCAL_ERA) == BC) {
year = 1 - year;
}
// Only the WOY algorithm correctly handles YEAR_WOY, so
@ -1076,11 +1076,11 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
// other stamp. This means the WOY has been explicitly
// set, and will be used for computation.
bestStamp = woyStamp;
if (fStamp[YEAR_WOY] != kUnset && fStamp[YEAR_WOY] >= fStamp[YEAR]) {
if (fStamp[UCAL_YEAR_WOY] != kUnset && fStamp[UCAL_YEAR_WOY] >= fStamp[UCAL_YEAR]) {
// The YEAR_WOY is set, and is not superceded by the
// YEAR; use it.
year = internalGet(YEAR_WOY);
year = internalGet(UCAL_YEAR_WOY);
}
/* At this point we cannot avoid using the WEEK_OF_YEAR together
@ -1105,7 +1105,7 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
* on the YEAR field. - aliu
*/
else if (internalGet(WEEK_OF_YEAR) == 1) {
else if (internalGet(UCAL_WEEK_OF_YEAR) == 1) {
// YEAR_WOY has not been set, so we must use the YEAR.
// Since WOY computations rely on the YEAR_WOY, not the
// YEAR, we must guess at its value. It is usually equal
@ -1143,7 +1143,7 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
}
}
} else if (internalGet(WEEK_OF_YEAR) >= 52) {
} else if (internalGet(UCAL_WEEK_OF_YEAR) >= 52) {
// FDW = Mon, MDFW = 4, Sat Jan 01 2000, WOY 52, YEAR_WOY 1999
julianDay = computeJulianDayOfYear(isGregorian, year, isLeap);
if (computeDOYfromWOY(julianDay) > yearLength(year)) {
@ -1171,7 +1171,7 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
useMonth = TRUE;
// We have the month specified. Make it 0-based for the algorithm.
month = (monthStamp != kUnset) ? internalGet(MONTH) - JANUARY : 0;
month = (monthStamp != kUnset) ? internalGet(UCAL_MONTH) - UCAL_JANUARY : 0;
// If the month is out of range, adjust it into range
if (month < 0 || month > 11) {
@ -1196,7 +1196,7 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
if (bestStamp == domStamp ||
bestStamp == monthStamp) {
date = (domStamp != kUnset) ? internalGet(DAY_OF_MONTH) : 1;
date = (domStamp != kUnset) ? internalGet(UCAL_DATE) : 1;
}
else { // assert(bestStamp == womStamp || bestStamp == dowimStamp)
// Compute from day of week plus week number or from the day of
@ -1212,8 +1212,8 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
// 1..-6. It represents the locale-specific first day of the
// week of the first day of the month, ignoring minimal days in
// first week.
date = 1 - fdm + ((fStamp[DAY_OF_WEEK] != kUnset) ?
(internalGet(DAY_OF_WEEK) - getFirstDayOfWeek()) : 0);
date = 1 - fdm + ((fStamp[UCAL_DAY_OF_WEEK] != kUnset) ?
(internalGet(UCAL_DAY_OF_WEEK) - getFirstDayOfWeek()) : 0);
if (bestStamp == womStamp) {
// Adjust for minimal days in first week.
@ -1221,7 +1221,7 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
date += 7;
// Now adjust for the week number.
date += 7 * (internalGet(WEEK_OF_MONTH) - 1);
date += 7 * (internalGet(UCAL_WEEK_OF_MONTH) - 1);
}
else { // assert(bestStamp == dowimStamp)
// Adjust into the month, if needed.
@ -1230,7 +1230,7 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
// We are basing this on the day-of-week-in-month. The only
// trickiness occurs if the day-of-week-in-month is
// negative.
int32_t dim = internalGet(DAY_OF_WEEK_IN_MONTH);
int32_t dim = internalGet(UCAL_DAY_OF_WEEK_IN_MONTH);
if (dim >= 0) {
date += 7*(dim - 1);
} else {
@ -1241,7 +1241,7 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
// in this month. Note that we handle -2, -3,
// etc. correctly, even though values < -1 are
// technically disallowed.
date += ((monthLength(internalGet(MONTH), year) - date) / 7 + dim + 1) * 7;
date += ((monthLength(internalGet(UCAL_MONTH), year) - date) / 7 + dim + 1) * 7;
}
}
}
@ -1262,7 +1262,7 @@ GregorianCalendar::computeJulianDay(UBool isGregorian, int32_t year)
doCutoverAdjustment = FALSE;
}
else if (bestStamp == doyStamp) {
doy = internalGet(DAY_OF_YEAR);
doy = internalGet(UCAL_DAY_OF_YEAR);
}
else if (bestStamp == woyStamp) {
doy = computeDOYfromWOY(julianDay);
@ -1365,7 +1365,7 @@ GregorianCalendar::aggregateStamp(int32_t stamp_a, int32_t stamp_b)
// -------------------------------------
void
GregorianCalendar::add(EDateFields field, int32_t amount, UErrorCode& status)
GregorianCalendar::add(UCalendarDateFields field, int32_t amount, UErrorCode& status)
{
if (U_FAILURE(status))
return;
@ -1374,7 +1374,7 @@ GregorianCalendar::add(EDateFields field, int32_t amount, UErrorCode& status)
return; // Do nothing!
complete(status);
if (field == YEAR || field == YEAR_WOY) {
if (field == UCAL_YEAR || field == UCAL_YEAR_WOY) {
int32_t year = internalGet(field);
int32_t era = internalGetEra();
year += (era == AD) ? amount : -amount;
@ -1383,33 +1383,33 @@ GregorianCalendar::add(EDateFields field, int32_t amount, UErrorCode& status)
else { // year <= 0
set(field, 1 - year);
// if year == 0, you get 1 BC
set(ERA, (AD + BC) - era);
set(UCAL_ERA, (AD + BC) - era);
}
pinDayOfMonth();
}
else if (field == MONTH) {
int32_t month = internalGet(MONTH) + amount;
else if (field == UCAL_MONTH) {
int32_t month = internalGet(UCAL_MONTH) + amount;
if (month >= 0) {
add(YEAR, (int32_t) (month / 12), status);
set(MONTH, (int32_t) (month % 12));
add(UCAL_YEAR, (int32_t) (month / 12), status);
set(UCAL_MONTH, (int32_t) (month % 12));
}
else { // month < 0
add(YEAR, (int32_t) ((month + 1) / 12) - 1, status);
add(UCAL_YEAR, (int32_t) ((month + 1) / 12) - 1, status);
month %= 12;
if (month < 0)
month += 12;
set(MONTH, JANUARY + month);
set(UCAL_MONTH, UCAL_JANUARY + month);
}
pinDayOfMonth();
}
else if (field == ERA) {
int32_t era = internalGet(ERA) + amount;
else if (field == UCAL_ERA) {
int32_t era = internalGet(UCAL_ERA) + amount;
if (era < 0)
era = 0;
if (era > 1)
era = 1;
set(ERA, era);
set(UCAL_ERA, era);
}
else {
// We handle most fields here. The algorithm is to add a computed amount
@ -1434,45 +1434,45 @@ GregorianCalendar::add(EDateFields field, int32_t amount, UErrorCode& status)
UBool adjustDST = TRUE;
switch (field) {
case WEEK_OF_YEAR:
case WEEK_OF_MONTH:
case DAY_OF_WEEK_IN_MONTH:
case UCAL_WEEK_OF_YEAR:
case UCAL_WEEK_OF_MONTH:
case UCAL_DAY_OF_WEEK_IN_MONTH:
delta *= 7 * 24 * 60 * 60 * 1000; // 7 days
break;
case AM_PM:
case UCAL_AM_PM:
delta *= 12 * 60 * 60 * 1000; // 12 hrs
break;
case DATE: // synonym of DAY_OF_MONTH
case DAY_OF_YEAR:
case DAY_OF_WEEK:
case DOW_LOCAL:
case UCAL_DATE: // synonym of DAY_OF_MONTH
case UCAL_DAY_OF_YEAR:
case UCAL_DAY_OF_WEEK:
case UCAL_DOW_LOCAL:
delta *= 24 * 60 * 60 * 1000; // 1 day
break;
case HOUR_OF_DAY:
case HOUR:
case UCAL_HOUR_OF_DAY:
case UCAL_HOUR:
delta *= 60 * 60 * 1000; // 1 hour
adjustDST = FALSE;
break;
case MINUTE:
case UCAL_MINUTE:
delta *= 60 * 1000; // 1 minute
adjustDST = FALSE;
break;
case SECOND:
case UCAL_SECOND:
delta *= 1000; // 1 second
adjustDST = FALSE;
break;
case MILLISECOND:
case UCAL_MILLISECOND:
adjustDST = FALSE;
break;
case ZONE_OFFSET:
case DST_OFFSET:
case UCAL_ZONE_OFFSET:
case UCAL_DST_OFFSET:
default:
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
@ -1481,14 +1481,14 @@ GregorianCalendar::add(EDateFields field, int32_t amount, UErrorCode& status)
// Save the current DST state.
int32_t dst = 0;
if (adjustDST)
dst = internalGet(DST_OFFSET);
dst = internalGet(UCAL_DST_OFFSET);
setTimeInMillis(internalGetTime() + delta, status); // Automatically computes fields if necessary
if (adjustDST) {
// Now do the DST adjustment alluded to above.
// Only call setTimeInMillis if necessary, because it's an expensive call.
dst -= internalGet(DST_OFFSET);
dst -= internalGet(UCAL_DST_OFFSET);
if(dst!= 0)
setTimeInMillis(internalGetTime() + dst, status);
}
@ -1502,7 +1502,7 @@ GregorianCalendar::add(EDateFields field, int32_t amount, UErrorCode& status)
* Note: This will be made public later. [LIU]
*/
void
GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
GregorianCalendar::roll(UCalendarDateFields field, int32_t amount, UErrorCode& status)
{
if(U_FAILURE(status))
return;
@ -1512,7 +1512,7 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
int32_t min = 0, max = 0, gap;
if (field >= 0 && field < FIELD_COUNT) {
if (field >= 0 && field < UCAL_FIELD_COUNT) {
complete(status);
min = getMinimum(field);
max = getMaximum(field);
@ -1525,13 +1525,13 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
int32_t cMonthLen=0; // 'c' for cutover; in days
int32_t cDayOfMonth=0; // no discontinuity: [0, cMonthLen)
double cMonthStart=0.0; // in ms
if (field == DAY_OF_MONTH || field == WEEK_OF_MONTH) {
max = monthLength(internalGet(MONTH));
if (field == UCAL_DATE || field == UCAL_WEEK_OF_MONTH) {
max = monthLength(internalGet(UCAL_MONTH));
double t = internalGetTime();
// We subtract 1 from the DAY_OF_MONTH to make it zero-based, and an
// additional 10 if we are after the cutover. Thus the monthStart
// value will be correct iff we actually are in the cutover month.
cDayOfMonth = internalGet(DAY_OF_MONTH) - ((t >= fGregorianCutover) ? 10 : 0);
cDayOfMonth = internalGet(UCAL_DATE) - ((t >= fGregorianCutover) ? 10 : 0);
cMonthStart = t - ((cDayOfMonth - 1) * kOneDay);
// A month containing the cutover is 10 days shorter.
@ -1542,21 +1542,21 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
}
switch (field) {
case ERA:
case YEAR:
case YEAR_WOY:
case AM_PM:
case MINUTE:
case SECOND:
case MILLISECOND:
case UCAL_ERA:
case UCAL_YEAR:
case UCAL_YEAR_WOY:
case UCAL_AM_PM:
case UCAL_MINUTE:
case UCAL_SECOND:
case UCAL_MILLISECOND:
// These fields are handled simply, since they have fixed minima
// and maxima. The field DAY_OF_MONTH is almost as simple. Other
// fields are complicated, since the range within they must roll
// varies depending on the date.
break;
case HOUR:
case HOUR_OF_DAY:
case UCAL_HOUR:
case UCAL_HOUR_OF_DAY:
// Rolling the hour is difficult on the ONSET and CEASE days of
// daylight savings. For example, if the change occurs at
// 2 AM, we have the following progression:
@ -1574,16 +1574,16 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
setTime(start + ((double)U_MILLIS_PER_HOUR * (newHour - oldHour)), status);
return;
}
case MONTH:
case UCAL_MONTH:
// Rolling the month involves both pinning the final value to [0, 11]
// and adjusting the DAY_OF_MONTH if necessary. We only adjust the
// DAY_OF_MONTH if, after updating the MONTH field, it is illegal.
// E.g., <jan31>.roll(MONTH, 1) -> <feb28> or <feb29>.
{
int32_t mon = (internalGet(MONTH) + amount) % 12;
int32_t mon = (internalGet(UCAL_MONTH) + amount) % 12;
if (mon < 0)
mon += 12;
set(MONTH, mon);
set(UCAL_MONTH, mon);
// Keep the day of month in range. We don't want to spill over
// into the next month; e.g., we don't want jan31 + 1 mo -> feb31 ->
@ -1591,13 +1591,13 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
// NOTE: We could optimize this later by checking for dom <= 28
// first. Do this if there appears to be a need. [LIU]
int32_t monthLen = monthLength(mon);
int32_t dom = internalGet(DAY_OF_MONTH);
int32_t dom = internalGet(UCAL_DATE);
if (dom > monthLen)
set(DAY_OF_MONTH, monthLen);
set(UCAL_DATE, monthLen);
return;
}
case WEEK_OF_YEAR:
case UCAL_WEEK_OF_YEAR:
{
// Unlike WEEK_OF_MONTH, WEEK_OF_YEAR never shifts the day of the
// week. However, rolling the week of the year can have seemingly
@ -1606,12 +1606,12 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
// date Dec 28, 1997 is the first day of week 1 of 1998 (if
// weeks start on Sunday and the minimal days in first week is
// <= 3).
int32_t woy = internalGet(WEEK_OF_YEAR);
int32_t woy = internalGet(UCAL_WEEK_OF_YEAR);
// Get the ISO year, which matches the week of year. This
// may be one year before or after the calendar year.
int32_t isoYear = internalGet(YEAR_WOY);
int32_t isoDoy = internalGet(DAY_OF_YEAR);
if (internalGet(MONTH) == Calendar::JANUARY) {
int32_t isoYear = internalGet(UCAL_YEAR_WOY);
int32_t isoDoy = internalGet(UCAL_DAY_OF_YEAR);
if (internalGet(UCAL_MONTH) == UCAL_JANUARY) {
if (woy >= 52) {
isoDoy += yearLength(isoYear);
}
@ -1631,7 +1631,7 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
// week 1 of the next year, we drop the last week by
// subtracting 7 from the last day of the year.
int32_t lastDoy = yearLength(isoYear);
int32_t lastRelDow = (lastDoy - isoDoy + internalGet(DAY_OF_WEEK) -
int32_t lastRelDow = (lastDoy - isoDoy + internalGet(UCAL_DAY_OF_WEEK) -
getFirstDayOfWeek()) % 7;
if (lastRelDow < 0)
lastRelDow += 7;
@ -1640,11 +1640,11 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
int32_t lastWoy = weekNumber(lastDoy, lastRelDow + 1);
woy = ((woy + lastWoy - 1) % lastWoy) + 1;
}
set(WEEK_OF_YEAR, woy);
set(YEAR_WOY, isoYear); // make YEAR_WOY timestamp > YEAR timestamp
set(UCAL_WEEK_OF_YEAR, woy);
set(UCAL_YEAR_WOY, isoYear); // make YEAR_WOY timestamp > YEAR timestamp
return;
}
case WEEK_OF_MONTH:
case UCAL_WEEK_OF_MONTH:
{
// This is tricky, because during the roll we may have to shift
// to a different day of the week. For example:
@ -1681,12 +1681,12 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
// Normalize the DAY_OF_WEEK so that 0 is the first day of the week
// in this locale. We have dow in 0..6.
int32_t dow = internalGet(DAY_OF_WEEK) - getFirstDayOfWeek();
int32_t dow = internalGet(UCAL_DAY_OF_WEEK) - getFirstDayOfWeek();
if (dow < 0)
dow += 7;
// Find the day of month, compensating for cutover discontinuity.
int32_t dom = inCutoverMonth ? cDayOfMonth : internalGet(DAY_OF_MONTH);
int32_t dom = inCutoverMonth ? cDayOfMonth : internalGet(UCAL_DATE);
// Find the day of the week (normalized for locale) for the first
// of the month.
@ -1706,7 +1706,7 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
// Get the day of the week (normalized for locale) for the last
// day of the month.
int32_t monthLen = inCutoverMonth ? cMonthLen : monthLength(internalGet(MONTH));
int32_t monthLen = inCutoverMonth ? cMonthLen : monthLength(internalGet(UCAL_MONTH));
int32_t ldm = (monthLen - dom + dow) % 7;
// We know monthLen >= DAY_OF_MONTH so we skip the += 7 step here.
@ -1742,11 +1742,11 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
if (inCutoverMonth) {
setTimeInMillis(cMonthStart + (newDom-1)*kOneDay, status);
} else {
set(DAY_OF_MONTH, newDom);
set(UCAL_DATE, newDom);
}
return;
}
case DAY_OF_MONTH:
case UCAL_DATE:
if (inCutoverMonth) {
// The default computation works except when the current month
// contains the Gregorian cutover. We handle this special case
@ -1760,16 +1760,16 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
setTimeInMillis(cMonthStart + msIntoMonth, status);
return;
} else {
max = monthLength(internalGet(MONTH));
max = monthLength(internalGet(UCAL_MONTH));
// ...else fall through to default computation
}
break;
case DAY_OF_YEAR:
case UCAL_DAY_OF_YEAR:
{
// Roll the day of year using millis. Compute the millis for
// the start of the year, and get the length of the year.
double delta = amount * kOneDay; // Scale up from days to millis
double min2 = internalGetTime() - (internalGet(DAY_OF_YEAR) - 1) * kOneDay;
double min2 = internalGetTime() - (internalGet(UCAL_DAY_OF_YEAR) - 1) * kOneDay;
int32_t yearLen = yearLength();
internalSetTime( uprv_fmod((internalGetTime() + delta - min2), (yearLen * kOneDay)));
if (internalGetTime() < 0)
@ -1779,8 +1779,8 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
return;
}
case DAY_OF_WEEK:
case DOW_LOCAL:
case UCAL_DAY_OF_WEEK:
case UCAL_DOW_LOCAL:
{
// Roll the day of week using millis. Compute the millis for
// the start of the week, using the first day of week setting.
@ -1789,7 +1789,7 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
// Compute the number of days before the current day in this
// week. This will be a value 0..6.
int32_t leadDays = internalGet(field) -
((field == DAY_OF_WEEK) ? getFirstDayOfWeek() : 1);
((field == UCAL_DAY_OF_WEEK) ? getFirstDayOfWeek() : 1);
if (leadDays < 0)
leadDays += 7;
double min2 = internalGetTime() - leadDays * kOneDay;
@ -1799,7 +1799,7 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
setTimeInMillis(internalGetTime() + min2, status);
return;
}
case DAY_OF_WEEK_IN_MONTH:
case UCAL_DAY_OF_WEEK_IN_MONTH:
{
// Roll the day of week in the month using millis. Determine
// the first day of the week in the month, and then the last,
@ -1807,10 +1807,10 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
double delta = amount * kOneWeek; // Scale up from weeks to millis
// Find the number of same days of the week before this one
// in this month.
int32_t preWeeks = (internalGet(DAY_OF_MONTH) - 1) / 7;
int32_t preWeeks = (internalGet(UCAL_DATE) - 1) / 7;
// Find the number of same days of the week after this one
// in this month.
int32_t postWeeks = (monthLength(internalGet(MONTH)) - internalGet(DAY_OF_MONTH)) / 7;
int32_t postWeeks = (monthLength(internalGet(UCAL_MONTH)) - internalGet(UCAL_DATE)) / 7;
// From these compute the min and gap millis for rolling.
double min2 = internalGetTime() - preWeeks * kOneWeek;
double gap2 = kOneWeek * (preWeeks + postWeeks + 1); // Must add 1!
@ -1821,8 +1821,8 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
setTimeInMillis(internalGetTime() + min2, status);
return;
}
case ZONE_OFFSET:
case DST_OFFSET:
case UCAL_ZONE_OFFSET:
case UCAL_DST_OFFSET:
default:
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
@ -1846,7 +1846,7 @@ GregorianCalendar::roll(EDateFields field, int32_t amount, UErrorCode& status)
// -------------------------------------
int32_t
GregorianCalendar::getMinimum(EDateFields field) const
GregorianCalendar::getMinimum(UCalendarDateFields field) const
{
return kMinValues[field];
}
@ -1854,7 +1854,7 @@ GregorianCalendar::getMinimum(EDateFields field) const
// -------------------------------------
int32_t
GregorianCalendar::getMaximum(EDateFields field) const
GregorianCalendar::getMaximum(UCalendarDateFields field) const
{
return kMaxValues[field];
}
@ -1862,7 +1862,7 @@ GregorianCalendar::getMaximum(EDateFields field) const
// -------------------------------------
int32_t
GregorianCalendar::getGreatestMinimum(EDateFields field) const
GregorianCalendar::getGreatestMinimum(UCalendarDateFields field) const
{
return kMinValues[field];
}
@ -1870,7 +1870,7 @@ GregorianCalendar::getGreatestMinimum(EDateFields field) const
// -------------------------------------
int32_t
GregorianCalendar::getLeastMaximum(EDateFields field) const
GregorianCalendar::getLeastMaximum(UCalendarDateFields field) const
{
return kLeastMaxValues[field];
}
@ -1878,7 +1878,7 @@ GregorianCalendar::getLeastMaximum(EDateFields field) const
// -------------------------------------
int32_t
GregorianCalendar::getActualMinimum(EDateFields field) const
GregorianCalendar::getActualMinimum(UCalendarDateFields field) const
{
return getMinimum(field);
}
@ -1886,7 +1886,7 @@ GregorianCalendar::getActualMinimum(EDateFields field) const
// -------------------------------------
int32_t
GregorianCalendar::getActualMaximum(EDateFields field) const
GregorianCalendar::getActualMaximum(UCalendarDateFields field) const
{
/* It is a known limitation that the code here (and in getActualMinimum)
* won't behave properly at the extreme limits of GregorianCalendar's
@ -1909,22 +1909,22 @@ GregorianCalendar::getActualMaximum(EDateFields field) const
switch (field) {
// we have functions that enable us to fast-path number of days in month
// of year
case DAY_OF_MONTH:
return monthLength(get(MONTH, status));
case UCAL_DATE:
return monthLength(get(UCAL_MONTH, status));
case DAY_OF_YEAR:
case UCAL_DAY_OF_YEAR:
return yearLength();
// for week of year, week of month, or day of week in month, we
// just fall back on the default implementation in Calendar (I'm not sure
// we could do better by having special calculations here)
case WEEK_OF_YEAR:
case WEEK_OF_MONTH:
case DAY_OF_WEEK_IN_MONTH:
case UCAL_WEEK_OF_YEAR:
case UCAL_WEEK_OF_MONTH:
case UCAL_DAY_OF_WEEK_IN_MONTH:
return Calendar::getActualMaximum(field, status);
case YEAR:
case YEAR_WOY:
case UCAL_YEAR:
case UCAL_YEAR_WOY:
/* The year computation is no different, in principle, from the
* others, however, the range of possible maxima is large. In
* addition, the way we know we've exceeded the range is different.
@ -1948,7 +1948,7 @@ GregorianCalendar::getActualMaximum(EDateFields field) const
Calendar *cal = (Calendar*)this->clone();
cal->setLenient(TRUE);
int32_t era = cal->get(ERA, status);
int32_t era = cal->get(UCAL_ERA, status);
if(U_FAILURE(status))
return 0;
@ -1964,7 +1964,7 @@ GregorianCalendar::getActualMaximum(EDateFields field) const
while((lowGood + 1) < highBad) {
int32_t y = (lowGood + highBad) / 2;
cal->set(field, y);
if(cal->get(field, status) == y && cal->get(ERA, status) == era) {
if(cal->get(field, status) == y && cal->get(UCAL_ERA, status) == era) {
lowGood = y;
}
else {
@ -1995,7 +1995,7 @@ GregorianCalendar::inDaylightTime(UErrorCode& status) const
// Force an update of the state of the Calendar.
((GregorianCalendar*)this)->complete(status); // cast away const
return (UBool)(U_SUCCESS(status) ? (internalGet(DST_OFFSET) != 0) : FALSE);
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
}
// -------------------------------------
@ -2006,7 +2006,7 @@ GregorianCalendar::inDaylightTime(UErrorCode& status) const
*/
int32_t
GregorianCalendar::internalGetEra() const {
return isSet(ERA) ? internalGet(ERA) : AD;
return isSet(UCAL_ERA) ? internalGet(UCAL_ERA) : AD;
}
U_NAMESPACE_END

View file

@ -410,7 +410,7 @@ SimpleTimeZone::getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
// 7-argument getOffset(), and outside code should use Calendar.get(int
// field) with fields ZONE_OFFSET and DST_OFFSET. We can't get rid of
// this method because it's public API. - liu 8/10/98
if(month < Calendar::JANUARY || month > Calendar::DECEMBER) {
if(month < UCAL_JANUARY || month > UCAL_DECEMBER) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
@ -429,8 +429,8 @@ SimpleTimeZone::getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
// 9-argument getOffset(), and outside code should use Calendar.get(int
// field) with fields ZONE_OFFSET and DST_OFFSET. We can't get rid of
// this method because it's public API. - liu 8/10/98
if (month < Calendar::JANUARY
|| month > Calendar::DECEMBER) {
if (month < UCAL_JANUARY
|| month > UCAL_DECEMBER) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
@ -451,12 +451,12 @@ SimpleTimeZone::getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
if(U_FAILURE(status)) return 0;
if ((era != GregorianCalendar::AD && era != GregorianCalendar::BC)
|| month < Calendar::JANUARY
|| month > Calendar::DECEMBER
|| month < UCAL_JANUARY
|| month > UCAL_DECEMBER
|| day < 1
|| day > monthLength
|| dayOfWeek < Calendar::SUNDAY
|| dayOfWeek > Calendar::SATURDAY
|| dayOfWeek < UCAL_SUNDAY
|| dayOfWeek > UCAL_SATURDAY
|| millis < 0
|| millis >= U_MILLIS_PER_DAY
|| monthLength < 28
@ -822,7 +822,7 @@ SimpleTimeZone::decodeStartRule(UErrorCode& status)
dstSavings = U_MILLIS_PER_HOUR;
}
if (startDay != 0) {
if (startMonth < Calendar::JANUARY || startMonth > Calendar::DECEMBER) {
if (startMonth < UCAL_JANUARY || startMonth > UCAL_DECEMBER) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@ -845,7 +845,7 @@ SimpleTimeZone::decodeStartRule(UErrorCode& status)
startMode = DOW_LE_DOM_MODE;
}
}
if (startDayOfWeek > Calendar::SATURDAY) {
if (startDayOfWeek > UCAL_SATURDAY) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@ -877,7 +877,7 @@ SimpleTimeZone::decodeEndRule(UErrorCode& status)
dstSavings = U_MILLIS_PER_HOUR;
}
if (endDay != 0) {
if (endMonth < Calendar::JANUARY || endMonth > Calendar::DECEMBER) {
if (endMonth < UCAL_JANUARY || endMonth > UCAL_DECEMBER) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
@ -900,7 +900,7 @@ SimpleTimeZone::decodeEndRule(UErrorCode& status)
endMode = DOW_LE_DOM_MODE;
}
}
if (endDayOfWeek > Calendar::SATURDAY) {
if (endDayOfWeek > UCAL_SATURDAY) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return;
}

View file

@ -396,7 +396,7 @@ void SimpleDateFormat::parseAmbiguousDatesAsAfter(UDate startDate, UErrorCode& s
fCalendar->setTime(startDate, status);
if(U_SUCCESS(status)) {
fDefaultCenturyStart = startDate;
fDefaultCenturyStartYear = fCalendar->get(Calendar::YEAR, status);
fDefaultCenturyStartYear = fCalendar->get(UCAL_YEAR, status);
}
}
@ -478,16 +478,16 @@ SimpleDateFormat::format(const Formattable& obj,
//----------------------------------------------------------------------
// Map index into pattern character string to Calendar field number.
const Calendar::EDateFields
const UCalendarDateFields
SimpleDateFormat::fgPatternIndexToCalendarField[] =
{
Calendar::ERA, Calendar::YEAR, Calendar::MONTH, Calendar::DATE,
Calendar::HOUR_OF_DAY, Calendar::HOUR_OF_DAY, Calendar::MINUTE,
Calendar::SECOND, Calendar::MILLISECOND, Calendar::DAY_OF_WEEK,
Calendar::DAY_OF_YEAR, Calendar::DAY_OF_WEEK_IN_MONTH,
Calendar::WEEK_OF_YEAR, Calendar::WEEK_OF_MONTH,
Calendar::AM_PM, Calendar::HOUR, Calendar::HOUR, Calendar::ZONE_OFFSET,
Calendar::YEAR_WOY, Calendar::DOW_LOCAL
UCAL_ERA, UCAL_YEAR, UCAL_MONTH, UCAL_DATE,
UCAL_HOUR_OF_DAY, UCAL_HOUR_OF_DAY, UCAL_MINUTE,
UCAL_SECOND, UCAL_MILLISECOND, UCAL_DAY_OF_WEEK,
UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK_IN_MONTH,
UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH,
UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR, UCAL_ZONE_OFFSET,
UCAL_YEAR_WOY, UCAL_DOW_LOCAL
};
// Map index into pattern character string to DateFormat field number
@ -531,7 +531,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
}
patternCharIndex = (EField)(patternCharPtr - DateFormatSymbols::getPatternUChars());
Calendar::EDateFields field = fgPatternIndexToCalendarField[patternCharIndex];
UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex];
int32_t value = cal.get(field, status);
if (U_FAILURE(status)) {
return;
@ -568,7 +568,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
// for "k" and "kk", write out the hour, adjusting midnight to appear as "24"
case kHourOfDay1Field:
if (value == 0)
zeroPaddingNumber(appendTo, cal.getMaximum(Calendar::HOUR_OF_DAY) + 1, count, maxIntCount);
zeroPaddingNumber(appendTo, cal.getMaximum(UCAL_HOUR_OF_DAY) + 1, count, maxIntCount);
else
zeroPaddingNumber(appendTo, value, count, maxIntCount);
break;
@ -602,7 +602,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
// as "12"
case kHour1Field:
if (value == 0)
zeroPaddingNumber(appendTo, cal.getLeastMaximum(Calendar::HOUR) + 1, count, maxIntCount);
zeroPaddingNumber(appendTo, cal.getLeastMaximum(UCAL_HOUR) + 1, count, maxIntCount);
else
zeroPaddingNumber(appendTo, value, count, maxIntCount);
break;
@ -617,8 +617,8 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
UnicodeString str;
int32_t zoneIndex = fSymbols->getZoneIndex(cal.getTimeZone().getID(str));
if (zoneIndex == -1) {
value = cal.get(Calendar::ZONE_OFFSET, status) +
cal.get(Calendar::DST_OFFSET, status);
value = cal.get(UCAL_ZONE_OFFSET, status) +
cal.get(UCAL_DST_OFFSET, status);
if (value < 0) {
appendTo += fgGmtMinus;
@ -631,7 +631,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
appendTo += (UChar)0x003A /*':'*/;
zeroPaddingNumber(appendTo, (int32_t)((value%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE), 2, 2);
}
else if (cal.get(Calendar::DST_OFFSET, status) != 0) {
else if (cal.get(UCAL_DST_OFFSET, status) != 0) {
if (count >= 4)
appendTo += fSymbols->fZoneStrings[zoneIndex][3];
else
@ -946,7 +946,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
if (parsedDate < internalGetDefaultCenturyStart())
{
// We can't use add here because that does a complete() first.
cal.set(Calendar::YEAR, internalGetDefaultCenturyStartYear() + 100);
cal.set(UCAL_YEAR, internalGetDefaultCenturyStartYear() + 100);
}
delete copy;
}
@ -979,7 +979,7 @@ SimpleDateFormat::parse(const UnicodeString& text, UErrorCode& status) const
int32_t SimpleDateFormat::matchString(const UnicodeString& text,
int32_t start,
Calendar::EDateFields field,
UCalendarDateFields field,
const UnicodeString* data,
int32_t dataCount,
Calendar& cal) const
@ -987,7 +987,7 @@ int32_t SimpleDateFormat::matchString(const UnicodeString& text,
int32_t i = 0;
int32_t count = dataCount;
if (field == Calendar::DAY_OF_WEEK) i = 1;
if (field == UCAL_DAY_OF_WEEK) i = 1;
// There may be multiple strings in the data[] array which begin with
// the same prefix (e.g., Cerven and Cervenec (June and July) in Czech).
@ -1084,7 +1084,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
patternCharIndex = (EField)(patternCharPtr - DateFormatSymbols::getPatternUChars());
Calendar::EDateFields field = fgPatternIndexToCalendarField[patternCharIndex];
UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex];
// If there are any spaces here, skip over them. If we hit the end
// of the string, then fail.
@ -1131,7 +1131,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
switch (patternCharIndex) {
case kEraField:
return matchString(text, start, Calendar::ERA, fSymbols->fEras, fSymbols->fErasCount, cal);
return matchString(text, start, UCAL_ERA, fSymbols->fEras, fSymbols->fErasCount, cal);
case kYearField:
// If there are 3 or more YEAR pattern characters, this indicates
// that the year value is to be treated literally, without any
@ -1156,7 +1156,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
value += (fDefaultCenturyStartYear/100)*100 +
(value < ambiguousTwoDigitYear ? 100 : 0);
}
cal.set(Calendar::YEAR, value);
cal.set(UCAL_YEAR, value);
return pos.getIndex();
case kYearWOYField:
// Comment is the same as for kYearFiels - look above
@ -1169,7 +1169,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
value += (fDefaultCenturyStartYear/100)*100 +
(value < ambiguousTwoDigitYear ? 100 : 0);
}
cal.set(Calendar::YEAR_WOY, value);
cal.set(UCAL_YEAR_WOY, value);
return pos.getIndex();
case kMonthField:
if (count <= 2) // i.e., M or MM.
@ -1177,7 +1177,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
// Don't want to parse the month if it is a string
// while pattern uses numeric style: M or MM.
// [We computed 'value' above.]
cal.set(Calendar::MONTH, value - 1);
cal.set(UCAL_MONTH, value - 1);
return pos.getIndex();
}
else
@ -1186,38 +1186,38 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
// Want to be able to parse both short and long forms.
// Try count == 4 first:
int32_t newStart = 0;
if ((newStart = matchString(text, start, Calendar::MONTH,
if ((newStart = matchString(text, start, UCAL_MONTH,
fSymbols->fMonths, fSymbols->fMonthsCount, cal)) > 0)
return newStart;
else // count == 4 failed, now try count == 3
return matchString(text, start, Calendar::MONTH,
return matchString(text, start, UCAL_MONTH,
fSymbols->fShortMonths, fSymbols->fShortMonthsCount, cal);
}
case kHourOfDay1Field:
// [We computed 'value' above.]
if (value == cal.getMaximum(Calendar::HOUR_OF_DAY) + 1)
if (value == cal.getMaximum(UCAL_HOUR_OF_DAY) + 1)
value = 0;
cal.set(Calendar::HOUR_OF_DAY, value);
cal.set(UCAL_HOUR_OF_DAY, value);
return pos.getIndex();
case kDayOfWeekField:
{
// Want to be able to parse both short and long forms.
// Try count == 4 (DDDD) first:
int32_t newStart = 0;
if ((newStart = matchString(text, start, Calendar::DAY_OF_WEEK,
if ((newStart = matchString(text, start, UCAL_DAY_OF_WEEK,
fSymbols->fWeekdays, fSymbols->fWeekdaysCount, cal)) > 0)
return newStart;
else // DDDD failed, now try DDD
return matchString(text, start, Calendar::DAY_OF_WEEK,
return matchString(text, start, UCAL_DAY_OF_WEEK,
fSymbols->fShortWeekdays, fSymbols->fShortWeekdaysCount, cal);
}
case kAmPmField:
return matchString(text, start, Calendar::AM_PM, fSymbols->fAmPms, fSymbols->fAmPmsCount, cal);
return matchString(text, start, UCAL_AM_PM, fSymbols->fAmPms, fSymbols->fAmPmsCount, cal);
case kHour1Field:
// [We computed 'value' above.]
if (value == cal.getLeastMaximum(Calendar::HOUR)+1)
if (value == cal.getLeastMaximum(UCAL_HOUR)+1)
value = 0;
cal.set(Calendar::HOUR, value);
cal.set(UCAL_HOUR, value);
return pos.getIndex();
case kTimezoneField:
{
@ -1245,7 +1245,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
if ((text.length() - start) > gmtLen &&
(lcaseText.compare(start, gmtLen, lcaseGMT, 0, gmtLen)) == 0)
{
cal.set(Calendar::DST_OFFSET, 0);
cal.set(UCAL_DST_OFFSET, 0);
pos.setIndex(start + gmtLen);
@ -1254,7 +1254,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
else if( text[pos.getIndex()] == 0x002D /*'-'*/ )
sign = -1;
else {
cal.set(Calendar::ZONE_OFFSET, 0 );
cal.set(UCAL_ZONE_OFFSET, 0 );
return pos.getIndex();
}
@ -1313,11 +1313,11 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
// There are similar cases of such caseCompare() uses elsewhere in ICU.
if (0 == (text.caseCompare(start, zs->length(), *zs, 0))) {
TimeZone *tz = TimeZone::createTimeZone(fSymbols->fZoneStrings[i][0]);
cal.set(Calendar::ZONE_OFFSET, tz->getRawOffset());
cal.set(UCAL_ZONE_OFFSET, tz->getRawOffset());
// Must call set() with something -- TODO -- Fix this to
// use the correct DST SAVINGS for the zone.
delete tz;
cal.set(Calendar::DST_OFFSET, j >= 3 ? U_MILLIS_PER_HOUR : 0);
cal.set(UCAL_DST_OFFSET, j >= 3 ? U_MILLIS_PER_HOUR : 0);
return (start + fSymbols->fZoneStrings[i][j].length());
}
}
@ -1362,10 +1362,10 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
if (cal.getTimeZone().useDaylightTime())
{
cal.set(Calendar::DST_OFFSET, U_MILLIS_PER_HOUR);
cal.set(UCAL_DST_OFFSET, U_MILLIS_PER_HOUR);
offset -= U_MILLIS_PER_HOUR;
}
cal.set(Calendar::ZONE_OFFSET, offset);
cal.set(UCAL_ZONE_OFFSET, offset);
return pos.getIndex();
}
@ -1582,9 +1582,9 @@ SimpleDateFormat::initializeSystemDefaultCentury()
if (calendar != NULL && U_SUCCESS(status))
{
calendar->setTime(Calendar::getNow(), status);
calendar->add(Calendar::YEAR, -80, status);
calendar->add(UCAL_YEAR, -80, status);
fgSystemDefaultCenturyStart = calendar->getTime(status);
fgSystemDefaultCenturyStartYear = calendar->get(Calendar::YEAR, status);
fgSystemDefaultCenturyStartYear = calendar->get(UCAL_YEAR, status);
delete calendar;
}
// We have no recourse upon failure unless we want to propagate the failure

View file

@ -177,7 +177,7 @@ CollationKey::operator=(const CollationKey& other)
// NOTE: this is somewhat messy 'cause we can't count
// on memcmp returning the exact values which match
// Collator::EComparisonResult
Collator::EComparisonResult
UCollationResult
CollationKey::compareTo(const CollationKey& target) const
{
uint8_t *src = this->fBytes;
@ -185,7 +185,7 @@ CollationKey::compareTo(const CollationKey& target) const
// are we comparing the same string
if (src == tgt)
return Collator::EQUAL;
return UCOL_EQUAL;
/*
int count = (this->fCount < target.fCount) ? this->fCount : target.fCount;
@ -208,32 +208,32 @@ CollationKey::compareTo(const CollationKey& target) const
*/
int minLength;
Collator::EComparisonResult result;
UCollationResult result;
// are we comparing different lengths?
if (this->fCount != target.fCount) {
if (this->fCount < target.fCount) {
minLength = this->fCount;
result = Collator::LESS;
result = UCOL_LESS;
}
else {
minLength = target.fCount;
result = Collator::GREATER;
result = UCOL_GREATER;
}
}
else {
minLength = target.fCount;
result = Collator::EQUAL;
result = UCOL_EQUAL;
}
if (minLength > 0) {
int diff = uprv_memcmp(src, tgt, minLength);
if (diff > 0) {
return Collator::GREATER;
return UCOL_GREATER;
}
else
if (diff < 0) {
return Collator::LESS;
return UCOL_LESS;
}
}

View file

@ -342,7 +342,7 @@ void RuleBasedCollator::getVersion(UVersionInfo versionInfo) const
}
}
Collator::EComparisonResult RuleBasedCollator::compare(
UCollationResult RuleBasedCollator::compare(
const UnicodeString& source,
const UnicodeString& target,
int32_t length) const
@ -350,20 +350,20 @@ Collator::EComparisonResult RuleBasedCollator::compare(
return compare(source.getBuffer(), uprv_min(length,source.length()), target.getBuffer(), uprv_min(length,target.length()));
}
Collator::EComparisonResult RuleBasedCollator::compare(const UChar* source,
UCollationResult RuleBasedCollator::compare(const UChar* source,
int32_t sourceLength,
const UChar* target,
int32_t targetLength)
const
{
return getEComparisonResult(ucol_strcoll(ucollator, source, sourceLength,
target, targetLength));
return ucol_strcoll(ucollator, source, sourceLength,
target, targetLength);
}
/**
* Compare two strings using this collator
*/
Collator::EComparisonResult RuleBasedCollator::compare(
UCollationResult RuleBasedCollator::compare(
const UnicodeString& source,
const UnicodeString& target) const
{

View file

@ -982,8 +982,8 @@ TimeZone::getDisplayName(UBool daylight, EDisplayType style, const Locale& local
// For the pure-DST zone, we use JANUARY and DECEMBER
new SimpleTimeZone(getRawOffset(), getID(tempID),
Calendar::JANUARY , 1, 0, 0,
Calendar::DECEMBER , 31, 0, U_MILLIS_PER_DAY, status) :
UCAL_JANUARY , 1, 0, 0,
UCAL_DECEMBER , 31, 0, U_MILLIS_PER_DAY, status) :
new SimpleTimeZone(getRawOffset(), getID(tempID));
format.applyPattern(style == LONG ? "zzzz" : "z");

View file

@ -222,7 +222,7 @@ ucal_setAttribute( UCalendar* cal,
break;
case UCAL_FIRST_DAY_OF_WEEK:
((Calendar*)cal)->setFirstDayOfWeek((Calendar::EDaysOfWeek)newValue);
((Calendar*)cal)->setFirstDayOfWeek((UCalendarDaysOfWeek)newValue);
break;
case UCAL_MINIMAL_DAYS_IN_FIRST_WEEK:
@ -312,7 +312,7 @@ ucal_add( UCalendar* cal,
if(U_FAILURE(*status)) return;
((Calendar*)cal)->add((Calendar::EDateFields)field, amount, *status);
((Calendar*)cal)->add(field, amount, *status);
}
U_CAPI void U_EXPORT2
@ -324,7 +324,7 @@ ucal_roll( UCalendar* cal,
if(U_FAILURE(*status)) return;
((Calendar*)cal)->roll((Calendar::EDateFields)field, amount, *status);
((Calendar*)cal)->roll(field, amount, *status);
}
U_CAPI int32_t U_EXPORT2
@ -335,7 +335,7 @@ ucal_get( const UCalendar* cal,
if(U_FAILURE(*status)) return -1;
return ((Calendar*)cal)->get((Calendar::EDateFields)field, *status);
return ((Calendar*)cal)->get(field, *status);
}
U_CAPI void U_EXPORT2
@ -344,7 +344,7 @@ ucal_set( UCalendar* cal,
int32_t value)
{
((Calendar*)cal)->set((Calendar::EDateFields)field, value);
((Calendar*)cal)->set(field, value);
}
U_CAPI UBool U_EXPORT2
@ -352,7 +352,7 @@ ucal_isSet( const UCalendar* cal,
UCalendarDateFields field)
{
return ((Calendar*)cal)->isSet((Calendar::EDateFields)field);
return ((Calendar*)cal)->isSet(field);
}
U_CAPI void U_EXPORT2
@ -360,7 +360,7 @@ ucal_clearField( UCalendar* cal,
UCalendarDateFields field)
{
((Calendar*)cal)->clear((Calendar::EDateFields)field);
((Calendar*)cal)->clear(field);
}
U_CAPI void U_EXPORT2
@ -383,23 +383,23 @@ ucal_getLimit( const UCalendar* cal,
switch(type) {
case UCAL_MINIMUM:
return ((Calendar*)cal)->getMinimum((Calendar::EDateFields)field);
return ((Calendar*)cal)->getMinimum(field);
case UCAL_MAXIMUM:
return ((Calendar*)cal)->getMaximum((Calendar::EDateFields)field);
return ((Calendar*)cal)->getMaximum(field);
case UCAL_GREATEST_MINIMUM:
return ((Calendar*)cal)->getGreatestMinimum((Calendar::EDateFields)field);
return ((Calendar*)cal)->getGreatestMinimum(field);
case UCAL_LEAST_MAXIMUM:
return ((Calendar*)cal)->getLeastMaximum((Calendar::EDateFields)field);
return ((Calendar*)cal)->getLeastMaximum(field);
case UCAL_ACTUAL_MINIMUM:
return ((Calendar*)cal)->getActualMinimum((Calendar::EDateFields)field,
return ((Calendar*)cal)->getActualMinimum(field,
*status);
case UCAL_ACTUAL_MAXIMUM:
return ((Calendar*)cal)->getActualMaximum((Calendar::EDateFields)field,
return ((Calendar*)cal)->getActualMaximum(field,
*status);
default:

View file

@ -31,6 +31,7 @@
#include "unicode/uobject.h"
#include "unicode/locid.h"
#include "unicode/timezone.h"
#include "unicode/ucal.h"
U_NAMESPACE_BEGIN
@ -151,7 +152,7 @@ public:
* Field IDs for date and time. Used to specify date/time fields. ERA is calendar
* specific. Example ranges given are for illustration only; see specific Calendar
* subclasses for actual ranges.
* @stable ICU 2.0
* @deprecated ICU 2.6. Use C enum UCalendarDateFields defined in ucal.h
*/
enum EDateFields {
ERA, // Example: 0..1
@ -183,7 +184,7 @@ public:
* Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients
* who create locale resources for the field of first-day-of-week should be aware of
* this. For instance, in US locale, first-day-of-week is set to 1, i.e., SUNDAY.
* @stable ICU 2.0
* @deprecated ICU 2.6. Use C enum UCalendarDaysOfWeek defined in ucal.h
*/
enum EDaysOfWeek {
SUNDAY = 1,
@ -197,7 +198,7 @@ public:
/**
* Useful constants for month. Note: Calendar month is 0-based.
* @stable ICU 2.0
* @deprecated ICU 2.6. Use C enum UCalendarMonths defined in ucal.h
*/
enum EMonths {
JANUARY,
@ -217,7 +218,7 @@ public:
/**
* Useful constants for hour in 12-hour clock. Used in GregorianCalendar.
* @stable ICU 2.0
* @deprecated ICU 2.6. Use C enum UCalendarAMPMs defined in ucal.h
*/
enum EAmpm {
AM,
@ -463,7 +464,7 @@ public:
* leniency, this will be set to an error status.
* @stable ICU 2.0
*/
virtual void add(EDateFields field, int32_t amount, UErrorCode& status) = 0;
virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status) = 0;
/**
* Time Field Rolling function. Rolls (up/down) a single unit of time on the given
@ -478,7 +479,7 @@ public:
* hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the hour value in the range
* between 0 and 23, which is zero-based.
* <P>
* NOTE: Do not use this method -- use roll(EDateFields, int, UErrorCode&) instead.
* NOTE: Do not use this method -- use roll(UCalendarDateFields, int, UErrorCode&) instead.
*
* @param field The time field.
* @param up Indicates if the value of the specified time field is to be rolled
@ -488,7 +489,7 @@ public:
* leniency, this will be set to an error status.
* @stable ICU 2.0
*/
void roll(EDateFields field, UBool up, UErrorCode& status);
void roll(UCalendarDateFields field, UBool up, UErrorCode& status);
/**
* Time Field Rolling function. Rolls by the given amount on the given
@ -512,7 +513,7 @@ public:
* an error status.
* @stable ICU 2.0
*/
virtual void roll(EDateFields field, int32_t amount, UErrorCode& status) = 0;
virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) = 0;
/**
* Return the difference between the given time and the time this
@ -569,7 +570,7 @@ public:
* <code>field</code>.
* @stable ICU 2.0
*/
virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);
virtual int32_t fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status);
/**
* Sets the calendar's time zone to be the one passed in. The Calendar takes ownership
@ -648,7 +649,7 @@ public:
* @param value The given first day of the week.
* @stable ICU 2.0
*/
void setFirstDayOfWeek(EDaysOfWeek value);
void setFirstDayOfWeek(UCalendarDaysOfWeek value);
/**
* Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
@ -656,7 +657,7 @@ public:
* @return The first day of the week.
* @stable ICU 2.0
*/
EDaysOfWeek getFirstDayOfWeek(void) const;
UCalendarDaysOfWeek getFirstDayOfWeek(void) const;
/**
* Sets what the minimal days required in the first week of the year are; For
@ -688,7 +689,7 @@ public:
* @return The minimum value for the given time field.
* @stable ICU 2.0
*/
virtual int32_t getMinimum(EDateFields field) const = 0;
virtual int32_t getMinimum(UCalendarDateFields field) const = 0;
/**
* Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
@ -698,7 +699,7 @@ public:
* @return The maximum value for the given time field.
* @stable ICU 2.0
*/
virtual int32_t getMaximum(EDateFields field) const = 0;
virtual int32_t getMaximum(UCalendarDateFields field) const = 0;
/**
* Gets the highest minimum value for the given field if varies. Otherwise same as
@ -708,7 +709,7 @@ public:
* @return The highest minimum value for the given time field.
* @stable ICU 2.0
*/
virtual int32_t getGreatestMinimum(EDateFields field) const = 0;
virtual int32_t getGreatestMinimum(UCalendarDateFields field) const = 0;
/**
* Gets the lowest maximum value for the given field if varies. Otherwise same as
@ -718,7 +719,7 @@ public:
* @return The lowest maximum value for the given time field.
* @stable ICU 2.0
*/
virtual int32_t getLeastMaximum(EDateFields field) const = 0;
virtual int32_t getLeastMaximum(UCalendarDateFields field) const = 0;
/**
* Return the minimum value that this field could have, given the current date.
@ -734,7 +735,7 @@ public:
* @return the minimum of the given field for the current date of this Calendar
* @stable ICU 2.0
*/
int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
int32_t getActualMinimum(UCalendarDateFields field, UErrorCode& status) const;
/**
* Return the maximum value that this field could have, given the current date.
@ -752,7 +753,7 @@ public:
* @return the maximum of the given field for the current date of this Calendar
* @stable ICU 2.0
*/
int32_t getActualMaximum(EDateFields field, UErrorCode& status) const;
int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
/**
* Gets the value for a given time field. Recalculate the current time field values
@ -767,7 +768,7 @@ public:
* and set() has been called for any other field.
* @stable ICU 2.0
*/
int32_t get(EDateFields field, UErrorCode& status) const;
int32_t get(UCalendarDateFields field, UErrorCode& status) const;
/**
* Determines if the given time field has a value set. This can affect in the
@ -777,7 +778,7 @@ public:
* @return True if the given time field has a value set; false otherwise.
* @stable ICU 2.0
*/
UBool isSet(EDateFields field) const;
UBool isSet(UCalendarDateFields field) const;
/**
* Sets the given time field with the given value.
@ -786,7 +787,7 @@ public:
* @param value The value to be set for the given time field.
* @stable ICU 2.0
*/
void set(EDateFields field, int32_t value);
void set(UCalendarDateFields field, int32_t value);
/**
* Sets the values for the fields YEAR, MONTH, and DATE. Other field values are
@ -845,7 +846,7 @@ public:
* @param field The time field to be cleared.
* @stable ICU 2.0
*/
void clear(EDateFields field);
void clear(UCalendarDateFields field);
/**
* Returns a unique class ID POLYMORPHICALLY. Pure virtual method. This method is to
@ -978,7 +979,7 @@ protected:
* @return The value for the given time field.
* @stable ICU 2.0
*/
int32_t internalGet(EDateFields field) const {return fFields[field];}
int32_t internalGet(UCalendarDateFields field) const {return fFields[field];}
/**
* Sets the value for a given time field. This is a fast internal method for
@ -989,7 +990,7 @@ protected:
* @param value The value for the given time field.
* @stable ICU 2.0
*/
void internalSet(EDateFields field, int32_t value);
void internalSet(UCalendarDateFields field, int32_t value);
protected:
/**
@ -1038,13 +1039,13 @@ protected:
* The time fields containing values into which the millis is computed.
* @stable ICU 2.0
*/
int32_t fFields[FIELD_COUNT];
int32_t fFields[UCAL_FIELD_COUNT];
/**
* The flags which tell if a specified time field for the calendar is set.
* @stable ICU 2.0
*/
UBool fIsSet[FIELD_COUNT];
UBool fIsSet[UCAL_FIELD_COUNT];
/** Special values of stamp[]
* @stable ICU 2.0
@ -1061,7 +1062,7 @@ protected:
* MINIMUM_USER_SET to Integer.MAX_VALUE are legal user set values.
* @stable ICU 2.0
*/
int32_t fStamp[FIELD_COUNT];
int32_t fStamp[UCAL_FIELD_COUNT];
private:
@ -1092,7 +1093,7 @@ private:
* out the week count for a specific date for a given locale. These must be set when
* a Calendar is constructed.
*/
EDaysOfWeek fFirstDayOfWeek;
UCalendarDaysOfWeek fFirstDayOfWeek;
uint8_t fMinimalDaysInFirstWeek;
/**
@ -1135,7 +1136,7 @@ Calendar::createInstance(TimeZone* zone, UErrorCode& errorCode)
// -------------------------------------
inline void
Calendar::roll(EDateFields field, UBool up, UErrorCode& status)
Calendar::roll(UCalendarDateFields field, UBool up, UErrorCode& status)
{
roll(field, (int32_t)(up ? +1 : -1), status);
}
@ -1147,7 +1148,7 @@ Calendar::roll(EDateFields field, UBool up, UErrorCode& status)
* fUserSetZoneOffset, as well as the isSet[] array.
*/
inline void
Calendar::internalSet(EDateFields field, int32_t value)
Calendar::internalSet(UCalendarDateFields field, int32_t value)
{
fFields[field] = value;
}

View file

@ -207,7 +207,7 @@ public:
* GREATER is returned if source string is compared to be greater than
* target string in the compare() method.
* @see Collator#compare
* @stable ICU 2.0
* @deprecated ICU 2.6. Use C enum UCollationResult defined in ucol.h
*/
enum EComparisonResult
{
@ -328,7 +328,7 @@ public:
* than target
* @stable ICU 2.0
**/
virtual EComparisonResult compare(const UnicodeString& source,
virtual UCollationResult compare(const UnicodeString& source,
const UnicodeString& target) const = 0;
/**
@ -343,7 +343,7 @@ public:
* length) is less than target.
* @stable ICU 2.0
*/
virtual EComparisonResult compare(const UnicodeString& source,
virtual UCollationResult compare(const UnicodeString& source,
const UnicodeString& target,
int32_t length) const = 0;
@ -362,7 +362,7 @@ public:
* target
* @stable ICU 2.0
*/
virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
const UChar* target, int32_t targetLength)
const = 0;

View file

@ -350,7 +350,7 @@ public:
* an error status.
* @stable ICU 2.0
*/
virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);
/**
* (Overrides Calendar) Rolls up or down by the given amount in the specified field.
@ -363,7 +363,7 @@ public:
* an error status.
* @stable ICU 2.0
*/
virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
/**
* (Overrides Calendar) Returns minimum value for the given field. e.g. for
@ -372,7 +372,7 @@ public:
* @return minimum value for the given field
* @stable ICU 2.0
*/
virtual int32_t getMinimum(EDateFields field) const;
virtual int32_t getMinimum(UCalendarDateFields field) const;
/**
* (Overrides Calendar) Returns maximum value for the given field. e.g. for
@ -381,7 +381,7 @@ public:
* @return maximum value for the given field
* @stable ICU 2.0
*/
virtual int32_t getMaximum(EDateFields field) const;
virtual int32_t getMaximum(UCalendarDateFields field) const;
/**
* (Overrides Calendar) Returns highest minimum value for the given field if varies.
@ -391,7 +391,7 @@ public:
* Otherwise same as getMinimum().
* @stable ICU 2.0
*/
virtual int32_t getGreatestMinimum(EDateFields field) const;
virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;
/**
* (Overrides Calendar) Returns lowest maximum value for the given field if varies.
@ -401,7 +401,7 @@ public:
* Otherwise same as getMaximum().
* @stable ICU 2.0
*/
virtual int32_t getLeastMaximum(EDateFields field) const;
virtual int32_t getLeastMaximum(UCalendarDateFields field) const;
/**
* Return the minimum value that this field could have, given the current date.
@ -410,7 +410,7 @@ public:
* @return the minimum value that this field could have, given the current date.
* @stable ICU 2.0
*/
int32_t getActualMinimum(EDateFields field) const;
int32_t getActualMinimum(UCalendarDateFields field) const;
/**
* Return the maximum value that this field could have, given the current date.
@ -421,7 +421,7 @@ public:
* @return the maximum value that this field could have, given the current date.
* @stable ICU 2.0
*/
int32_t getActualMaximum(EDateFields field) const;
int32_t getActualMaximum(UCalendarDateFields field) const;
/**
* (Overrides Calendar) Return true if the current date for this Calendar is in
@ -618,7 +618,7 @@ private:
/**
* Validates the value of the given time field. True if it's valid.
*/
UBool boundsCheck(int32_t value, EDateFields field) const;
UBool boundsCheck(int32_t value, UCalendarDateFields field) const;
/**
* Return the pseudo-time-stamp for two fields, given their
@ -756,7 +756,7 @@ inline uint8_t GregorianCalendar::julianDayToDayOfWeek(double julian)
// accordingly. We add 1 because Julian day 0 is Monday.
int8_t dayOfWeek = (int8_t) uprv_fmod(julian + 1, 7);
uint8_t result = (uint8_t)(dayOfWeek + ((dayOfWeek < 0) ? (7 + SUNDAY) : SUNDAY));
uint8_t result = (uint8_t)(dayOfWeek + ((dayOfWeek < 0) ? (7 + UCAL_SUNDAY) : UCAL_SUNDAY));
return result;
}

View file

@ -676,7 +676,7 @@ private:
* @return the new start position if matching succeeded; a negative number
* indicating matching failure, otherwise.
*/
int32_t matchString(const UnicodeString& text, int32_t start, Calendar::EDateFields field,
int32_t matchString(const UnicodeString& text, int32_t start, UCalendarDateFields field,
const UnicodeString* stringArray, int32_t stringArrayCount, Calendar& cal) const;
/**
@ -771,7 +771,7 @@ private:
/**
* Used to map pattern characters to Calendar field identifiers.
*/
static const Calendar::EDateFields fgPatternIndexToCalendarField[];
static const UCalendarDateFields fgPatternIndexToCalendarField[];
/**
* Map index into pattern character string to DateFormat field number

View file

@ -183,7 +183,7 @@ public:
* otherwise.
* @stable ICU 2.0
*/
Collator::EComparisonResult compareTo(const CollationKey& target) const;
UCollationResult compareTo(const CollationKey& target) const;
/**
* Creates an integer that is unique to the collation key. NOTE: this

View file

@ -248,7 +248,7 @@ public:
* target. Otherwise, returns EQUAL.
* @stable ICU 2.0
*/
virtual EComparisonResult compare(const UnicodeString& source,
virtual UCollationResult compare(const UnicodeString& source,
const UnicodeString& target) const;
@ -265,7 +265,7 @@ public:
* target. Otherwise, returns EQUAL.
* @stable ICU 2.0
*/
virtual EComparisonResult compare(const UnicodeString& source,
virtual UCollationResult compare(const UnicodeString& source,
const UnicodeString& target,
int32_t length) const;
@ -302,7 +302,7 @@ public:
* target
* @stable ICU 2.2
*/
virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,
virtual UCollationResult compare(const UChar* source, int32_t sourceLength,
const UChar* target, int32_t targetLength)
const;
@ -755,6 +755,7 @@ private:
* Converts C's UCollationResult to EComparisonResult
* @param result member of the enum UComparisonResult
* @return EComparisonResult equivalent of UCollationResult
* @deprecated ICU 2.6. We will not need it.
*/
Collator::EComparisonResult getEComparisonResult(
const UCollationResult &result) const;

View file

@ -49,46 +49,46 @@ CollationDummyTest::~CollationDummyTest()
delete myCollation;
}
const Collator::EComparisonResult CollationDummyTest::results[] = {
Collator::LESS,
Collator::LESS, /*Collator::GREATER,*/
Collator::LESS,
Collator::LESS,
Collator::LESS,
Collator::LESS,
Collator::LESS,
Collator::GREATER,
Collator::GREATER,
Collator::LESS, /* 10 */
Collator::GREATER,
Collator::LESS,
Collator::GREATER,
Collator::GREATER,
Collator::LESS,
Collator::LESS,
Collator::LESS,
const UCollationResult CollationDummyTest::results[] = {
UCOL_LESS,
UCOL_LESS, /*Collator::GREATER,*/
UCOL_LESS,
UCOL_LESS,
UCOL_LESS,
UCOL_LESS,
UCOL_LESS,
UCOL_GREATER,
UCOL_GREATER,
UCOL_LESS, /* 10 */
UCOL_GREATER,
UCOL_LESS,
UCOL_GREATER,
UCOL_GREATER,
UCOL_LESS,
UCOL_LESS,
UCOL_LESS,
/* test primary > 17 */
Collator::EQUAL,
Collator::EQUAL,
Collator::EQUAL, /* 20 */
Collator::LESS,
Collator::LESS,
Collator::EQUAL,
Collator::EQUAL,
Collator::EQUAL,
Collator::LESS,
UCOL_EQUAL,
UCOL_EQUAL,
UCOL_EQUAL, /* 20 */
UCOL_LESS,
UCOL_LESS,
UCOL_EQUAL,
UCOL_EQUAL,
UCOL_EQUAL,
UCOL_LESS,
/* test secondary > 26 */
Collator::EQUAL,
Collator::EQUAL,
Collator::EQUAL,
Collator::EQUAL,
Collator::EQUAL, /* 30 */
Collator::EQUAL,
Collator::LESS,
Collator::EQUAL, /* 34 */
Collator::EQUAL,
Collator::EQUAL,
Collator::LESS
UCOL_EQUAL,
UCOL_EQUAL,
UCOL_EQUAL,
UCOL_EQUAL,
UCOL_EQUAL, /* 30 */
UCOL_EQUAL,
UCOL_LESS,
UCOL_EQUAL, /* 34 */
UCOL_EQUAL,
UCOL_EQUAL,
UCOL_LESS
};
@ -138,7 +138,7 @@ void CollationDummyTest::TestExtra(/* char* par */)
{
for (j = i + 1; j < COUNT_TEST_CASES; j += 1)
{
doTest(myCollation, testCases[i], testCases[j], Collator::LESS);
doTest(myCollation, testCases[i], testCases[j], UCOL_LESS);
}
}
}
@ -166,7 +166,7 @@ void CollationDummyTest::TestJB581(void)
return;
}
Collator::EComparisonResult result = coll->compare(source, target);
UCollationResult result = coll->compare(source, target);
/* result is 1, secondary differences only for ignorable space characters*/
if (result != 1)
{

View file

@ -47,7 +47,7 @@ public:
void TestJB581();
private:
static const Collator::EComparisonResult results[];
static const UCollationResult results[];
RuleBasedCollator *myCollation;
};

View file

@ -119,21 +119,21 @@ CollationAPITest::TestProperty(/* char* par */)
}
}
doAssert((col->compare("ab", "abc") == Collator::LESS), "ab < abc comparison failed");
doAssert((col->compare("ab", "AB") == Collator::LESS), "ab < AB comparison failed");
doAssert((col->compare("blackbird", "black-bird") == Collator::GREATER), "black-bird > blackbird comparison failed");
doAssert((col->compare("black bird", "black-bird") == Collator::LESS), "black bird > black-bird comparison failed");
doAssert((col->compare("Hello", "hello") == Collator::GREATER), "Hello > hello comparison failed");
doAssert((col->compare("ab", "abc") == UCOL_LESS), "ab < abc comparison failed");
doAssert((col->compare("ab", "AB") == UCOL_LESS), "ab < AB comparison failed");
doAssert((col->compare("blackbird", "black-bird") == UCOL_GREATER), "black-bird > blackbird comparison failed");
doAssert((col->compare("black bird", "black-bird") == UCOL_LESS), "black bird > black-bird comparison failed");
doAssert((col->compare("Hello", "hello") == UCOL_GREATER), "Hello > hello comparison failed");
/*start of update [Bertrand A. D. 02/10/98]*/
doAssert((col->compare("ab", "abc", 2) == Collator::EQUAL), "ab = abc with length 2 comparison failed");
doAssert((col->compare("ab", "AB", 2) == Collator::LESS), "ab < AB with length 2 comparison failed");
doAssert((col->compare("ab", "Aa", 1) == Collator::LESS), "ab < Aa with length 1 comparison failed");
doAssert((col->compare("ab", "Aa", 2) == Collator::GREATER), "ab > Aa with length 2 comparison failed");
doAssert((col->compare("black-bird", "blackbird", 5) == Collator::EQUAL), "black-bird = blackbird with length of 5 comparison failed");
doAssert((col->compare("black bird", "black-bird", 10) == Collator::LESS), "black bird < black-bird with length 10 comparison failed");
doAssert((col->compare("Hello", "hello", 5) == Collator::GREATER), "Hello > hello with length 5 comparison failed");
doAssert((col->compare("ab", "abc", 2) == UCOL_EQUAL), "ab = abc with length 2 comparison failed");
doAssert((col->compare("ab", "AB", 2) == UCOL_LESS), "ab < AB with length 2 comparison failed");
doAssert((col->compare("ab", "Aa", 1) == UCOL_LESS), "ab < Aa with length 1 comparison failed");
doAssert((col->compare("ab", "Aa", 2) == UCOL_GREATER), "ab > Aa with length 2 comparison failed");
doAssert((col->compare("black-bird", "blackbird", 5) == UCOL_EQUAL), "black-bird = blackbird with length of 5 comparison failed");
doAssert((col->compare("black bird", "black-bird", 10) == UCOL_LESS), "black bird < black-bird with length 10 comparison failed");
doAssert((col->compare("Hello", "hello", 5) == UCOL_GREATER), "Hello > hello with length 5 comparison failed");
/*end of update [Bertrand A. D. 02/10/98]*/
@ -552,7 +552,7 @@ CollationAPITest::TestCollationKey(/* char* par */)
col->getCollationKey(test1, sortk1, key1Status);
doAssert((sortk1.compareTo(col->getCollationKey(test2, sortk2, key2Status)))
== Collator::GREATER,
== UCOL_GREATER,
"Result should be \"Abcda\" >>> \"abcda\"");
CollationKey sortk3(sortk2), sortkNew, sortkEmpty;
@ -565,11 +565,11 @@ CollationAPITest::TestCollationKey(/* char* par */)
doAssert((sortk1 == sortkNew), "The sort keys assignment failed");
doAssert((sortk1.hashCode() == sortkNew.hashCode()), "sort key hashCode() failed");
doAssert((sortkNew != sortk3), "The sort keys should be different");
doAssert(sortk1.compareTo(sortk3) == Collator::GREATER, "Result should be \"Abcda\" >>> \"abcda\"");
doAssert(sortk2.compareTo(sortk3) == Collator::EQUAL, "Result should be \"abcda\" == \"abcda\"");
doAssert(sortkEmpty.compareTo(sortk1) == Collator::LESS, "Result should be (empty key) <<< \"Abcda\"");
doAssert(sortk1.compareTo(sortkEmpty) == Collator::GREATER, "Result should be \"Abcda\" >>> (empty key)");
doAssert(sortkEmpty.compareTo(sortkEmpty) == Collator::EQUAL, "Result should be (empty key) == (empty key)");
doAssert(sortk1.compareTo(sortk3) == UCOL_GREATER, "Result should be \"Abcda\" >>> \"abcda\"");
doAssert(sortk2.compareTo(sortk3) == UCOL_EQUAL, "Result should be \"abcda\" == \"abcda\"");
doAssert(sortkEmpty.compareTo(sortk1) == UCOL_LESS, "Result should be (empty key) <<< \"Abcda\"");
doAssert(sortk1.compareTo(sortkEmpty) == UCOL_GREATER, "Result should be \"Abcda\" >>> (empty key)");
doAssert(sortkEmpty.compareTo(sortkEmpty) == UCOL_EQUAL, "Result should be (empty key) == (empty key)");
int32_t cnt1, cnt2, cnt3, cnt4;
uint8_t* byteArray1 = 0;
@ -601,12 +601,12 @@ CollationAPITest::TestCollationKey(/* char* par */)
doAssert(memcmp(byteArray2, sortk2_compat, strlen(sortk2_compat)) == 0,
"Binary format for 'abcda' sortkey different!");
*/
doAssert(sortk1.compareTo(sortk4) == Collator::EQUAL, "CollationKey::toByteArray(sortk1) Failed.");
doAssert(sortk2.compareTo(sortk5) == Collator::EQUAL, "CollationKey::toByteArray(sortk2) Failed.");
doAssert(sortk4.compareTo(sortk5) == Collator::GREATER, "sortk4 >>> sortk5 Failed");
doAssert(sortk1.compareTo(sortk6) == Collator::EQUAL, "CollationKey::getByteArray(sortk1) Failed.");
doAssert(sortk2.compareTo(sortk7) == Collator::EQUAL, "CollationKey::getByteArray(sortk2) Failed.");
doAssert(sortk6.compareTo(sortk7) == Collator::GREATER, "sortk6 >>> sortk7 Failed");
doAssert(sortk1.compareTo(sortk4) == UCOL_EQUAL, "CollationKey::toByteArray(sortk1) Failed.");
doAssert(sortk2.compareTo(sortk5) == UCOL_EQUAL, "CollationKey::toByteArray(sortk2) Failed.");
doAssert(sortk4.compareTo(sortk5) == UCOL_GREATER, "sortk4 >>> sortk5 Failed");
doAssert(sortk1.compareTo(sortk6) == UCOL_EQUAL, "CollationKey::getByteArray(sortk1) Failed.");
doAssert(sortk2.compareTo(sortk7) == UCOL_EQUAL, "CollationKey::getByteArray(sortk2) Failed.");
doAssert(sortk6.compareTo(sortk7) == UCOL_GREATER, "sortk6 >>> sortk7 Failed");
logln("Equality tests : ");
doAssert(sortk1 == sortk4, "sortk1 == sortk4 Failed.");
@ -629,7 +629,7 @@ CollationAPITest::TestCollationKey(/* char* par */)
col->setStrength(Collator::SECONDARY);
doAssert(col->getCollationKey(test1, sortk1, key1Status).compareTo(
col->getCollationKey(test2, sortk2, key2Status))
== Collator::EQUAL,
== UCOL_EQUAL,
"Result should be \"Abcda\" == \"abcda\"");
delete col;
}
@ -1047,11 +1047,11 @@ void CollationAPITest::TestSortKey()
CollationKey key3;
col->getCollationKey(test3, u_strlen(test3), key3, status);
doAssert(key1.compareTo(key2) == Collator::GREATER,
doAssert(key1.compareTo(key2) == UCOL_GREATER,
"Result should be \"Abcda\" > \"abcda\"");
doAssert(key2.compareTo(key1) == Collator::LESS,
doAssert(key2.compareTo(key1) == UCOL_LESS,
"Result should be \"abcda\" < \"Abcda\"");
doAssert(key2.compareTo(key3) == Collator::EQUAL,
doAssert(key2.compareTo(key3) == UCOL_EQUAL,
"Result should be \"abcda\" == \"abcda\"");
int32_t keylength = 0;
@ -1111,9 +1111,9 @@ void CollationAPITest::TestSortKey()
col->getCollationKey(test2, u_strlen(test2), key2, status);
col->getCollationKey(test3, u_strlen(test3), key3, status);
doAssert(key1.compareTo(key2) == Collator::EQUAL,
doAssert(key1.compareTo(key2) == UCOL_EQUAL,
"Result should be \"Abcda\" == \"abcda\"");
doAssert(key2.compareTo(key3) == Collator::EQUAL,
doAssert(key2.compareTo(key3) == UCOL_EQUAL,
"Result should be \"abcda\" == \"abcda\"");
tempkey = key2.getByteArray(keylength);
@ -1745,12 +1745,12 @@ class TestCollator: Collator
{
public:
virtual Collator* clone(void) const;
virtual EComparisonResult compare(const UnicodeString& source,
virtual UCollationResult compare(const UnicodeString& source,
const UnicodeString& target) const;
virtual EComparisonResult compare(const UnicodeString& source,
virtual UCollationResult compare(const UnicodeString& source,
const UnicodeString& target,
int32_t length) const;
virtual EComparisonResult compare(const UChar* source,
virtual UCollationResult compare(const UChar* source,
int32_t sourceLength,
const UChar* target,
int32_t targetLength) const;
@ -1793,29 +1793,29 @@ inline UBool TestCollator::operator!=(const TestCollator& other) const {
}
#define returnEComparisonResult(data) \
if (data < 0) return Collator::LESS;\
if (data > 0) return Collator::GREATER;\
return Collator::EQUAL;
if (data < 0) return UCOL_LESS;\
if (data > 0) return UCOL_GREATER;\
return UCOL_EQUAL;
Collator* TestCollator::clone() const
{
return new TestCollator();
}
Collator::EComparisonResult TestCollator::compare(const UnicodeString& source,
UCollationResult TestCollator::compare(const UnicodeString& source,
const UnicodeString& target) const
{
returnEComparisonResult(source.compare(target));
}
Collator::EComparisonResult TestCollator::compare(const UnicodeString& source,
UCollationResult TestCollator::compare(const UnicodeString& source,
const UnicodeString& target,
int32_t length) const
{
returnEComparisonResult(source.compare(0, length, target));
}
Collator::EComparisonResult TestCollator::compare(const UChar* source,
UCollationResult TestCollator::compare(const UChar* source,
int32_t sourceLength,
const UChar* target,
int32_t targetLength) const

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -95,7 +95,7 @@ public: // package
virtual void check520(Calendar* c,
int32_t y, int32_t m, int32_t d,
int32_t hr, int32_t min, int32_t sec,
int32_t ms, Calendar::EDateFields field);
int32_t ms, UCalendarDateFields field);
virtual void check520(Calendar* c,
int32_t y, int32_t m, int32_t d);
@ -165,7 +165,7 @@ public:
SimpleDateFormat *sdf, int32_t times, UErrorCode& status);
// test subroutine used by TestDOW_LOCALandYEAR_WOY
virtual void loop_addroll(Calendar *cal, /*SimpleDateFormat *sdf, */
int times, Calendar::EDateFields field, Calendar::EDateFields field2,
int times, UCalendarDateFields field, UCalendarDateFields field2,
UErrorCode& errorCode);
void yearAddTest(Calendar& cal, UErrorCode& status);

View file

@ -199,12 +199,12 @@ CalendarTimeZoneTest::dateToFields(UDate date, int32_t& y, int32_t& m, int32_t&
if (cal == 0) return;
UErrorCode status = U_ZERO_ERROR;
cal->setTime(date, status);
y = cal->get(Calendar::YEAR, status) - 1900;
m = cal->get(Calendar::MONTH, status);
d = cal->get(Calendar::DATE, status);
hr = cal->get(Calendar::HOUR_OF_DAY, status);
min = cal->get(Calendar::MINUTE, status);
sec = cal->get(Calendar::SECOND, status);
y = cal->get(UCAL_YEAR, status) - 1900;
m = cal->get(UCAL_MONTH, status);
d = cal->get(UCAL_DATE, status);
hr = cal->get(UCAL_HOUR_OF_DAY, status);
min = cal->get(UCAL_MINUTE, status);
sec = cal->get(UCAL_SECOND, status);
releaseCalendar(cal);
}

View file

@ -80,7 +80,7 @@ void CollationCurrencyTest::currencyTest(/*char *par*/)
uint32_t i, j;
UErrorCode status = U_ZERO_ERROR;
Collator::EComparisonResult expectedResult = Collator::EQUAL;
UCollationResult expectedResult = UCOL_EQUAL;
RuleBasedCollator *c = (RuleBasedCollator *)Collator::createInstance("en_US", status);
if (U_FAILURE(status))
@ -100,18 +100,18 @@ void CollationCurrencyTest::currencyTest(/*char *par*/)
if (i < j)
{
expectedResult = Collator::LESS;
expectedResult = UCOL_LESS;
}
else if ( i == j)
{
expectedResult = Collator::EQUAL;
expectedResult = UCOL_EQUAL;
}
else
{
expectedResult = Collator::GREATER;
expectedResult = UCOL_GREATER;
}
Collator::EComparisonResult compareResult = c->compare(source, target);
UCollationResult compareResult = c->compare(source, target);
CollationKey sourceKey, targetKey;
UErrorCode status = U_ZERO_ERROR;
@ -132,7 +132,7 @@ void CollationCurrencyTest::currencyTest(/*char *par*/)
continue;
}
Collator::EComparisonResult keyResult = sourceKey.compareTo(targetKey);
UCollationResult keyResult = sourceKey.compareTo(targetKey);
reportCResult( source, target, sourceKey, targetKey, compareResult, keyResult, compareResult, expectedResult );

View file

@ -59,16 +59,16 @@ const UChar CollationDanishTest::testTargetCases[][CollationDanishTest::MAX_TOKE
{(UChar)0x004C /* 'L' */, (UChar)0x0079 /* 'y' */, (UChar)0x0062 /* 'b' */, (UChar)0x0065 /* 'e' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0000 /* '\0' */}
};
const Collator::EComparisonResult CollationDanishTest::results[] = {
Collator::LESS,
Collator::LESS,
Collator::GREATER,
Collator::LESS,
Collator::LESS,
const UCollationResult CollationDanishTest::results[] = {
UCOL_LESS,
UCOL_LESS,
UCOL_GREATER,
UCOL_LESS,
UCOL_LESS,
/* test primary > 5*/
Collator::EQUAL,
Collator::LESS,
Collator::EQUAL
UCOL_EQUAL,
UCOL_LESS,
UCOL_EQUAL
};
const UChar CollationDanishTest::testBugs[][CollationDanishTest::MAX_TOKEN_LEN] = {
@ -202,13 +202,13 @@ void CollationDanishTest::TestTertiary(/* char* par */)
logln("Test internet data list : ");
for (i = 0; i < 53; i++) {
for (j = i+1; j < 54; j++) {
doTest(myCollation, testBugs[i], testBugs[j], Collator::LESS);
doTest(myCollation, testBugs[i], testBugs[j], UCOL_LESS);
}
}
logln("Test NT data list : ");
for (i = 0; i < 52; i++) {
for (j = i+1; j < 53; j++) {
doTest(myCollation, testNTList[i], testNTList[j], Collator::LESS);
doTest(myCollation, testNTList[i], testNTList[j], UCOL_LESS);
}
}
}

View file

@ -41,7 +41,7 @@ private:
static const UChar testNTList[][MAX_TOKEN_LEN];
static const UChar testSourceCases[][MAX_TOKEN_LEN];
static const UChar testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
static const UCollationResult results[];
Collator *myCollation;
};

View file

@ -106,15 +106,15 @@ DataDrivenCollatorTest::getNextInSequence(SeqElement &el) {
case CharacterIterator::DONE:
break;
case 0x003C /* < */:
el.relation = Collator::LESS;
el.relation = UCOL_LESS;
currChar = CharacterIterator::DONE;
break;
case 0x003D /* = */:
el.relation = Collator::EQUAL;
el.relation = UCOL_EQUAL;
currChar = CharacterIterator::DONE;
break;
case 0x003E /* > */:
el.relation = Collator::GREATER;
el.relation = UCOL_GREATER;
currChar = CharacterIterator::DONE;
break;
case 0x0027 /* ' */: /* very basic quoting */
@ -237,7 +237,7 @@ DataDrivenCollatorTest::processTest(TestData *testData) {
void
DataDrivenCollatorTest::processSequence(Collator* col, const UnicodeString &sequence) {
Collator::EComparisonResult relation = Collator::EQUAL;
UCollationResult relation = UCOL_EQUAL;
UBool hasNext;
SeqElement *source = NULL;
SeqElement *target = NULL;
@ -251,12 +251,12 @@ DataDrivenCollatorTest::processSequence(Collator* col, const UnicodeString &sequ
sequences.addElement(target, status);
do {
relation = Collator::EQUAL;
relation = UCOL_EQUAL;
target = new SeqElement();
hasNext = getNextInSequence(*target);
for(j = sequences.size(); j > 0; j--) {
source = (SeqElement *)sequences.elementAt(j-1);
if(relation == Collator::EQUAL && source->relation != Collator::EQUAL) {
if(relation == UCOL_EQUAL && source->relation != UCOL_EQUAL) {
relation = source->relation;
}
doTest(col, source->source, target->source, relation);

View file

@ -29,7 +29,7 @@
class SeqElement {
public:
UnicodeString source;
Collator::EComparisonResult relation;
UCollationResult relation;
};
class DataDrivenCollatorTest: public IntlTestCollator {

View file

@ -82,21 +82,21 @@ const UChar CollationGermanTest::testTargetCases[][CollationGermanTest::MAX_TOKE
{0x53, 0x74, 0x72, 0x61, 0x73, 0x73, 0x65, 0}
};
const Collator::EComparisonResult CollationGermanTest::results[][2] =
const UCollationResult CollationGermanTest::results[][2] =
{
// Primary Tertiary
{ Collator::LESS, Collator::LESS },
{ Collator::EQUAL, Collator::LESS },
{ Collator::GREATER, Collator::GREATER },
{ Collator::GREATER, Collator::GREATER },
{ Collator::GREATER, Collator::GREATER },
{ Collator::EQUAL, Collator::LESS },
{ Collator::EQUAL, Collator::EQUAL },
{ Collator::LESS, Collator::LESS },
{ Collator::EQUAL, Collator::GREATER },
{ Collator::EQUAL, Collator::EQUAL },
{ Collator::LESS, Collator::LESS },
{ Collator::EQUAL, Collator::GREATER }
{ UCOL_LESS, UCOL_LESS },
{ UCOL_EQUAL, UCOL_LESS },
{ UCOL_GREATER, UCOL_GREATER },
{ UCOL_GREATER, UCOL_GREATER },
{ UCOL_GREATER, UCOL_GREATER },
{ UCOL_EQUAL, UCOL_LESS },
{ UCOL_EQUAL, UCOL_EQUAL },
{ UCOL_LESS, UCOL_LESS },
{ UCOL_EQUAL, UCOL_GREATER },
{ UCOL_EQUAL, UCOL_EQUAL },
{ UCOL_LESS, UCOL_LESS },
{ UCOL_EQUAL, UCOL_GREATER }
};

View file

@ -40,7 +40,7 @@ public:
private:
static const UChar testSourceCases[][MAX_TOKEN_LEN];
static const UChar testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[][2];
static const UCollationResult results[][2];
Collator *myCollation;
};

View file

@ -113,7 +113,7 @@ void DateFormatRegressionTest::Test4052408(void)
DateFormat *fmt = DateFormat::createDateTimeInstance(DateFormat::SHORT,
DateFormat::SHORT, Locale::getUS());
UDate dt = date(97, Calendar::MAY, 3, 8, 55);
UDate dt = date(97, UCAL_MAY, 3, 8, 55);
UnicodeString str;
str = fmt->format(dt, str);
logln(str);
@ -211,16 +211,16 @@ void DateFormatRegressionTest::Test4056591(void)
//try {
SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("yyMMdd"), Locale::getUS(), status);
failure(status, "new SimpleDateFormat");
UDate start = date(1809-1900, Calendar::DECEMBER, 25);
UDate start = date(1809-1900, UCAL_DECEMBER, 25);
fmt->set2DigitYearStart(start, status);
failure(status, "fmt->setTwoDigitStartDate");
if( (fmt->get2DigitYearStart(status) != start) || failure(status, "get2DigitStartDate"))
errln("get2DigitYearStart broken");
UDate dates [] = {
date(1809-1900, Calendar::DECEMBER, 25),
date(1909-1900, Calendar::DECEMBER, 24),
date(1809-1900, Calendar::DECEMBER, 26),
date(1861-1900, Calendar::DECEMBER, 25),
date(1809-1900, UCAL_DECEMBER, 25),
date(1909-1900, UCAL_DECEMBER, 24),
date(1809-1900, UCAL_DECEMBER, 26),
date(1861-1900, UCAL_DECEMBER, 25),
};
UnicodeString strings [] = {
@ -335,8 +335,8 @@ void DateFormatRegressionTest::Test4060212(void)
failure(status, "new GregorianCalendar");
cal->setTime(myDate, status);
failure(status, "cal->setTime");
if ((cal->get(Calendar::DAY_OF_YEAR, status) != 40) || failure(status, "cal->get"))
errln((UnicodeString) "Fail: Got " + cal->get(Calendar::DAY_OF_YEAR, status) +
if ((cal->get(UCAL_DAY_OF_YEAR, status) != 40) || failure(status, "cal->get"))
errln((UnicodeString) "Fail: Got " + cal->get(UCAL_DAY_OF_YEAR, status) +
" Want 40");
logln("Using yyyy-ddd.hh:mm:ss");
@ -350,8 +350,8 @@ void DateFormatRegressionTest::Test4060212(void)
logln( myString );
cal->setTime(myDate, status);
failure(status, "cal->setTime");
if ((cal->get(Calendar::DAY_OF_YEAR, status) != 40) || failure(status, "cal->get"))
errln((UnicodeString) "Fail: Got " + cal->get(Calendar::DAY_OF_YEAR, status) +
if ((cal->get(UCAL_DAY_OF_YEAR, status) != 40) || failure(status, "cal->get"))
errln((UnicodeString) "Fail: Got " + cal->get(UCAL_DAY_OF_YEAR, status) +
" Want 40");
delete formatter;
@ -477,7 +477,7 @@ void DateFormatRegressionTest::Test4071441(void)
Calendar *calA = (Calendar*) fmtA->getCalendar();
Calendar *calB = (Calendar*) fmtB->getCalendar();
UDate epoch = date(0, 0, 0);
UDate xmas = date(61, Calendar::DECEMBER, 25);
UDate xmas = date(61, UCAL_DECEMBER, 25);
UErrorCode status = U_ZERO_ERROR;
calA->setTime(epoch, status);
@ -752,7 +752,7 @@ void DateFormatRegressionTest::Test4104136(void)
};
UDate dates [] = {
date(70, Calendar::JANUARY, 1, 10, 30),
date(70, UCAL_JANUARY, 1, 10, 30),
-1,
-1
};
@ -874,7 +874,7 @@ void DateFormatRegressionTest::Test4106807(void)
//logln(df->format(dt));
gc->setTime(dt, status);
failure(status, "gc->getTime");
logln(UnicodeString("") + gc->get(Calendar::ZONE_OFFSET, status));
logln(UnicodeString("") + gc->get(UCAL_ZONE_OFFSET, status));
failure(status, "gc->get");
UnicodeString s;
s = format->format(dt, s, pos);
@ -951,7 +951,7 @@ void DateFormatRegressionTest::Test4151631(void)
failure(status, "new SimpleDateFormat");
UnicodeString result;
FieldPosition pos(FieldPosition::DONT_CARE);
result = format->format(date(1998-1900, Calendar::JUNE, 30, 13, 30, 0), result, pos);
result = format->format(date(1998-1900, UCAL_JUNE, 30, 13, 30, 0), result, pos);
if (result != "TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')") {
errln("Fail: result=" + result);
}
@ -1046,14 +1046,14 @@ void DateFormatRegressionTest::Test4182066(void) {
int32_t STRINGS_COUNT = (int32_t)(sizeof(STRINGS) / sizeof(STRINGS[0]));
UDate FAIL_DATE = (UDate) 0;
UDate DATES[] = {
date(2000-1900, Calendar::FEBRUARY, 29),
date(2001-1900, Calendar::JANUARY, 23),
date( -1-1900, Calendar::APRIL, 5),
date( -9-1900, Calendar::JANUARY, 23),
date(1314-1900, Calendar::NOVEMBER, 12),
date( 1-1900, Calendar::OCTOBER, 31),
date(2000-1900, UCAL_FEBRUARY, 29),
date(2001-1900, UCAL_JANUARY, 23),
date( -1-1900, UCAL_APRIL, 5),
date( -9-1900, UCAL_JANUARY, 23),
date(1314-1900, UCAL_NOVEMBER, 12),
date( 1-1900, UCAL_OCTOBER, 31),
FAIL_DATE, // "+1" isn't recognized by US NumberFormat
date( 1-1900, Calendar::SEPTEMBER,12),
date( 1-1900, UCAL_SEPTEMBER,12),
};
UnicodeString out;
@ -1114,7 +1114,7 @@ DateFormatRegressionTest::Test4210209(void) {
}
Calendar* calx = (Calendar*)fmt.getCalendar(); // cast away const!
calx->setLenient(FALSE);
UDate d = date(2000-1900, Calendar::FEBRUARY, 29);
UDate d = date(2000-1900, UCAL_FEBRUARY, 29);
UnicodeString s, ss;
fmt.format(d, s);
logln(disp.format(d, ss.remove()) + " f> " + pattern +
@ -1139,7 +1139,7 @@ DateFormatRegressionTest::Test4210209(void) {
}
cal.clear();
cal.setLenient(FALSE);
cal.set(2000, Calendar::FEBRUARY, 29); // This should work!
cal.set(2000, UCAL_FEBRUARY, 29); // This should work!
logln(UnicodeString("Attempt to set Calendar to Feb 29 2000: ") +
disp.format(cal.getTime(status), ss.remove()));
if (U_FAILURE(status)) {

View file

@ -267,7 +267,7 @@ void DateFormatRoundTripTest::test(DateFormat *fmt, const Locale &origLocale, UB
// String usually matches in 1. Exceptions are checked for here.
if(smatch > maxSmatch) { // Don't compute unless necessary
// Starts in BC, with no era in pattern
if( ! hasEra && getField(d[0], Calendar::ERA) == GregorianCalendar::BC)
if( ! hasEra && getField(d[0], UCAL_ERA) == GregorianCalendar::BC)
maxSmatch = 2;
// Starts in DST, no year in pattern
else if(fmt->getTimeZone().inDaylightTime(d[0], status) && ! failure(status, "foo") &&
@ -277,14 +277,14 @@ void DateFormatRoundTripTest::test(DateFormat *fmt, const Locale &origLocale, UB
// unless timezone isn't used or we aren't close to the DST changover
else if (pat.indexOf(UnicodeString("y")) != -1
&& pat.indexOf(UnicodeString("yyyy")) == -1
&& getField(d[0], Calendar::YEAR)
!= getField(d[dmatch], Calendar::YEAR)
&& getField(d[0], UCAL_YEAR)
!= getField(d[dmatch], UCAL_YEAR)
&& !failure(status, "foo")
&& ((hasZone
&& (fmt->getTimeZone().inDaylightTime(d[0], status)
== fmt->getTimeZone().inDaylightTime(d[dmatch], status)
|| getField(d[0], Calendar::MONTH) == Calendar::APRIL
|| getField(d[0], Calendar::MONTH) == Calendar::OCTOBER))
|| getField(d[0], UCAL_MONTH) == UCAL_APRIL
|| getField(d[0], UCAL_MONTH) == UCAL_OCTOBER))
|| !hasZone)
)
{
@ -326,7 +326,7 @@ int32_t DateFormatRoundTripTest::getField(UDate d, int32_t f) {
UErrorCode status = U_ZERO_ERROR;
getFieldCal->setTime(d, status);
failure(status, "getfieldCal->setTime");
int32_t ret = getFieldCal->get((Calendar::EDateFields)f, status);
int32_t ret = getFieldCal->get((UCalendarDateFields)f, status);
failure(status, "getfieldCal->get");
return ret;
}

View file

@ -91,7 +91,7 @@ void DateFormatTest::TestWallyWedel()
// offset = ttz.getRawOffset();
cal->setTimeZone(*ttz);
cal->setTime(today, status);
offset = cal->get(Calendar::ZONE_OFFSET, status) + cal->get(Calendar::DST_OFFSET, status);
offset = cal->get(UCAL_ZONE_OFFSET, status) + cal->get(UCAL_DST_OFFSET, status);
// logln(i + " " + ids[i] + " offset " + offset);
const char* sign = "+";
if (offset < 0) {
@ -297,7 +297,7 @@ DateFormatTest::TestFieldPosition(void)
logln((UnicodeString)" Pattern = " + ((SimpleDateFormat*)df)->toPattern(str));
str.truncate(0);
logln((UnicodeString)" Result = " + df->format(someDate, str));
for (int32_t i = 0; i < Calendar::FIELD_COUNT;++i) {
for (int32_t i = 0; i < UCAL_FIELD_COUNT;++i) {
UnicodeString field;
getFieldText(df, i, someDate, field);
UnicodeString expStr;
@ -477,8 +477,8 @@ DateFormatTest::TestCzechMonths459()
DateFormat* fmt = DateFormat::createDateInstance(DateFormat::FULL, Locale("cs", "", ""));
UnicodeString pattern;
logln((UnicodeString)"Pattern " + ((SimpleDateFormat*) fmt)->toPattern(pattern));
UDate june = date(97, Calendar::JUNE, 15);
UDate july = date(97, Calendar::JULY, 15);
UDate june = date(97, UCAL_JUNE, 15);
UDate july = date(97, UCAL_JULY, 15);
UnicodeString juneStr; fmt->format(june, juneStr);
UnicodeString julyStr; fmt->format(july, julyStr);
//try {
@ -487,13 +487,13 @@ DateFormatTest::TestCzechMonths459()
UnicodeString s; fmt->format(d, s);
int32_t month,yr,day,hr,min,sec; dateToFields(d,yr,month,day,hr,min,sec);
logln((UnicodeString)" -> parse -> " + s + " (month = " + month + ")");
if (month != Calendar::JUNE) errln((UnicodeString)"FAIL: Month should be June");
if (month != UCAL_JUNE) errln((UnicodeString)"FAIL: Month should be June");
logln((UnicodeString)"format(July 15 1997) = " + julyStr);
d = fmt->parse(julyStr, status);
fmt->format(d, s);
dateToFields(d,yr,month,day,hr,min,sec);
logln((UnicodeString)" -> parse -> " + s + " (month = " + month + ")");
if (month != Calendar::JULY) errln((UnicodeString)"FAIL: Month should be July");
if (month != UCAL_JULY) errln((UnicodeString)"FAIL: Month should be July");
//}
//catch(ParseException e) {
if (U_FAILURE(status))
@ -588,7 +588,7 @@ DateFormatTest::TestQuotePattern161()
{
UErrorCode status = U_ZERO_ERROR;
SimpleDateFormat* formatter = new SimpleDateFormat((UnicodeString)"MM/dd/yyyy 'at' hh:mm:ss a zzz", status);
UDate currentTime_1 = date(97, Calendar::AUGUST, 13, 10, 42, 28);
UDate currentTime_1 = date(97, UCAL_AUGUST, 13, 10, 42, 28);
UnicodeString dateString; ((DateFormat*)formatter)->format(currentTime_1, dateString);
UnicodeString exp("08/13/1997 at 10:42:28 AM ");
logln((UnicodeString)"format(" + dateToString(currentTime_1) + ") = " + dateString);
@ -768,8 +768,8 @@ void
DateFormatTest::TestTwoDigitYear()
{
DateFormat* fmt = DateFormat::createDateInstance(DateFormat::SHORT, Locale::getUK());
parse2DigitYear(*fmt, "5/6/17", date(117, Calendar::JUNE, 5));
parse2DigitYear(*fmt, "4/6/34", date(34, Calendar::JUNE, 4));
parse2DigitYear(*fmt, "5/6/17", date(117, UCAL_JUNE, 5));
parse2DigitYear(*fmt, "4/6/34", date(34, UCAL_JUNE, 4));
delete fmt;
}
@ -853,7 +853,7 @@ DateFormatTest::TestDateFormatZone146()
//*****************************greenwichcalendar.setTimeZone(TimeZone.getDefault());
//greenwichcalendar.set(1997, 3, 4, 23, 0);
// try anything to set hour to 23:00 !!!
greenwichcalendar->set(Calendar::HOUR_OF_DAY, 23);
greenwichcalendar->set(UCAL_HOUR_OF_DAY, 23);
// get time
UDate greenwichdate = greenwichcalendar->getTime(status);
// format every way
@ -901,7 +901,7 @@ DateFormatTest::TestDateFormatZone146()
void
DateFormatTest::TestLocaleDateFormat() // Bug 495
{
UDate testDate = date(97, Calendar::SEPTEMBER, 15);
UDate testDate = date(97, UCAL_SEPTEMBER, 15);
DateFormat *dfFrench = DateFormat::createDateTimeInstance(DateFormat::FULL,
DateFormat::FULL, Locale::getFrench());
DateFormat *dfUS = DateFormat::createDateTimeInstance(DateFormat::FULL,

View file

@ -130,60 +130,60 @@ const UChar CollationEnglishTest::testTargetCases[][CollationEnglishTest::MAX_TO
{(UChar)0x0070 /* 'p' */, 0x00EA, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, 0} // 49
};
const Collator::EComparisonResult CollationEnglishTest::results[] = {
Collator::LESS,
Collator::LESS, /*Collator::GREATER,*/
Collator::LESS,
Collator::GREATER,
Collator::GREATER,
Collator::EQUAL,
Collator::LESS,
Collator::LESS,
Collator::LESS,
Collator::LESS, /*Collator::GREATER,*/ /* 10 */
Collator::GREATER,
Collator::LESS,
Collator::EQUAL,
Collator::LESS,
Collator::GREATER,
Collator::GREATER,
Collator::GREATER,
Collator::LESS,
Collator::LESS,
Collator::LESS, /* 20 */
Collator::LESS,
Collator::LESS,
Collator::LESS,
Collator::GREATER,
Collator::GREATER,
Collator::GREATER,
const UCollationResult CollationEnglishTest::results[] = {
UCOL_LESS,
UCOL_LESS, /*Collator::GREATER,*/
UCOL_LESS,
UCOL_GREATER,
UCOL_GREATER,
UCOL_EQUAL,
UCOL_LESS,
UCOL_LESS,
UCOL_LESS,
UCOL_LESS, /*Collator::GREATER,*/ /* 10 */
UCOL_GREATER,
UCOL_LESS,
UCOL_EQUAL,
UCOL_LESS,
UCOL_GREATER,
UCOL_GREATER,
UCOL_GREATER,
UCOL_LESS,
UCOL_LESS,
UCOL_LESS, /* 20 */
UCOL_LESS,
UCOL_LESS,
UCOL_LESS,
UCOL_GREATER,
UCOL_GREATER,
UCOL_GREATER,
/* Test Tertiary > 26 */
Collator::LESS,
Collator::LESS,
Collator::GREATER,
Collator::LESS, /* 30 */
Collator::GREATER,
Collator::EQUAL,
Collator::GREATER,
Collator::LESS,
Collator::LESS,
Collator::LESS,
UCOL_LESS,
UCOL_LESS,
UCOL_GREATER,
UCOL_LESS, /* 30 */
UCOL_GREATER,
UCOL_EQUAL,
UCOL_GREATER,
UCOL_LESS,
UCOL_LESS,
UCOL_LESS,
/* test identical > 36 */
Collator::EQUAL,
Collator::EQUAL,
UCOL_EQUAL,
UCOL_EQUAL,
/* test primary > 38 */
Collator::EQUAL,
Collator::EQUAL, /* 40 */
Collator::LESS,
Collator::EQUAL,
Collator::EQUAL,
UCOL_EQUAL,
UCOL_EQUAL, /* 40 */
UCOL_LESS,
UCOL_EQUAL,
UCOL_EQUAL,
/* test secondary > 43 */
Collator::LESS,
Collator::LESS,
Collator::EQUAL,
Collator::LESS,
Collator::LESS,
Collator::LESS // 49
UCOL_LESS,
UCOL_LESS,
UCOL_EQUAL,
UCOL_LESS,
UCOL_LESS,
UCOL_LESS // 49
};
const UChar CollationEnglishTest::testBugs[][CollationEnglishTest::MAX_TOKEN_LEN] = {
@ -254,23 +254,23 @@ void CollationEnglishTest::TestTertiary(/* char* par */)
{
for (j = i+1; j < 10; j++)
{
doTest(myCollation, testBugs[i], testBugs[j], Collator::LESS);
doTest(myCollation, testBugs[i], testBugs[j], UCOL_LESS);
}
}
//test more interesting cases
Collator::EComparisonResult expected;
UCollationResult expected;
const int32_t testMoreSize = (int32_t)(sizeof(testMore) / sizeof(testMore[0]));
for (i = 0; i < testMoreSize; i++)
{
for (j = 0; j < testMoreSize; j++)
{
if (i < j)
expected = Collator::LESS;
expected = UCOL_LESS;
else if (i == j)
expected = Collator::EQUAL;
expected = UCOL_EQUAL;
else // (i > j)
expected = Collator::GREATER;
expected = UCOL_GREATER;
doTest(myCollation, testMore[i], testMore[j], expected );
}
}
@ -298,18 +298,18 @@ void CollationEnglishTest::TestSecondary(/* char* par */)
//test acute and grave ordering (compare to french collation)
int32_t j;
Collator::EComparisonResult expected;
UCollationResult expected;
const int32_t testAcuteSize = (int32_t)(sizeof(testAcute) / sizeof(testAcute[0]));
for (i = 0; i < testAcuteSize; i++)
{
for (j = 0; j < testAcuteSize; j++)
{
if (i < j)
expected = Collator::LESS;
expected = UCOL_LESS;
else if (i == j)
expected = Collator::EQUAL;
expected = UCOL_EQUAL;
else // (i > j)
expected = Collator::GREATER;
expected = UCOL_GREATER;
doTest(myCollation, testAcute[i], testAcute[j], expected );
}
}

View file

@ -43,7 +43,7 @@ private:
static const UChar testBugs[][MAX_TOKEN_LEN];
static const UChar testSourceCases[][MAX_TOKEN_LEN];
static const UChar testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
static const UCollationResult results[];
static const UChar testAcute[][MAX_TOKEN_LEN];
Collator *myCollation;

View file

@ -67,17 +67,17 @@ const UChar CollationSpanishTest::testTargetCases[][CollationSpanishTest::MAX_TO
{0x68, 0x65, 0x6c, 0x6c, 0x4f, 0},
};
const Collator::EComparisonResult CollationSpanishTest::results[] = {
Collator::LESS,
Collator::LESS,
Collator::GREATER,
Collator::LESS,
Collator::LESS,
const UCollationResult CollationSpanishTest::results[] = {
UCOL_LESS,
UCOL_LESS,
UCOL_GREATER,
UCOL_LESS,
UCOL_LESS,
// test primary > 5
Collator::LESS,
Collator::EQUAL,
Collator::LESS,
Collator::EQUAL
UCOL_LESS,
UCOL_EQUAL,
UCOL_LESS,
UCOL_EQUAL
};
void CollationSpanishTest::TestTertiary(/* char* par */)

View file

@ -39,7 +39,7 @@ public:
private:
static const UChar testSourceCases[][MAX_TOKEN_LEN];
static const UChar testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
static const UCollationResult results[];
Collator *myCollation;
};

View file

@ -58,13 +58,13 @@ const UChar CollationFinnishTest::testTargetCases[][CollationFinnishTest::MAX_TO
{0x76, 0x61, 0x74, 0}
};
const Collator::EComparisonResult CollationFinnishTest::results[] = {
Collator::GREATER,
Collator::LESS,
Collator::GREATER,
Collator::LESS,
const UCollationResult CollationFinnishTest::results[] = {
UCOL_GREATER,
UCOL_LESS,
UCOL_GREATER,
UCOL_LESS,
// test primary > 4
Collator::EQUAL,
UCOL_EQUAL,
};
void CollationFinnishTest::TestTertiary(/* char* par */)

View file

@ -38,7 +38,7 @@ public:
private:
static const UChar testSourceCases[][MAX_TOKEN_LEN];
static const UChar testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
static const UCollationResult results[];
Collator *myCollation;
};

View file

@ -73,20 +73,20 @@ const UChar CollationFrenchTest::testTargetCases[][CollationFrenchTest::MAX_TOKE
{0x01df, 0x0000}
};
const Collator::EComparisonResult CollationFrenchTest::results[] =
const UCollationResult CollationFrenchTest::results[] =
{
Collator::LESS,
Collator::LESS,
Collator::LESS, /*Collator::GREATER,*/
Collator::LESS,
Collator::GREATER,
Collator::GREATER,
Collator::LESS,
Collator::GREATER,
Collator::LESS, /*Collator::GREATER,*/
Collator::GREATER,
Collator::LESS,
Collator::LESS
UCOL_LESS,
UCOL_LESS,
UCOL_LESS, /*Collator::GREATER,*/
UCOL_LESS,
UCOL_GREATER,
UCOL_GREATER,
UCOL_LESS,
UCOL_GREATER,
UCOL_LESS, /*Collator::GREATER,*/
UCOL_GREATER,
UCOL_LESS,
UCOL_LESS
};
// 0x0300 is grave, 0x0301 is acute
@ -158,7 +158,7 @@ void CollationFrenchTest::TestSecondary(/* char* par */)
//test acute and grave ordering
int32_t i = 0;
int32_t j;
Collator::EComparisonResult expected;
UCollationResult expected;
UErrorCode status = U_ZERO_ERROR;
//myCollation->setAttribute(UCOL_FRENCH_COLLATION, UCOL_ON, status);
myCollation->setStrength(Collator::SECONDARY);
@ -172,11 +172,11 @@ void CollationFrenchTest::TestSecondary(/* char* par */)
for (j = 0; j < testAcuteSize; j++)
{
if (i < j)
expected = Collator::LESS;
expected = UCOL_LESS;
else if (i == j)
expected = Collator::EQUAL;
expected = UCOL_EQUAL;
else // (i > j)
expected = Collator::GREATER;
expected = UCOL_GREATER;
doTest(myCollation, testAcute[i], testAcute[j], expected );
}
}
@ -191,7 +191,7 @@ void CollationFrenchTest::TestExtra(/* char* par */)
{
for (j = i + 1; j < 10; j += 1)
{
doTest(myCollation, testBugs[i], testBugs[j], Collator::LESS);
doTest(myCollation, testBugs[i], testBugs[j], UCOL_LESS);
}
}
}

View file

@ -41,7 +41,7 @@ private:
static const UChar testSourceCases[][MAX_TOKEN_LEN];
static const UChar testTargetCases[][MAX_TOKEN_LEN];
static const UChar testBugs[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
static const UCollationResult results[];
static const UChar testAcute[][MAX_TOKEN_LEN];
Collator *myCollation;

View file

@ -140,7 +140,7 @@ void G7CollationTest::TestG7Locales(/* char* par */)
{
for (n = j+1; n < FIXEDTESTSET; n++)
{
doTest(tblColl1, testCases[results[i][j]], testCases[results[i][n]], Collator::LESS);
doTest(tblColl1, testCases[results[i][j]], testCases[results[i][n]], UCOL_LESS);
}
}
@ -170,7 +170,7 @@ void G7CollationTest::TestDemo1(/* char* par */)
{
for (n = j+1; n < FIXEDTESTSET; n++)
{
doTest(myCollation, testCases[results[8][j]], testCases[results[8][n]], Collator::LESS);
doTest(myCollation, testCases[results[8][j]], testCases[results[8][n]], UCOL_LESS);
}
}
@ -199,7 +199,7 @@ void G7CollationTest::TestDemo2(/* char* par */)
{
for (n = j+1; n < TOTALTESTSET; n++)
{
doTest(myCollation, testCases[results[9][j]], testCases[results[9][n]], Collator::LESS);
doTest(myCollation, testCases[results[9][j]], testCases[results[9][n]], UCOL_LESS);
}
}
@ -228,7 +228,7 @@ void G7CollationTest::TestDemo3(/* char* par */)
{
for (n = j+1; n < TOTALTESTSET; n++)
{
doTest(myCollation, testCases[results[10][j]], testCases[results[10][n]], Collator::LESS);
doTest(myCollation, testCases[results[10][j]], testCases[results[10][n]], UCOL_LESS);
}
}
@ -257,7 +257,7 @@ void G7CollationTest::TestDemo4(/* char* par */)
{
for (n = j+1; n < TOTALTESTSET; n++)
{
doTest(myCollation, testCases[results[11][j]], testCases[results[11][n]], Collator::LESS);
doTest(myCollation, testCases[results[11][j]], testCases[results[11][n]], UCOL_LESS);
}
}

View file

@ -53,13 +53,13 @@ const UChar CollationKanaTest::testTargetCases[][CollationKanaTest::MAX_TOKEN_LE
{0x3042, 0x3042, 0x3068, 0x0000} /* 6 */
};
const Collator::EComparisonResult CollationKanaTest::results[] = {
Collator::LESS,
Collator::EQUAL, //Collator::LESS, /* Katakanas and Hiraganas are equal on tertiary level(ICU 2.0)*/
Collator::LESS,
Collator::GREATER, // Collator::LESS, /* Prolonged sound mark sorts BEFORE equivalent vowel (ICU 2.0)*/
Collator::LESS,
Collator::LESS, //Collator::GREATER /* Prolonged sound mark sorts BEFORE equivalent vowel (ICU 2.0)*//* 6 */
const UCollationResult CollationKanaTest::results[] = {
UCOL_LESS,
UCOL_EQUAL, //Collator::LESS, /* Katakanas and Hiraganas are equal on tertiary level(ICU 2.0)*/
UCOL_LESS,
UCOL_GREATER, // Collator::LESS, /* Prolonged sound mark sorts BEFORE equivalent vowel (ICU 2.0)*/
UCOL_LESS,
UCOL_LESS, //Collator::GREATER /* Prolonged sound mark sorts BEFORE equivalent vowel (ICU 2.0)*//* 6 */
};
const UChar CollationKanaTest::testBaseCases[][CollationKanaTest::MAX_TOKEN_LEN] = {
@ -121,7 +121,7 @@ void CollationKanaTest::TestBase()
int32_t i;
myCollation->setStrength(Collator::PRIMARY);
for (i = 0; i < 3 ; i++)
doTest(myCollation, testBaseCases[i], testBaseCases[i + 1], Collator::LESS);
doTest(myCollation, testBaseCases[i], testBaseCases[i + 1], UCOL_LESS);
}
/* Testing plain, Daku-ten, Handaku-ten letters */
@ -131,7 +131,7 @@ void CollationKanaTest::TestPlainDakutenHandakuten(void)
myCollation->setStrength(Collator::SECONDARY);
for (i = 0; i < 3 ; i++)
doTest(myCollation, testPlainDakutenHandakutenCases[i], testPlainDakutenHandakutenCases[i + 1],
Collator::LESS);
UCOL_LESS);
}
/*
@ -144,7 +144,7 @@ void CollationKanaTest::TestSmallLarge(void)
myCollation->setStrength(Collator::TERTIARY);
myCollation->setAttribute(UCOL_CASE_LEVEL, UCOL_ON, status);
for (i = 0; i < 3 ; i++)
doTest(myCollation, testSmallLargeCases[i], testSmallLargeCases[i + 1], Collator::LESS);
doTest(myCollation, testSmallLargeCases[i], testSmallLargeCases[i + 1], UCOL_LESS);
}
/*
@ -158,7 +158,7 @@ void CollationKanaTest::TestKatakanaHiragana(void)
myCollation->setAttribute(UCOL_CASE_LEVEL, UCOL_ON, status);
for (i = 0; i < 3 ; i++) {
doTest(myCollation, testKatakanaHiraganaCases[i], testKatakanaHiraganaCases[i + 1],
Collator::LESS);
UCOL_LESS);
}
}
@ -172,7 +172,7 @@ void CollationKanaTest::TestChooonKigoo(void)
myCollation->setStrength(Collator::QUATERNARY);
myCollation->setAttribute(UCOL_CASE_LEVEL, UCOL_ON, status);
for (i = 0; i < 7 ; i++) {
doTest(myCollation, testChooonKigooCases[i], testChooonKigooCases[i + 1], Collator::LESS);
doTest(myCollation, testChooonKigooCases[i], testChooonKigooCases[i + 1], UCOL_LESS);
}
}

View file

@ -50,7 +50,7 @@ public:
private:
static const UChar testSourceCases[][MAX_TOKEN_LEN];
static const UChar testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
static const UCollationResult results[];
static const UChar testBaseCases[][MAX_TOKEN_LEN];
static const UChar testPlainDakutenHandakutenCases[][MAX_TOKEN_LEN];
static const UChar testSmallLargeCases[][MAX_TOKEN_LEN];

View file

@ -50,8 +50,8 @@ const UChar LotusCollationKoreanTest::testTargetCases[][LotusCollationKoreanTest
{0xac01, 0}
};
const Collator::EComparisonResult LotusCollationKoreanTest::results[] = {
Collator::LESS
const UCollationResult LotusCollationKoreanTest::results[] = {
UCOL_LESS
};
void LotusCollationKoreanTest::TestTertiary(/* char* par */)

View file

@ -30,7 +30,7 @@ public:
private:
static const UChar testSourceCases[][MAX_TOKEN_LEN];
static const UChar testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
static const UCollationResult results[];
Collator *myCollation;
};

View file

@ -1420,7 +1420,7 @@ LocaleTest::Test4143951()
{
UErrorCode status = U_ZERO_ERROR;
Calendar *cal = Calendar::createInstance(Locale("ru", "", ""), status);
if (cal->getFirstDayOfWeek() != Calendar::MONDAY) {
if (cal->getFirstDayOfWeek() != UCAL_MONDAY) {
errln("Fail: First day of week in Russia should be Monday");
}
delete cal;

View file

@ -228,7 +228,7 @@ void CollationMonkeyTest::TestRules(/* char* par */){
return;
}
for(i=0; i<2; i++){
doTest(myCollation, testSourceCases[i], testTargetCases[i], Collator::LESS);
doTest(myCollation, testSourceCases[i], testTargetCases[i], UCOL_LESS);
}
delete myCollation;
@ -243,7 +243,7 @@ void CollationMonkeyTest::TestRules(/* char* par */){
return;
}
for(i=0; i<2; i++){
doTest(myCollation, testSourceCases[i], testTargetCases[i], Collator::LESS);
doTest(myCollation, testSourceCases[i], testTargetCases[i], UCOL_LESS);
}
delete myCollation;
delete col;

View file

@ -545,9 +545,9 @@ void CollationRegressionTest::Test4078588(/* char *par */)
return;
}
Collator::EComparisonResult result = rbc->compare("a","bb");
UCollationResult result = rbc->compare("a","bb");
if (result != Collator::LESS)
if (result != UCOL_LESS)
{
errln((UnicodeString)"Compare(a,bb) returned " + (int)result
+ (UnicodeString)"; expected -1");
@ -1072,7 +1072,7 @@ void CollationRegressionTest::compareArray(Collator &c,
int32_t testCount)
{
int32_t i;
Collator::EComparisonResult expectedResult = Collator::EQUAL;
UCollationResult expectedResult = UCOL_EQUAL;
for (i = 0; i < testCount; i += 3)
{
@ -1082,15 +1082,15 @@ void CollationRegressionTest::compareArray(Collator &c,
if (comparison == "<")
{
expectedResult = Collator::LESS;
expectedResult = UCOL_LESS;
}
else if (comparison == ">")
{
expectedResult = Collator::GREATER;
expectedResult = UCOL_GREATER;
}
else if (comparison == "=")
{
expectedResult = Collator::EQUAL;
expectedResult = UCOL_EQUAL;
}
else
{
@ -1099,7 +1099,7 @@ void CollationRegressionTest::compareArray(Collator &c,
errln(bogus1 + comparison + bogus2);
}
Collator::EComparisonResult compareResult = c.compare(source, target);
UCollationResult compareResult = c.compare(source, target);
CollationKey sourceKey, targetKey;
UErrorCode status = U_ZERO_ERROR;
@ -1120,7 +1120,7 @@ void CollationRegressionTest::compareArray(Collator &c,
continue;
}
Collator::EComparisonResult keyResult = sourceKey.compareTo(targetKey);
UCollationResult keyResult = sourceKey.compareTo(targetKey);
reportCResult( source, target, sourceKey, targetKey, compareResult, keyResult, compareResult, expectedResult );

View file

@ -155,7 +155,7 @@ void CollationThaiTest::TestNamesList(void) {
}
if (lastWord.length() > 0) {
Collator::EComparisonResult result = coll->compare(lastWord, word);
UCollationResult result = coll->compare(lastWord, word);
doTest(coll, lastWord, word, result);
}
lastWord = word;

View file

@ -70,19 +70,19 @@ const UChar CollationTurkishTest::testTargetCases[][CollationTurkishTest::MAX_TO
{0x49, 0x64, 0x65, 0x61, 0}
};
const Collator::EComparisonResult CollationTurkishTest::results[] = {
Collator::LESS,
Collator::LESS,
Collator::LESS,
Collator::LESS,
Collator::GREATER,
Collator::LESS,
Collator::LESS,
Collator::GREATER,
const UCollationResult CollationTurkishTest::results[] = {
UCOL_LESS,
UCOL_LESS,
UCOL_LESS,
UCOL_LESS,
UCOL_GREATER,
UCOL_LESS,
UCOL_LESS,
UCOL_GREATER,
// test priamry > 8
Collator::LESS,
Collator::LESS,
Collator::GREATER
UCOL_LESS,
UCOL_LESS,
UCOL_GREATER
};
void CollationTurkishTest::TestTertiary(/* char* par */)

View file

@ -39,7 +39,7 @@ private:
// static constants
static const UChar testSourceCases[][MAX_TOKEN_LEN];
static const UChar testTargetCases[][MAX_TOKEN_LEN];
static const Collator::EComparisonResult results[];
static const UCollationResult results[];
Collator *myCollation;
};

View file

@ -351,13 +351,13 @@ IntlTestCollator::compareUsingPartials(UCollator *coll, const UChar source[], in
}
void
IntlTestCollator::doTestVariant(Collator* col, const UnicodeString &source, const UnicodeString &target, Collator::EComparisonResult result)
IntlTestCollator::doTestVariant(Collator* col, const UnicodeString &source, const UnicodeString &target, UCollationResult result)
{
UErrorCode status = U_ZERO_ERROR;
UCollator *myCollation = (UCollator *)((RuleBasedCollator *)col)->getUCollator();
Collator::EComparisonResult compareResult = col->compare(source, target);
UCollationResult compareResult = col->compare(source, target);
CollationKey srckey, tgtkey;
col->getCollationKey(source, srckey, status);
@ -365,7 +365,7 @@ IntlTestCollator::doTestVariant(Collator* col, const UnicodeString &source, cons
if (U_FAILURE(status)){
errln("Creation of collation keys failed\n");
}
Collator::EComparisonResult keyResult = srckey.compareTo(tgtkey);
UCollationResult keyResult = srckey.compareTo(tgtkey);
reportCResult(source, target, srckey, tgtkey, compareResult, keyResult, result, result);
@ -464,18 +464,18 @@ IntlTestCollator::doTestVariant(Collator* col, const UnicodeString &source, cons
}
void
IntlTestCollator::doTest(Collator* col, const UChar *source, const UChar *target, Collator::EComparisonResult result) {
IntlTestCollator::doTest(Collator* col, const UChar *source, const UChar *target, UCollationResult result) {
doTest(col, UnicodeString(source), UnicodeString(target), result);
}
void
IntlTestCollator::doTest(Collator* col, const UnicodeString &source, const UnicodeString &target, Collator::EComparisonResult result)
IntlTestCollator::doTest(Collator* col, const UnicodeString &source, const UnicodeString &target, UCollationResult result)
{
doTestVariant(col, source, target, result);
if(result == Collator::LESS) {
doTestVariant(col, target, source, Collator::GREATER);
} else if (result == Collator::GREATER) {
doTestVariant(col, target, source, Collator::LESS);
if(result == UCOL_LESS) {
doTestVariant(col, target, source, UCOL_GREATER);
} else if (result == UCOL_GREATER) {
doTestVariant(col, target, source, UCOL_LESS);
}
UErrorCode status = U_ZERO_ERROR;
@ -494,10 +494,10 @@ IntlTestCollator::doTest(Collator* col, const UnicodeString &source, const Unico
void
IntlTestCollator::reportCResult( const UnicodeString &source, const UnicodeString &target,
CollationKey &sourceKey, CollationKey &targetKey,
Collator::EComparisonResult compareResult,
Collator::EComparisonResult keyResult,
Collator::EComparisonResult incResult,
Collator::EComparisonResult expectedResult )
UCollationResult compareResult,
UCollationResult keyResult,
UCollationResult incResult,
UCollationResult expectedResult )
{
if (expectedResult < -1 || expectedResult > 1)
{
@ -563,18 +563,18 @@ IntlTestCollator::reportCResult( const UnicodeString &source, const UnicodeStrin
}
UnicodeString&
IntlTestCollator::appendCompareResult(Collator::EComparisonResult result,
IntlTestCollator::appendCompareResult(UCollationResult result,
UnicodeString& target)
{
if (result == Collator::LESS)
if (result == UCOL_LESS)
{
target += "LESS";
}
else if (result == Collator::EQUAL)
else if (result == UCOL_EQUAL)
{
target += "EQUAL";
}
else if (result == Collator::GREATER)
else if (result == UCOL_GREATER)
{
target += "GREATER";
}

View file

@ -28,19 +28,19 @@ class IntlTestCollator: public IntlTest {
void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par = NULL );
protected:
// These two should probably go down in IntlTest
void doTest(Collator* col, const UChar *source, const UChar *target, Collator::EComparisonResult result);
void doTest(Collator* col, const UChar *source, const UChar *target, UCollationResult result);
void doTest(Collator* col, const UnicodeString &source, const UnicodeString &target, Collator::EComparisonResult result);
void doTestVariant(Collator* col, const UnicodeString &source, const UnicodeString &target, Collator::EComparisonResult result);
void doTest(Collator* col, const UnicodeString &source, const UnicodeString &target, UCollationResult result);
void doTestVariant(Collator* col, const UnicodeString &source, const UnicodeString &target, UCollationResult result);
virtual void reportCResult( const UnicodeString &source, const UnicodeString &target,
CollationKey &sourceKey, CollationKey &targetKey,
Collator::EComparisonResult compareResult,
Collator::EComparisonResult keyResult,
Collator::EComparisonResult incResult,
Collator::EComparisonResult expectedResult );
UCollationResult compareResult,
UCollationResult keyResult,
UCollationResult incResult,
UCollationResult expectedResult );
static UnicodeString &prettify(const CollationKey &source, UnicodeString &target);
static UnicodeString &appendCompareResult(Collator::EComparisonResult result, UnicodeString &target);
static UnicodeString &appendCompareResult(UCollationResult result, UnicodeString &target);
void backAndForth(CollationElementIterator &iter);
/**
* Return an integer array containing all of the collation orders

View file

@ -198,10 +198,10 @@ TimeZoneBoundaryTest::verifyDST(UDate d, TimeZone* time_zone, UBool expUseDaylig
GregorianCalendar *gc = new GregorianCalendar(time_zone->clone(), status);
gc->setTime(d, status);
if (failure(status, "GregorianCalendar::setTime")) return;
int32_t offset = time_zone->getOffset((uint8_t)gc->get(gc->ERA, status),
gc->get(gc->YEAR, status), gc->get(gc->MONTH, status),
gc->get(gc->DAY_OF_MONTH, status), (uint8_t)gc->get(gc->DAY_OF_WEEK, status),
((gc->get(gc->HOUR_OF_DAY, status) * 60 + gc->get(gc->MINUTE, status)) * 60 + gc->get(gc->SECOND, status)) * 1000 + gc->get(gc->MILLISECOND, status),
int32_t offset = time_zone->getOffset((uint8_t)gc->get(UCAL_ERA, status),
gc->get(UCAL_YEAR, status), gc->get(UCAL_MONTH, status),
gc->get(UCAL_DATE, status), (uint8_t)gc->get(UCAL_DAY_OF_WEEK, status),
((gc->get(UCAL_HOUR_OF_DAY, status) * 60 + gc->get(UCAL_MINUTE, status)) * 60 + gc->get(UCAL_SECOND, status)) * 1000 + gc->get(UCAL_MILLISECOND, status),
status);
if (failure(status, "GregorianCalendar::get")) return;
if (offset == expDSTOffset) logln(UnicodeString("PASS: getOffset() = ") + (offset / ONE_HOUR));
@ -221,7 +221,7 @@ TimeZoneBoundaryTest::TestBoundaries()
#if 1
{
logln("--- Test a ---");
UDate d = date(97, Calendar::APRIL, 6);
UDate d = date(97, UCAL_APRIL, 6);
TimeZone *z = TimeZone::createTimeZone("PST");
for (int32_t i = 60; i <= 180; i += 15) {
UBool inDST = (i >= 120);
@ -325,7 +325,7 @@ TimeZoneBoundaryTest::TestNewRules()
SimpleTimeZone *tz;
logln("-----------------------------------------------------------------");
logln("Aug 2ndTues .. Mar 15");
tz = new SimpleTimeZone(- 8 * (int32_t)ONE_HOUR, "Test_1", Calendar::AUGUST, 2, Calendar::TUESDAY, 2 * (int32_t)ONE_HOUR, Calendar::MARCH, 15, 0, 2 * (int32_t)ONE_HOUR, status);
tz = new SimpleTimeZone(- 8 * (int32_t)ONE_HOUR, "Test_1", UCAL_AUGUST, 2, UCAL_TUESDAY, 2 * (int32_t)ONE_HOUR, UCAL_MARCH, 15, 0, 2 * (int32_t)ONE_HOUR, status);
logln("========================================");
testUsingBinarySearch(tz, date(97, 0, 1), 858416400000.0);
logln("========================================");
@ -333,7 +333,7 @@ TimeZoneBoundaryTest::TestNewRules()
delete tz;
logln("-----------------------------------------------------------------");
logln("Apr Wed>=14 .. Sep Sun<=20");
tz = new SimpleTimeZone(- 8 * (int32_t)ONE_HOUR, "Test_2", Calendar::APRIL, 14, - Calendar::WEDNESDAY, 2 *(int32_t)ONE_HOUR, Calendar::SEPTEMBER, - 20, - Calendar::SUNDAY, 2 * (int32_t)ONE_HOUR, status);
tz = new SimpleTimeZone(- 8 * (int32_t)ONE_HOUR, "Test_2", UCAL_APRIL, 14, - UCAL_WEDNESDAY, 2 *(int32_t)ONE_HOUR, UCAL_SEPTEMBER, - 20, - UCAL_SUNDAY, 2 * (int32_t)ONE_HOUR, status);
logln("========================================");
testUsingBinarySearch(tz, date(97, 0, 1), 861184800000.0);
logln("========================================");
@ -350,7 +350,7 @@ TimeZoneBoundaryTest::findBoundariesStepwise(int32_t year, UDate interval, TimeZ
{
UErrorCode status = U_ZERO_ERROR;
UnicodeString str;
UDate d = date(year - 1900, Calendar::JANUARY, 1);
UDate d = date(year - 1900, UCAL_JANUARY, 1);
UDate time = d;
UDate limit = time + ONE_YEAR + ONE_DAY;
UBool lastState = z->inDaylightTime(d, status);

View file

@ -129,14 +129,14 @@ void TimeZoneRegressionTest:: Test4073215()
SimpleTimeZone *z = (SimpleTimeZone*) TimeZone::createTimeZone("GMT");
if (z->useDaylightTime())
errln("Fail: Fix test to start with non-DST zone");
z->setStartRule(Calendar::FEBRUARY, 1, Calendar::SUNDAY, 0, status);
z->setStartRule(UCAL_FEBRUARY, 1, UCAL_SUNDAY, 0, status);
failure(status, "z->setStartRule()");
z->setEndRule(Calendar::MARCH, -1, Calendar::SUNDAY, 0, status);
z->setEndRule(UCAL_MARCH, -1, UCAL_SUNDAY, 0, status);
failure(status, "z->setStartRule()");
if (!z->useDaylightTime())
errln("Fail: DST not active");
GregorianCalendar cal(1997, Calendar::JANUARY, 31, status);
GregorianCalendar cal(1997, UCAL_JANUARY, 31, status);
failure(status, "new GregorianCalendar");
cal.adoptTimeZone(z);
@ -151,7 +151,7 @@ void TimeZoneRegressionTest:: Test4073215()
if (indt) {
errln("Fail: Jan 31 inDaylightTime=TRUE, exp FALSE");
}
cal.set(1997, Calendar::MARCH, 1);
cal.set(1997, UCAL_MARCH, 1);
indt = z->inDaylightTime(mar1=cal.getTime(status), status);
failure(status, "inDaylightTime or getTime call on Mar 1");
if (!indt) {
@ -160,7 +160,7 @@ void TimeZoneRegressionTest:: Test4073215()
failure(status, "getTime");
errln((UnicodeString)"Fail: " + str + " inDaylightTime=FALSE, exp TRUE");
}
cal.set(1997, Calendar::MARCH, 31);
cal.set(1997, UCAL_MARCH, 31);
indt = z->inDaylightTime(mar31=cal.getTime(status), status);
failure(status, "inDaylightTime or getTime call on Mar 31");
if (indt) {
@ -200,14 +200,14 @@ void TimeZoneRegressionTest:: Test4084933() {
TimeZone *tz = TimeZone::createTimeZone("PST");
int32_t offset1 = tz->getOffset(1,
1997, Calendar::OCTOBER, 26, Calendar::SUNDAY, (2*60*60*1000), status);
1997, UCAL_OCTOBER, 26, UCAL_SUNDAY, (2*60*60*1000), status);
int32_t offset2 = tz->getOffset(1,
1997, Calendar::OCTOBER, 26, Calendar::SUNDAY, (2*60*60*1000)-1, status);
1997, UCAL_OCTOBER, 26, UCAL_SUNDAY, (2*60*60*1000)-1, status);
int32_t offset3 = tz->getOffset(1,
1997, Calendar::OCTOBER, 26, Calendar::SUNDAY, (1*60*60*1000), status);
1997, UCAL_OCTOBER, 26, UCAL_SUNDAY, (1*60*60*1000), status);
int32_t offset4 = tz->getOffset(1,
1997, Calendar::OCTOBER, 26, Calendar::SUNDAY, (1*60*60*1000)-1, status);
1997, UCAL_OCTOBER, 26, UCAL_SUNDAY, (1*60*60*1000)-1, status);
/*
* The following was added just for consistency. It shows that going *to* Daylight
@ -215,14 +215,14 @@ void TimeZoneRegressionTest:: Test4084933() {
*/
int32_t offset5 = tz->getOffset(1,
1997, Calendar::APRIL, 6, Calendar::SUNDAY, (2*60*60*1000), status);
1997, UCAL_APRIL, 6, UCAL_SUNDAY, (2*60*60*1000), status);
int32_t offset6 = tz->getOffset(1,
1997, Calendar::APRIL, 6, Calendar::SUNDAY, (2*60*60*1000)-1, status);
1997, UCAL_APRIL, 6, UCAL_SUNDAY, (2*60*60*1000)-1, status);
int32_t offset7 = tz->getOffset(1,
1997, Calendar::APRIL, 6, Calendar::SUNDAY, (1*60*60*1000), status);
1997, UCAL_APRIL, 6, UCAL_SUNDAY, (1*60*60*1000), status);
int32_t offset8 = tz->getOffset(1,
1997, Calendar::APRIL, 6, Calendar::SUNDAY, (1*60*60*1000)-1, status);
1997, UCAL_APRIL, 6, UCAL_SUNDAY, (1*60*60*1000)-1, status);
int32_t SToffset = (int32_t)(-8 * 60*60*1000L);
int32_t DToffset = (int32_t)(-7 * 60*60*1000L);
@ -296,10 +296,10 @@ void TimeZoneRegressionTest:: Test4109314() {
PST, new Date(98,Calendar.OCTOBER,24,22,0), new Date(98,Calendar.OCTOBER,25,6,0),
};*/
UDate testData [] = {
CalendarRegressionTest::makeDate(98,Calendar::APRIL,4,22,0),
CalendarRegressionTest::makeDate(98, Calendar::APRIL,5,6,0),
CalendarRegressionTest::makeDate(98,Calendar::OCTOBER,24,22,0),
CalendarRegressionTest::makeDate(98,Calendar::OCTOBER,25,6,0)
CalendarRegressionTest::makeDate(98,UCAL_APRIL,4,22,0),
CalendarRegressionTest::makeDate(98, UCAL_APRIL,5,6,0),
CalendarRegressionTest::makeDate(98,UCAL_OCTOBER,24,22,0),
CalendarRegressionTest::makeDate(98,UCAL_OCTOBER,25,6,0)
};
UBool pass = TRUE;
for (int32_t i = 0; i < 4; i+=2) {
@ -332,33 +332,33 @@ TimeZoneRegressionTest::checkCalendar314(GregorianCalendar *testCal, TimeZone *t
// Here is where the user made an error. They were passing in the value of
// the MILLSECOND field; you need to pass in the millis in the day in STANDARD
// time.
UDate millis = testCal->get(Calendar::MILLISECOND, status) +
1000.0 * (testCal->get(Calendar::SECOND, status) +
60.0 * (testCal->get(Calendar::MINUTE, status) +
60.0 * (testCal->get(Calendar::HOUR_OF_DAY, status)))) -
testCal->get(Calendar::DST_OFFSET, status);
UDate millis = testCal->get(UCAL_MILLISECOND, status) +
1000.0 * (testCal->get(UCAL_SECOND, status) +
60.0 * (testCal->get(UCAL_MINUTE, status) +
60.0 * (testCal->get(UCAL_HOUR_OF_DAY, status)))) -
testCal->get(UCAL_DST_OFFSET, status);
/* Fix up millis to be in range. ASSUME THAT WE ARE NOT AT THE
* BEGINNING OR END OF A MONTH. We must add this code because
* getOffset() has been changed to be more strict about the parameters
* it receives -- it turns out that this test was passing in illegal
* values. */
int32_t date = testCal->get(Calendar::DATE, status);
int32_t dow = testCal->get(Calendar::DAY_OF_WEEK, status);
int32_t date = testCal->get(UCAL_DATE, status);
int32_t dow = testCal->get(UCAL_DAY_OF_WEEK, status);
while(millis < 0) {
millis += U_MILLIS_PER_DAY;
--date;
dow = Calendar::SUNDAY + ((dow - Calendar::SUNDAY + 6) % 7);
dow = UCAL_SUNDAY + ((dow - UCAL_SUNDAY + 6) % 7);
}
while (millis >= U_MILLIS_PER_DAY) {
millis -= U_MILLIS_PER_DAY;
++date;
dow = Calendar::SUNDAY + ((dow - Calendar::SUNDAY + 1) % 7);
dow = UCAL_SUNDAY + ((dow - UCAL_SUNDAY + 1) % 7);
}
tzOffset = testTZ->getOffset((uint8_t)testCal->get(Calendar::ERA, status),
testCal->get(Calendar::YEAR, status),
testCal->get(Calendar::MONTH, status),
tzOffset = testTZ->getOffset((uint8_t)testCal->get(UCAL_ERA, status),
testCal->get(UCAL_YEAR, status),
testCal->get(UCAL_MONTH, status),
date,
(uint8_t)dow,
(int32_t)millis,
@ -430,23 +430,23 @@ void TimeZoneRegressionTest:: Test4126678()
TimeZone *tz = TimeZone::createTimeZone("PST");
cal->adoptTimeZone(tz);
cal->set(1998 - 1900, Calendar::APRIL, 5, 10, 0);
cal->set(1998 - 1900, UCAL_APRIL, 5, 10, 0);
//Date dt = new Date(1998-1900, Calendar::APRIL, 5, 10, 0);
if (! tz->useDaylightTime() || U_FAILURE(status))
errln("We're not in Daylight Savings Time and we should be.\n");
//cal.setTime(dt);
int32_t era = cal->get(Calendar::ERA, status);
int32_t year = cal->get(Calendar::YEAR, status);
int32_t month = cal->get(Calendar::MONTH, status);
int32_t day = cal->get(Calendar::DATE, status);
int32_t dayOfWeek = cal->get(Calendar::DAY_OF_WEEK, status);
int32_t millis = cal->get(Calendar::MILLISECOND, status) +
(cal->get(Calendar::SECOND, status) +
(cal->get(Calendar::MINUTE, status) +
(cal->get(Calendar::HOUR, status) * 60) * 60) * 1000) -
cal->get(Calendar::DST_OFFSET, status);
int32_t era = cal->get(UCAL_ERA, status);
int32_t year = cal->get(UCAL_YEAR, status);
int32_t month = cal->get(UCAL_MONTH, status);
int32_t day = cal->get(UCAL_DATE, status);
int32_t dayOfWeek = cal->get(UCAL_DAY_OF_WEEK, status);
int32_t millis = cal->get(UCAL_MILLISECOND, status) +
(cal->get(UCAL_SECOND, status) +
(cal->get(UCAL_MINUTE, status) +
(cal->get(UCAL_HOUR, status) * 60) * 60) * 1000) -
cal->get(UCAL_DST_OFFSET, status);
failure(status, "cal->get");
int32_t offset = tz->getOffset((uint8_t)era, year, month, day, (uint8_t)dayOfWeek, millis, status);
@ -556,30 +556,30 @@ void TimeZoneRegressionTest:: Test4154542()
const int32_t GOOD = 1;
const int32_t BAD = 0;
const int32_t GOOD_MONTH = Calendar::JANUARY;
const int32_t GOOD_MONTH = UCAL_JANUARY;
const int32_t GOOD_DAY = 1;
const int32_t GOOD_DAY_OF_WEEK = Calendar::SUNDAY;
const int32_t GOOD_DAY_OF_WEEK = UCAL_SUNDAY;
const int32_t GOOD_TIME = 0;
int32_t DATA [] = {
GOOD, INT32_MIN, 0, INT32_MAX, INT32_MIN,
GOOD, Calendar::JANUARY, -5, Calendar::SUNDAY, 0,
GOOD, Calendar::DECEMBER, 5, Calendar::SATURDAY, 24*60*60*1000,
BAD, Calendar::DECEMBER, 5, Calendar::SATURDAY, 24*60*60*1000+1,
BAD, Calendar::DECEMBER, 5, Calendar::SATURDAY, -1,
BAD, Calendar::JANUARY, -6, Calendar::SUNDAY, 0,
BAD, Calendar::DECEMBER, 6, Calendar::SATURDAY, 24*60*60*1000,
GOOD, Calendar::DECEMBER, 1, 0, 0,
GOOD, Calendar::DECEMBER, 31, 0, 0,
BAD, Calendar::APRIL, 31, 0, 0,
BAD, Calendar::DECEMBER, 32, 0, 0,
BAD, Calendar::JANUARY-1, 1, Calendar::SUNDAY, 0,
BAD, Calendar::DECEMBER+1, 1, Calendar::SUNDAY, 0,
GOOD, Calendar::DECEMBER, 31, -Calendar::SUNDAY, 0,
GOOD, Calendar::DECEMBER, 31, -Calendar::SATURDAY, 0,
BAD, Calendar::DECEMBER, 32, -Calendar::SATURDAY, 0,
BAD, Calendar::DECEMBER, -32, -Calendar::SATURDAY, 0,
BAD, Calendar::DECEMBER, 31, -Calendar::SATURDAY-1, 0,
GOOD, UCAL_JANUARY, -5, UCAL_SUNDAY, 0,
GOOD, UCAL_DECEMBER, 5, UCAL_SATURDAY, 24*60*60*1000,
BAD, UCAL_DECEMBER, 5, UCAL_SATURDAY, 24*60*60*1000+1,
BAD, UCAL_DECEMBER, 5, UCAL_SATURDAY, -1,
BAD, UCAL_JANUARY, -6, UCAL_SUNDAY, 0,
BAD, UCAL_DECEMBER, 6, UCAL_SATURDAY, 24*60*60*1000,
GOOD, UCAL_DECEMBER, 1, 0, 0,
GOOD, UCAL_DECEMBER, 31, 0, 0,
BAD, UCAL_APRIL, 31, 0, 0,
BAD, UCAL_DECEMBER, 32, 0, 0,
BAD, UCAL_JANUARY-1, 1, UCAL_SUNDAY, 0,
BAD, UCAL_DECEMBER+1, 1, UCAL_SUNDAY, 0,
GOOD, UCAL_DECEMBER, 31, -UCAL_SUNDAY, 0,
GOOD, UCAL_DECEMBER, 31, -UCAL_SATURDAY, 0,
BAD, UCAL_DECEMBER, 32, -UCAL_SATURDAY, 0,
BAD, UCAL_DECEMBER, -32, -UCAL_SATURDAY, 0,
BAD, UCAL_DECEMBER, 31, -UCAL_SATURDAY-1, 0,
};
SimpleTimeZone *zone = new SimpleTimeZone(0, "Z");
for (int32_t i=0; i < 18*5; i+=5) {
@ -689,8 +689,8 @@ TimeZoneRegressionTest::Test4154525()
case 0:
method = "constructor";
z = new SimpleTimeZone(0, "id",
Calendar::JANUARY, 1, 0, 0,
Calendar::MARCH, 1, 0, 0,
UCAL_JANUARY, 1, 0, 0,
UCAL_MARCH, 1, 0, 0,
savings, status); // <- what we're interested in
break;
case 1:
@ -730,8 +730,8 @@ void
TimeZoneRegressionTest::Test4154650()
{
const int32_t GOOD = 1, BAD = 0;
const int32_t GOOD_ERA = GregorianCalendar::AD, GOOD_YEAR = 1998, GOOD_MONTH = Calendar::AUGUST;
const int32_t GOOD_DAY = 2, GOOD_DOW = Calendar::SUNDAY, GOOD_TIME = 16*3600000;
const int32_t GOOD_ERA = GregorianCalendar::AD, GOOD_YEAR = 1998, GOOD_MONTH = UCAL_AUGUST;
const int32_t GOOD_DAY = 2, GOOD_DOW = UCAL_SUNDAY, GOOD_TIME = 16*3600000;
int32_t DATA []= {
GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, GOOD_TIME,
@ -741,20 +741,20 @@ TimeZoneRegressionTest::Test4154650()
BAD, GregorianCalendar::BC-1, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, GOOD_TIME,
BAD, GregorianCalendar::AD+1, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, Calendar::JANUARY, GOOD_DAY, GOOD_DOW, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, Calendar::DECEMBER, GOOD_DAY, GOOD_DOW, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, Calendar::JANUARY-1, GOOD_DAY, GOOD_DOW, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, Calendar::DECEMBER+1, GOOD_DAY, GOOD_DOW, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, UCAL_JANUARY, GOOD_DAY, GOOD_DOW, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, UCAL_DECEMBER, GOOD_DAY, GOOD_DOW, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, UCAL_JANUARY-1, GOOD_DAY, GOOD_DOW, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, UCAL_DECEMBER+1, GOOD_DAY, GOOD_DOW, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, Calendar::JANUARY, 1, GOOD_DOW, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, Calendar::JANUARY, 31, GOOD_DOW, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, Calendar::JANUARY, 0, GOOD_DOW, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, Calendar::JANUARY, 32, GOOD_DOW, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, UCAL_JANUARY, 1, GOOD_DOW, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, UCAL_JANUARY, 31, GOOD_DOW, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, UCAL_JANUARY, 0, GOOD_DOW, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, UCAL_JANUARY, 32, GOOD_DOW, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, Calendar::SUNDAY, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, Calendar::SATURDAY, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, Calendar::SUNDAY-1, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, Calendar::SATURDAY+1, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, UCAL_SUNDAY, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, UCAL_SATURDAY, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, UCAL_SUNDAY-1, GOOD_TIME,
BAD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, UCAL_SATURDAY+1, GOOD_TIME,
GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, 0,
GOOD, GOOD_ERA, GOOD_YEAR, GOOD_MONTH, GOOD_DAY, GOOD_DOW, 24*3600000-1,
@ -800,8 +800,8 @@ TimeZoneRegressionTest::Test4162593()
const int32_t ONE_HOUR = 60*60*1000;
SimpleTimeZone *asuncion = new SimpleTimeZone(-4*ONE_HOUR, "America/Asuncion" /*PY%sT*/,
Calendar::OCTOBER, 1, 0 /*DOM*/, 0*ONE_HOUR,
Calendar::MARCH, 1, 0 /*DOM*/, 0*ONE_HOUR, 1*ONE_HOUR, status);
UCAL_OCTOBER, 1, 0 /*DOM*/, 0*ONE_HOUR,
UCAL_MARCH, 1, 0 /*DOM*/, 0*ONE_HOUR, 1*ONE_HOUR, status);
/* Zone
* Starting time
@ -811,9 +811,9 @@ TimeZoneRegressionTest::Test4162593()
0, 0, 0 };
int32_t DATA_INT [] [5] = {
{98, Calendar::SEPTEMBER, 30, 22, 0},
{100, Calendar::FEBRUARY, 28, 22, 0},
{100, Calendar::FEBRUARY, 29, 22, 0},
{98, UCAL_SEPTEMBER, 30, 22, 0},
{100, UCAL_FEBRUARY, 28, 22, 0},
{100, UCAL_FEBRUARY, 29, 22, 0},
};
UBool DATA_BOOL [] = {
@ -825,8 +825,8 @@ TimeZoneRegressionTest::Test4162593()
UnicodeString zone [4];// = new String[4];
DATA_TZ[0] =
new SimpleTimeZone(2*ONE_HOUR, "Asia/Damascus" /*EE%sT*/,
Calendar::APRIL, 1, 0 /*DOM*/, 0*ONE_HOUR,
Calendar::OCTOBER, 1, 0 /*DOM*/, 0*ONE_HOUR, 1*ONE_HOUR, status);
UCAL_APRIL, 1, 0 /*DOM*/, 0*ONE_HOUR,
UCAL_OCTOBER, 1, 0 /*DOM*/, 0*ONE_HOUR, 1*ONE_HOUR, status);
DATA_TZ[1] = asuncion; DATA_TZ[2] = asuncion;
for(int32_t j = 0; j < 3; j++) {
@ -873,7 +873,7 @@ void TimeZoneRegressionTest::TestJ186() {
// lines marked //~ are commented out.
SimpleTimeZone z(0, "ID");
//~z.setDSTSavings(0, status); // Must do this!
z.setStartRule(Calendar::FEBRUARY, 1, Calendar::SUNDAY, 0, status);
z.setStartRule(UCAL_FEBRUARY, 1, UCAL_SUNDAY, 0, status);
failure(status, "setStartRule()");
if (z.useDaylightTime()) {
errln("Fail: useDaylightTime true with start rule only");
@ -881,7 +881,7 @@ void TimeZoneRegressionTest::TestJ186() {
//~if (z.getDSTSavings() != 0) {
//~ errln("Fail: dst savings != 0 with start rule only");
//~}
z.setEndRule(Calendar::MARCH, -1, Calendar::SUNDAY, 0, status);
z.setEndRule(UCAL_MARCH, -1, UCAL_SUNDAY, 0, status);
failure(status, "setStartRule()");
if (!z.useDaylightTime()) {
errln("Fail: useDaylightTime false with rules set");
@ -966,12 +966,12 @@ TimeZoneRegressionTest::TestJDK12API()
UErrorCode status = U_ZERO_ERROR;
int32_t offset1 = pst->getOffset(1,
1997, Calendar::OCTOBER, 26, Calendar::SUNDAY, (2*60*60*1000), status);
1997, UCAL_OCTOBER, 26, UCAL_SUNDAY, (2*60*60*1000), status);
failure(status, "getOffset() failed");
int32_t offset2 = cst->getOffset(1,
1997, Calendar::OCTOBER, 26, Calendar::SUNDAY, (2*60*60*1000), 31, status);
1997, UCAL_OCTOBER, 26, UCAL_SUNDAY, (2*60*60*1000), 31, status);
failure(status, "getOffset() failed");
if(offset1 == offset2)
@ -979,7 +979,7 @@ TimeZoneRegressionTest::TestJDK12API()
// verify error checking
pst->getOffset(1,
1997, (Calendar::EDateFields)-1, 26, Calendar::SUNDAY, (2*60*60*1000), status);
1997, (UCalendarDateFields)-1, 26, UCAL_SUNDAY, (2*60*60*1000), status);
if(U_SUCCESS(status))
errln("FAILURE: getOffset() succeeded with -1 for month");

View file

@ -135,10 +135,10 @@ TimeZoneTest::TestRuleAPI()
GregorianCalendar *gc = new GregorianCalendar(*zone, status);
if (failure(status, "new GregorianCalendar")) return;
gc->clear();
gc->set(1990, Calendar::MARCH, 1);
gc->set(1990, UCAL_MARCH, 1);
UDate marchOneStd = gc->getTime(status); // Local Std time midnight
gc->clear();
gc->set(1990, Calendar::JULY, 1);
gc->set(1990, UCAL_JULY, 1);
UDate julyOneStd = gc->getTime(status); // Local Std time midnight
if (failure(status, "GregorianCalendar::getTime")) return;
@ -146,8 +146,8 @@ TimeZoneTest::TestRuleAPI()
int32_t startHour = (int32_t)(2.25 * 3600000);
int32_t endHour = (int32_t)(3.5 * 3600000);
zone->setStartRule(Calendar::MARCH, 1, 0, startHour, status);
zone->setEndRule (Calendar::JULY, 1, 0, endHour, status);
zone->setStartRule(UCAL_MARCH, 1, 0, startHour, status);
zone->setEndRule (UCAL_JULY, 1, 0, endHour, status);
delete gc;
gc = new GregorianCalendar(*zone, status);
@ -174,8 +174,8 @@ TimeZoneTest::TestRuleAPI()
" = " + dateToString(expJulyOne));
}
testUsingBinarySearch(zone, date(90, Calendar::JANUARY, 1), date(90, Calendar::JUNE, 15), marchOne);
testUsingBinarySearch(zone, date(90, Calendar::JUNE, 1), date(90, Calendar::DECEMBER, 31), julyOne);
testUsingBinarySearch(zone, date(90, UCAL_JANUARY, 1), date(90, UCAL_JUNE, 15), marchOne);
testUsingBinarySearch(zone, date(90, UCAL_JUNE, 1), date(90, UCAL_DECEMBER, 31), julyOne);
if (zone->inDaylightTime(marchOne - 1000, status) ||
!zone->inDaylightTime(marchOne, status))
@ -260,7 +260,7 @@ TimeZoneTest::TestVariousAPI518()
{
UErrorCode status = U_ZERO_ERROR;
TimeZone* time_zone = TimeZone::createTimeZone("PST");
UDate d = date(97, Calendar::APRIL, 30);
UDate d = date(97, UCAL_APRIL, 30);
UnicodeString str;
logln("The timezone is " + time_zone->getID(str));
if (!time_zone->inDaylightTime(d, status)) errln("FAIL: inDaylightTime returned FALSE");
@ -271,8 +271,8 @@ TimeZoneTest::TestVariousAPI518()
if (U_FAILURE(status)) { errln("FAIL: Couldn't create GregorianCalendar"); return; }
gc->setTime(d, status);
if (U_FAILURE(status)) { errln("FAIL: GregorianCalendar::setTime failed"); return; }
if (time_zone->getOffset(gc->AD, gc->get(gc->YEAR, status), gc->get(gc->MONTH, status),
gc->get(gc->DAY_OF_MONTH, status), (uint8_t)gc->get(gc->DAY_OF_WEEK, status), 0, status) != - 7 * millisPerHour)
if (time_zone->getOffset(gc->AD, gc->get(UCAL_YEAR, status), gc->get(UCAL_MONTH, status),
gc->get(UCAL_DATE, status), (uint8_t)gc->get(UCAL_DAY_OF_WEEK, status), 0, status) != - 7 * millisPerHour)
errln("FAIL: getOffset returned wrong value");
if (U_FAILURE(status)) { errln("FAIL: GregorianCalendar::set failed"); return; }
delete gc;
@ -792,8 +792,8 @@ TimeZoneTest::TestDisplayName()
// PST zone that has DST all year long.
SimpleTimeZone *zone2 = new SimpleTimeZone(0, "PST");
zone2->setStartRule(Calendar::JANUARY, 1, 0, 0, status);
zone2->setEndRule(Calendar::DECEMBER, 31, 0, 0, status);
zone2->setStartRule(UCAL_JANUARY, 1, 0, 0, status);
zone2->setEndRule(UCAL_DECEMBER, 31, 0, 0, status);
UnicodeString inDaylight = (zone2->inDaylightTime(UDate(0), status)? UnicodeString("TRUE"):UnicodeString("FALSE"));
logln(UnicodeString("Modified PST inDaylightTime->") + inDaylight );
@ -886,7 +886,7 @@ TimeZoneTest::TestDSTSavings()
// tests above, but I don't have time to figure out how to do this (or if it's
// even really a good idea). Let's consider that a future. --rtg 1/27/98
SimpleTimeZone *tz = new SimpleTimeZone(-5 * U_MILLIS_PER_HOUR, "dstSavingsTest",
Calendar::MARCH, 1, 0, 0, Calendar::SEPTEMBER, 1, 0, 0,
UCAL_MARCH, 1, 0, 0, UCAL_SEPTEMBER, 1, 0, 0,
(int32_t)(0.5 * U_MILLIS_PER_HOUR), status);
if(U_FAILURE(status))
errln("couldn't create TimeZone");
@ -900,26 +900,26 @@ TimeZoneTest::TestDSTSavings()
errln(UnicodeString("Set DST offset to 0.5 hour, but got back ") + (tz->getDSTSavings() /
U_MILLIS_PER_HOUR) + " hours instead.");
int32_t offset = tz->getOffset(GregorianCalendar::AD, 1998, Calendar::JANUARY, 1,
Calendar::THURSDAY, 10 * U_MILLIS_PER_HOUR,status);
int32_t offset = tz->getOffset(GregorianCalendar::AD, 1998, UCAL_JANUARY, 1,
UCAL_THURSDAY, 10 * U_MILLIS_PER_HOUR,status);
if (offset != -5 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10 AM, 1/1/98 should have been -5 hours, but we got ")
+ (offset / U_MILLIS_PER_HOUR) + " hours.");
offset = tz->getOffset(GregorianCalendar::AD, 1998, Calendar::JUNE, 1, Calendar::MONDAY,
offset = tz->getOffset(GregorianCalendar::AD, 1998, UCAL_JUNE, 1, UCAL_MONDAY,
10 * U_MILLIS_PER_HOUR,status);
if (offset != -4.5 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10 AM, 6/1/98 should have been -4.5 hours, but we got ")
+ (offset / U_MILLIS_PER_HOUR) + " hours.");
tz->setDSTSavings(U_MILLIS_PER_HOUR, status);
offset = tz->getOffset(GregorianCalendar::AD, 1998, Calendar::JANUARY, 1,
Calendar::THURSDAY, 10 * U_MILLIS_PER_HOUR,status);
offset = tz->getOffset(GregorianCalendar::AD, 1998, UCAL_JANUARY, 1,
UCAL_THURSDAY, 10 * U_MILLIS_PER_HOUR,status);
if (offset != -5 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10 AM, 1/1/98 should have been -5 hours, but we got ")
+ (offset / U_MILLIS_PER_HOUR) + " hours.");
offset = tz->getOffset(GregorianCalendar::AD, 1998, Calendar::JUNE, 1, Calendar::MONDAY,
offset = tz->getOffset(GregorianCalendar::AD, 1998, UCAL_JUNE, 1, UCAL_MONDAY,
10 * U_MILLIS_PER_HOUR,status);
if (offset != -4 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10 AM, 6/1/98 (with a 1-hour DST offset) should have been -4 hours, but we got ")
@ -942,64 +942,64 @@ TimeZoneTest::TestAlternateRules()
// test the day-of-month API
UErrorCode status = U_ZERO_ERROR;
tz.setStartRule(Calendar::MARCH, 10, 12 * U_MILLIS_PER_HOUR, status);
tz.setStartRule(UCAL_MARCH, 10, 12 * U_MILLIS_PER_HOUR, status);
if(U_FAILURE(status))
errln("tz.setStartRule failed");
tz.setEndRule(Calendar::OCTOBER, 20, 12 * U_MILLIS_PER_HOUR, status);
tz.setEndRule(UCAL_OCTOBER, 20, 12 * U_MILLIS_PER_HOUR, status);
if(U_FAILURE(status))
errln("tz.setStartRule failed");
int32_t offset = tz.getOffset(GregorianCalendar::AD, 1998, Calendar::MARCH, 5,
Calendar::THURSDAY, 10 * U_MILLIS_PER_HOUR,status);
int32_t offset = tz.getOffset(GregorianCalendar::AD, 1998, UCAL_MARCH, 5,
UCAL_THURSDAY, 10 * U_MILLIS_PER_HOUR,status);
if (offset != -5 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10AM, 3/5/98 should have been -5 hours, but we got ")
+ (offset / U_MILLIS_PER_HOUR) + " hours.");
offset = tz.getOffset(GregorianCalendar::AD, 1998, Calendar::MARCH, 15,
Calendar::SUNDAY, 10 * millisPerHour,status);
offset = tz.getOffset(GregorianCalendar::AD, 1998, UCAL_MARCH, 15,
UCAL_SUNDAY, 10 * millisPerHour,status);
if (offset != -4 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10AM, 3/15/98 should have been -4 hours, but we got ")
+ (offset / U_MILLIS_PER_HOUR) + " hours.");
offset = tz.getOffset(GregorianCalendar::AD, 1998, Calendar::OCTOBER, 15,
Calendar::THURSDAY, 10 * millisPerHour,status);
offset = tz.getOffset(GregorianCalendar::AD, 1998, UCAL_OCTOBER, 15,
UCAL_THURSDAY, 10 * millisPerHour,status);
if (offset != -4 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10AM, 10/15/98 should have been -4 hours, but we got ") + (offset / U_MILLIS_PER_HOUR) + " hours.");
offset = tz.getOffset(GregorianCalendar::AD, 1998, Calendar::OCTOBER, 25,
Calendar::SUNDAY, 10 * millisPerHour,status);
offset = tz.getOffset(GregorianCalendar::AD, 1998, UCAL_OCTOBER, 25,
UCAL_SUNDAY, 10 * millisPerHour,status);
if (offset != -5 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10AM, 10/25/98 should have been -5 hours, but we got ")
+ (offset / U_MILLIS_PER_HOUR) + " hours.");
// test the day-of-week-after-day-in-month API
tz.setStartRule(Calendar::MARCH, 10, Calendar::FRIDAY, 12 * millisPerHour, TRUE, status);
tz.setStartRule(UCAL_MARCH, 10, UCAL_FRIDAY, 12 * millisPerHour, TRUE, status);
if(U_FAILURE(status))
errln("tz.setStartRule failed");
tz.setEndRule(Calendar::OCTOBER, 20, Calendar::FRIDAY, 12 * millisPerHour, FALSE, status);
tz.setEndRule(UCAL_OCTOBER, 20, UCAL_FRIDAY, 12 * millisPerHour, FALSE, status);
if(U_FAILURE(status))
errln("tz.setStartRule failed");
offset = tz.getOffset(GregorianCalendar::AD, 1998, Calendar::MARCH, 11,
Calendar::WEDNESDAY, 10 * millisPerHour,status);
offset = tz.getOffset(GregorianCalendar::AD, 1998, UCAL_MARCH, 11,
UCAL_WEDNESDAY, 10 * millisPerHour,status);
if (offset != -5 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10AM, 3/11/98 should have been -5 hours, but we got ")
+ (offset / U_MILLIS_PER_HOUR) + " hours.");
offset = tz.getOffset(GregorianCalendar::AD, 1998, Calendar::MARCH, 14,
Calendar::SATURDAY, 10 * millisPerHour,status);
offset = tz.getOffset(GregorianCalendar::AD, 1998, UCAL_MARCH, 14,
UCAL_SATURDAY, 10 * millisPerHour,status);
if (offset != -4 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10AM, 3/14/98 should have been -4 hours, but we got ")
+ (offset / U_MILLIS_PER_HOUR) + " hours.");
offset = tz.getOffset(GregorianCalendar::AD, 1998, Calendar::OCTOBER, 15,
Calendar::THURSDAY, 10 * millisPerHour,status);
offset = tz.getOffset(GregorianCalendar::AD, 1998, UCAL_OCTOBER, 15,
UCAL_THURSDAY, 10 * millisPerHour,status);
if (offset != -4 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10AM, 10/15/98 should have been -4 hours, but we got ")
+ (offset / U_MILLIS_PER_HOUR) + " hours.");
offset = tz.getOffset(GregorianCalendar::AD, 1998, Calendar::OCTOBER, 17,
Calendar::SATURDAY, 10 * millisPerHour,status);
offset = tz.getOffset(GregorianCalendar::AD, 1998, UCAL_OCTOBER, 17,
UCAL_SATURDAY, 10 * millisPerHour,status);
if (offset != -5 * U_MILLIS_PER_HOUR)
errln(UnicodeString("The offset for 10AM, 10/17/98 should have been -5 hours, but we got ")
+ (offset / U_MILLIS_PER_HOUR) + " hours.");