/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2010, International Business Machines Corporation and
+ * Copyright (c) 1997-2010,2012, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
- * Headers { "locale","spec", "date", "str"}
+ * Headers { "locale", "zone", "spec", "date", "str"}
// locale: locale including calendar type
+ // zone: time zone name, or "" to not explicitly set zone
// spec: either 'PATTERN=y mm h' etc, or 'DATE=SHORT,TIME=LONG'
// date: either an unsigned long (millis), or a calendar spec ERA=0,YEAR=1, etc.. applied to the calendar type specified by the locale
// str: the expected unicode string
Cases {
{
- "en_US@calendar=gregorian",
+ "en_US@calendar=gregorian",
+ "",
"DATE=SHORT,TIME=SHORT",
"ERA=1,YEAR=2007,MONTH=AUGUST,DATE=8,HOUR=18,MINUTE=54,SECOND=12",
"8/8/2007 6:54pm"
errln("case %d: No 'locale' line.", n);
continue;
}
+ UnicodeString zone = currentCase->getString("zone", status);
+ if (U_FAILURE(status)) {
+ errln("case %d: No 'zone' line.", n);
+ continue;
+ }
UnicodeString spec = currentCase->getString("spec", status);
if(U_FAILURE(status)) {
errln("case %d: No 'spec' line.", n);
if(U_FAILURE(status)) {
errln("case %d: could not create calendar from %s", n, calLoc);
}
+
+ if (zone.length() > 0) {
+ TimeZone * tz = TimeZone::createTimeZone(zone);
+ cal->setTimeZone(*tz);
+ format->setTimeZone(*tz);
+ delete tz;
+ }
// parse 'date'
if(date.startsWith(kMILLIS)) {
for (int q=0; q<UCAL_FIELD_COUNT; q++) {
if (fromSet.isSet((UCalendarDateFields)q)) {
//int32_t oldv = cal->get((UCalendarDateFields)q, status);
- cal->add((UCalendarDateFields)q,
- fromSet.get((UCalendarDateFields)q), status);
+ if (q == UCAL_DATE) {
+ cal->add((UCalendarDateFields)q,
+ fromSet.get((UCalendarDateFields)q), status);
+ } else {
+ cal->set((UCalendarDateFields)q,
+ fromSet.get((UCalendarDateFields)q));
+ }
//int32_t newv = cal->get((UCalendarDateFields)q, status);
}
}