/********************************************************************
- * Copyright (c) 1997-2007, International Business Machines
+ * Copyright (c) 1997-2013, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************/
GregorianCalendar cal(1997, UCAL_JANUARY, 31, status);
if(U_FAILURE(status)) {
- errln("Error creating calendar %s", u_errorName(status));
+ dataerrln("Error creating calendar %s", u_errorName(status));
return;
}
failure(status, "new GregorianCalendar");
SimpleDateFormat sdf((UnicodeString)"E d MMM yyyy G HH:mm", status);
if(U_FAILURE(status)) {
- errln("Error creating date format %s", u_errorName(status));
+ dataerrln("Error creating date format %s", u_errorName(status));
return;
}
sdf.setCalendar(cal);
int32_t SToffset = (int32_t)(-8 * 60*60*1000L);
int32_t DToffset = (int32_t)(-7 * 60*60*1000L);
-#define ERR_IF_FAIL(x) if(x) { errln("FAIL: TimeZone misbehaving - %s", #x); }
+#define ERR_IF_FAIL(x) if(x) { dataerrln("FAIL: TimeZone misbehaving - %s", #x); }
ERR_IF_FAIL(U_FAILURE(status))
ERR_IF_FAIL(offset1 != SToffset)
UErrorCode status = U_ZERO_ERROR;
GregorianCalendar *testCal = (GregorianCalendar*)Calendar::createInstance(status);
if(U_FAILURE(status)) {
- errln("Error creating calendar %s", u_errorName(status));
+ dataerrln("Error creating calendar %s", u_errorName(status));
delete testCal;
return;
}
UErrorCode status = U_ZERO_ERROR;
Calendar *cal = Calendar::createInstance(status);
if(U_FAILURE(status)) {
- errln("Error creating calendar %s", u_errorName(status));
+ dataerrln("Error creating calendar %s", u_errorName(status));
delete cal;
return;
}
TimeZone *tz = TimeZone::createTimeZone("PST");
cal->adoptTimeZone(tz);
- cal->set(1998 - 1900, UCAL_APRIL, 5, 10, 0);
- //Date dt = new Date(1998-1900, Calendar::APRIL, 5, 10, 0);
+ cal->set(1998, UCAL_APRIL, 5, 10, 0);
if (! tz->useDaylightTime() || U_FAILURE(status))
- errln("We're not in Daylight Savings Time and we should be.\n");
+ dataerrln("We're not in Daylight Savings Time and we should be. - %s", u_errorName(status));
//cal.setTime(dt);
int32_t era = cal->get(UCAL_ERA, status);
failure(status, "cal->get");
int32_t offset = tz->getOffset((uint8_t)era, year, month, day, (uint8_t)dayOfWeek, millis, status);
int32_t raw_offset = tz->getRawOffset();
- /* Because of better historical timezone support based on Olson data,
- * DST is not observed in year 98. Thus, the expected result is changed.
- * As of Mar 2007, ICU timezone transition data is represented by 32-bit.
- * When we support 64-bit Olson transition data, the actual offset in
- * AD 98 for America/Los_Angeles will be changed again (-7:52:58). Until
- * then, expected result is offset == raw_offset. -Yoshito
- */
- /*
+
if (offset == raw_offset)
- errln("Offsets should not match when in DST");
- */
- /* TODO: When ICU support the Olson LMT offset for America/Los_Angeles, we need to update
- * the reference data.
- */
- if (offset != raw_offset)
- errln("Offsets should match");
+ dataerrln("Offsets should match");
delete cal;
}
UErrorCode ec = U_ZERO_ERROR;
int32_t count;
StringEnumeration* ids = TimeZone::createEnumeration(rawoffset);
+ if (ids == NULL) {
+ dataerrln("Fail: TimeZone::createEnumeration(rawoffset)");
+ continue;
+ }
count = ids->count(ec);
if (count> max)
max = count;
UErrorCode status = U_ZERO_ERROR;
SimpleDateFormat *fmt = new SimpleDateFormat("z", Locale::getUS(), status);
if(U_FAILURE(status)) {
- errln("Error creating calendar %s", u_errorName(status));
+ dataerrln("Error creating calendar %s", u_errorName(status));
delete fmt;
return;
}
// Also check DateFormat
DateFormat* fmt1 = new SimpleDateFormat(UnicodeString("z"), status);
- if(!assertSuccess("trying to construct", status))return;
+ if (U_FAILURE(status)) {
+ dataerrln("Failure trying to construct: %s", u_errorName(status));
+ return;
+ }
fmt1->setTimeZone(*z1); // Format uses standard zone
DateFormat* fmt2 = new SimpleDateFormat(UnicodeString("z"), status);
if(!assertSuccess("trying to construct", status))return;
UnicodeString a,b,c,d,e,f,g,h,i,j,k,l;
UnicodeString DATA[] = {
"z1->getDisplayName(false, SHORT)/std zone",
- z1->getDisplayName(FALSE, TimeZone::SHORT, a), "GMT+01:30",
+ z1->getDisplayName(FALSE, TimeZone::SHORT, a), "GMT+1:30",
"z1->getDisplayName(false, LONG)/std zone",
z1->getDisplayName(FALSE, TimeZone::LONG, b), "GMT+01:30",
"z1->getDisplayName(true, SHORT)/std zone",
- z1->getDisplayName(TRUE, TimeZone::SHORT, c), "GMT+01:30",
+ z1->getDisplayName(TRUE, TimeZone::SHORT, c), "GMT+1:30",
"z1->getDisplayName(true, LONG)/std zone",
z1->getDisplayName(TRUE, TimeZone::LONG, d ), "GMT+01:30",
"z2->getDisplayName(false, SHORT)/dst zone",
- z2->getDisplayName(FALSE, TimeZone::SHORT, e), "GMT+01:30",
+ z2->getDisplayName(FALSE, TimeZone::SHORT, e), "GMT+1:30",
"z2->getDisplayName(false, LONG)/dst zone",
z2->getDisplayName(FALSE, TimeZone::LONG, f ), "GMT+01:30",
"z2->getDisplayName(true, SHORT)/dst zone",
- z2->getDisplayName(TRUE, TimeZone::SHORT, g), "GMT+02:15",
+ z2->getDisplayName(TRUE, TimeZone::SHORT, g), "GMT+2:15",
"z2->getDisplayName(true, LONG)/dst zone",
z2->getDisplayName(TRUE, TimeZone::LONG, h ), "GMT+02:15",
- "DateFormat.format(std)/std zone", fmt1->format(std, i), "GMT+01:30",
- "DateFormat.format(dst)/std zone", fmt1->format(dst, j), "GMT+01:30",
- "DateFormat.format(std)/dst zone", fmt2->format(std, k), "GMT+01:30",
- "DateFormat.format(dst)/dst zone", fmt2->format(dst, l), "GMT+02:15",
+ "DateFormat.format(std)/std zone", fmt1->format(std, i), "GMT+1:30",
+ "DateFormat.format(dst)/std zone", fmt1->format(dst, j), "GMT+1:30",
+ "DateFormat.format(std)/dst zone", fmt2->format(std, k), "GMT+1:30",
+ "DateFormat.format(dst)/dst zone", fmt2->format(dst, l), "GMT+2:15",
};
for (int32_t idx=0; idx<(int32_t)ARRAY_LENGTH(DATA); idx+=3) {
// Make sure we got valid zones
if (zoneWith->getID(str) != UnicodeString(idWithLocaleData) ||
zoneWithout->getID(str) != UnicodeString(idWithoutLocaleData)) {
- errln(UnicodeString("Fail: Unable to create zones - wanted ") + idWithLocaleData + ", got " + zoneWith->getID(str) + ", and wanted " + idWithoutLocaleData + " but got " + zoneWithout->getID(str));
+ dataerrln(UnicodeString("Fail: Unable to create zones - wanted ") + idWithLocaleData + ", got " + zoneWith->getID(str) + ", and wanted " + idWithoutLocaleData + " but got " + zoneWithout->getID(str));
} else {
GregorianCalendar calWith(*zoneWith, status);
GregorianCalendar calWithout(*zoneWithout, status);
return;
}
- SimpleTimeZone *cst = 0;
-
- if(cst1->getDynamicClassID() == SimpleTimeZone::getStaticClassID())
- cst = (SimpleTimeZone*) cst1;
+ SimpleTimeZone *cst = dynamic_cast<SimpleTimeZone *>(cst1);
if(pst->hasSameRules(*cst)) {
errln("FAILURE: PST and CST have same rules");