ICU-4917 Remove code from trunk to be added to branch.

X-SVN-Rev: 27779
This commit is contained in:
Jason Spieth 2010-03-04 21:15:43 +00:00
parent 99fe830c00
commit 79a1c517b9
3 changed files with 4 additions and 73 deletions

View File

@ -1900,26 +1900,7 @@ SimpleDateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition&
int32_t s = subParse(text, pos, ch, count, int32_t s = subParse(text, pos, ch, count,
FALSE, TRUE, ambiguousYear, saveHebrewMonth, *workCal, i); FALSE, TRUE, ambiguousYear, saveHebrewMonth, *workCal, i);
if (s == -pos-1) { if (s < 0) {
// era not present, in special cases allow this to continue
s++;
if (i+1 < fPattern.length()) {
// move to next pattern character
UChar ch = fPattern.charAt(i+1);
// check for whitespace
if (uprv_isRuleWhiteSpace(ch)) {
i++;
// Advance over run in pattern
while ((i+1)<fPattern.length() &&
uprv_isRuleWhiteSpace(fPattern.charAt(i+1))) {
++i;
}
}
}
}
else if (s < 0) {
status = U_PARSE_ERROR; status = U_PARSE_ERROR;
goto ExitParse; goto ExitParse;
} }
@ -2369,7 +2350,6 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
Formattable number; Formattable number;
int32_t value = 0; int32_t value = 0;
int32_t i; int32_t i;
int32_t ps = 0;
ParsePosition pos(0); ParsePosition pos(0);
UDateFormatField patternCharIndex; UDateFormatField patternCharIndex;
NumberFormat *currentNumberFormat; NumberFormat *currentNumberFormat;
@ -2464,10 +2444,7 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
return matchString(text, start, UCAL_ERA, fSymbols->fEraNames, fSymbols->fEraNamesCount, cal); return matchString(text, start, UCAL_ERA, fSymbols->fEraNames, fSymbols->fEraNamesCount, cal);
} }
ps = matchString(text, start, UCAL_ERA, fSymbols->fEras, fSymbols->fErasCount, cal); return matchString(text, start, UCAL_ERA, fSymbols->fEras, fSymbols->fErasCount, cal);
if (ps == -start)
ps--;
return ps;
case UDAT_YEAR_FIELD: case UDAT_YEAR_FIELD:
// If there are 3 or more YEAR pattern characters, this indicates // If there are 3 or more YEAR pattern characters, this indicates

View File

@ -79,10 +79,9 @@ void DateFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &nam
TESTCASE(39,Test6726); TESTCASE(39,Test6726);
TESTCASE(40,TestGMTParsing); TESTCASE(40,TestGMTParsing);
TESTCASE(41,Test6880); TESTCASE(41,Test6880);
TESTCASE(42,Test4917);
/* /*
TESTCASE(43,TestRelativeError); TESTCASE(42,TestRelativeError);
TESTCASE(44,TestRelativeOther); TESTCASE(43,TestRelativeOther);
*/ */
default: name = ""; break; default: name = ""; break;
} }
@ -3343,50 +3342,6 @@ void DateFormatTest::Test6880() {
delete fmt; delete fmt;
} }
void DateFormatTest::Test4917() {
const char* data[] = {
// input, output
"BC 4004-10-23T07:00:00Z", "BC 4004-10-23T07:00:00Z",
"AD 4004-10-23T07:00:00Z", "AD 4004-10-23T07:00:00Z",
"-4004-10-23T07:00:00Z" , "BC 4005-10-23T07:00:00Z",
"4004-10-23T07:00:00Z" , "AD 4004-10-23T07:00:00Z",
};
int32_t numData = 8;
UErrorCode status = U_ZERO_ERROR;
// create formatter
SimpleDateFormat *fmt1 = new SimpleDateFormat(UnicodeString("GGG yyyy-MM-dd'T'HH:mm:ss'Z"), status);
failure(status, "new SimpleDateFormat");
for(int i=0; i < numData; i+=2) {
// create input string
UnicodeString in = data[i];
// parse string to date
UDate dt1 = fmt1->parse(in, status);
failure(status, "fmt->parse");
// format date back to string
UnicodeString out;
out = fmt1->format(dt1, out);
logln(out);
// check that roundtrip worked as expected
UnicodeString expected = data[i+1];
if (out != expected) {
errln((UnicodeString)"FAIL: " + in + " -> " + out + " expected -> " + expected);
}
}
delete fmt1;
}
#endif /* #if !UCONFIG_NO_FORMATTING */ #endif /* #if !UCONFIG_NO_FORMATTING */
//eof //eof

View File

@ -167,7 +167,6 @@ public: // package
void Test6880(void); void Test6880(void);
void Test4917(void);
public: public:
/** /**
* Test host-specific formatting. * Test host-specific formatting.