mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-8823 Merging the fix for ticket#8719 (r30508) into maint-4-8.
X-SVN-Rev: 30819
This commit is contained in:
parent
53607e7a50
commit
6a3941084e
3 changed files with 23 additions and 22 deletions
|
@ -2618,14 +2618,15 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
|
|||
else {
|
||||
txtLoc = checkIntSuffix(text, txtLoc, patLoc+1, FALSE);
|
||||
}
|
||||
|
||||
// Check the range of the value
|
||||
int32_t bias = gFieldRangeBias[patternCharIndex];
|
||||
|
||||
if (bias >= 0 && (value > cal.getMaximum(field) + bias || value < cal.getMinimum(field) + bias)) {
|
||||
return -start;
|
||||
|
||||
if (!lenient) {
|
||||
// Check the range of the value
|
||||
int32_t bias = gFieldRangeBias[patternCharIndex];
|
||||
if (bias >= 0 && (value > cal.getMaximum(field) + bias || value < cal.getMinimum(field) + bias)) {
|
||||
return -start;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pos.setIndex(txtLoc);
|
||||
}
|
||||
}
|
||||
|
@ -3140,14 +3141,17 @@ int32_t SimpleDateFormat::subParse(const UnicodeString& text, int32_t& start, UC
|
|||
parseInt(*src, number, pos, allowNegative,currentNumberFormat);
|
||||
if (pos.getIndex() != parseStart) {
|
||||
int32_t value = number.getLong();
|
||||
|
||||
// Check the range of the value
|
||||
int32_t bias = gFieldRangeBias[patternCharIndex];
|
||||
|
||||
if (bias < 0 || (value >= cal.getMinimum(field) + bias && value <= cal.getMaximum(field) + bias)) {
|
||||
cal.set(field, value);
|
||||
return pos.getIndex();
|
||||
|
||||
if (!lenient) {
|
||||
// Check the range of the value
|
||||
int32_t bias = gFieldRangeBias[patternCharIndex];
|
||||
if (bias >= 0 && (value > cal.getMaximum(field) + bias || value < cal.getMinimum(field) + bias)) {
|
||||
return -start;
|
||||
}
|
||||
}
|
||||
|
||||
cal.set(field, value);
|
||||
return pos.getIndex();
|
||||
}
|
||||
return -start;
|
||||
}
|
||||
|
|
|
@ -362,7 +362,6 @@ void DateFormatRegressionTest::Test4060212(void)
|
|||
errln((UnicodeString) "Fail: Got " + cal->get(UCAL_DAY_OF_YEAR, status) +
|
||||
" Want 40");
|
||||
|
||||
#if 0
|
||||
// this is an odd usage of "ddd" and it doesn't
|
||||
// work now that date values are range checked per #3579.
|
||||
logln("Using yyyy-ddd.hh:mm:ss");
|
||||
|
@ -379,7 +378,6 @@ void DateFormatRegressionTest::Test4060212(void)
|
|||
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");
|
||||
#endif
|
||||
|
||||
delete formatter;
|
||||
delete fmt;
|
||||
|
@ -401,8 +399,8 @@ void DateFormatRegressionTest::Test4061287(void)
|
|||
}
|
||||
failure(status, "new SimpleDateFormat");
|
||||
//try {
|
||||
logln(UnicodeString("") + df->parse("30/02/1971", status));
|
||||
failure(status, "df->parse(\"30/02/1971\")");
|
||||
logln(UnicodeString("") + df->parse("35/01/1971", status));
|
||||
failure(status, "df->parse(\"35/01/1971\")");
|
||||
//logln(df.parse("35/01/1971").toString());
|
||||
//}
|
||||
/*catch (ParseException e) {
|
||||
|
@ -412,7 +410,7 @@ void DateFormatRegressionTest::Test4061287(void)
|
|||
df->setLenient(FALSE);
|
||||
UBool ok = FALSE;
|
||||
//try {
|
||||
logln(UnicodeString("") + df->parse("30/02/1971", status));
|
||||
logln(UnicodeString("") + df->parse("35/01/1971", status));
|
||||
if(U_FAILURE(status))
|
||||
ok = TRUE;
|
||||
//logln(df.parse("35/01/1971").toString());
|
||||
|
|
|
@ -683,9 +683,8 @@ DateFormatTest::TestLetterDPattern212()
|
|||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UnicodeString dateString("1995-040.05:01:29");
|
||||
UnicodeString ddateString("1995-02-09.05:01:29");
|
||||
UnicodeString bigD("yyyy-DDD.hh:mm:ss");
|
||||
UnicodeString littleD("yyyy-MM-dd.hh:mm:ss");
|
||||
UnicodeString littleD("yyyy-ddd.hh:mm:ss");
|
||||
UDate expLittleD = date(95, 0, 1, 5, 1, 29);
|
||||
UDate expBigD = expLittleD + 39 * 24 * 3600000.0;
|
||||
expLittleD = expBigD; // Expect the same, with default lenient parsing
|
||||
|
@ -704,7 +703,7 @@ DateFormatTest::TestLetterDPattern212()
|
|||
formatter = new SimpleDateFormat(littleD, status);
|
||||
ASSERT_OK(status);
|
||||
pos = ParsePosition(0);
|
||||
myDate = formatter->parse(ddateString, pos);
|
||||
myDate = formatter->parse(dateString, pos);
|
||||
logln((UnicodeString)"Using " + littleD + " -> " + dateToString(myDate));
|
||||
if (myDate != expLittleD) errln((UnicodeString)"FAIL: littleD - Expected " + dateToString(expLittleD));
|
||||
delete formatter;
|
||||
|
|
Loading…
Add table
Reference in a new issue