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);
}
}
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;
}
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");
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;
}
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) {
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());
{
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
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;