User Pyramid, Colander, and Deform, I've got a datetime widget.
datetime_event = colander.SchemaNode(
colander.DateTime(),
validator=colander.Range(
min=datetime(
2018, 1, 1, 0, 0,
tzinfo=timezone.utc),
min_err=(
'${val} must be after ${min}'),
max=datetime.now(timezone.utc),
max_err=(
'${val} is in the future, and must be less than ${max}')
),
)
I get this user-hostile validation error message.
2017-08-21 05:00:00-07:53 must be after 2018-01-01 00:00:00+00:00
I'd like to format the date without the timezone stuff:
2017-08-21 05:00:00 must be after 2018-01-01 00:00:00
Or better yet:
21 Aug 2017 5:00 AM must be after 1 Jan 2018 12:00 AM
If possible, how would I format the datetime objects in min_err
and max_err
?
Here's what I eventually used. The key was not to use the default variable
${val}
and use plain old Python f-strings.This solution also implements formatting of the date and time, and min and max dates in the pickadate UI.