cubicweb #1251804 handle input with wrong format in datetime fields [resolved]

In the current version (but this was the case in 3.8.x and probably earlier too), if I give a date with the wrong format (e.g. 01/02/2010 instead of 2010/02/01), the error is not displayed in a nice fashion, because the raw ValueError is caught at a high level:

2010-09-16 11:31:54 - (cubicweb.web) ERROR: unexpected error while validating form
Traceback (most recent call last):
 File "/home/alf/cubicweb/cubicweb/web/views/", line 213, in _validate_form
 File "/home/alf/cubicweb/cubicweb/web/views/", line 108, in publish
 File "/home/alf/cubicweb/cubicweb/web/views/", line 131, in _default_publish
   eid = self.edit_entity(formparams)
 File "/home/alf/cubicweb/cubicweb/web/views/", line 207, in edit_entity
   if field.has_been_modified(form):
 File "/home/alf/cubicweb/cubicweb/web/", line 451, in has_been_modified
   if field._has_been_modified(form):
 File "/home/alf/cubicweb/cubicweb/web/", line 477, in _has_been_modified
   new_value = self.process_form_value(form)
 File "/home/alf/cubicweb/cubicweb/web/", line 491, in process_form_value
   value = form.formvalues[(self, form)] = self._process_form_value(form)
 File "/home/alf/cubicweb/cubicweb/web/", line 496, in _process_form_value
   value = widget.process_field_data(form, self)
 File "/home/alf/cubicweb/cubicweb/web/", line 656, in process_field_data
   date = todatetime(req.parse_datetime(datestr, 'Date'))
 File "/home/alf/cubicweb/cubicweb/", line 374, in parse_datetime
   % {'value': value, 'format': format})
ValueError: can't parse u'1/10/2009' (expected %Y/%m/%d)

The exception needs to be caught somewhere in that stack and converted to something nicer such as ValidationError which is handled by the ui layer.

done in3.9.7
load left0.000
closed by<not specified>