We're updating the issue view to help you get more done. 

ICU4C DateFormat::setLenient very broken, will not set strict parsing


In ICU 53, control of date parse leniency was made more granular - instead of just using the leniency attribute of the DateFormat's Calendar, separate setters/getters were provided for several DateFormat-specific parse attributes as well as the Calendar's leniency. However, per discussion, the old DateFormat methods setLenient/getLenient were supposed to work basically as before for compatibility, by setting multiple attributes, or getting the AND of their settings. This works in ICU4J but not in ICU4C, whose setLenient method is currently this:

1 2 3 4 5 6 7 8 9 10 void DateFormat::setLenient(UBool lenient) { if (fCalendar != NULL) { fCalendar->setLenient(lenient); UErrorCode status = U_ZERO_ERROR; setBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, true, status); setBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, true, status); } }

The setBooleanAttribute calls pass true instead of lenient as they should, and as in ICU4J below:

1 2 3 4 5 6 public void setLenient(boolean lenient) { calendar.setLenient(lenient); setBooleanAttribute(BooleanAttribute.PARSE_ALLOW_NUMERIC, lenient); setBooleanAttribute(BooleanAttribute.PARSE_ALLOW_WHITESPACE, lenient); }

Since in ICU4C the default setting is lenient for all of these, this means that backward compatibility for setLenient(FALSE) is broken, it will not set strict parsing behavior. This is likely to cause problems for existing clients.



Yoshito Umaoka


Peter Edberg


Fix versions