Add a bit more flexibility to jquery time input values

i.e. for when the user hand-keys a value
This commit is contained in:
Lance Edgar 2017-12-20 21:30:14 -06:00
parent 9f14d01c22
commit 42b97d1e1a

View file

@ -37,4 +37,11 @@ class JQueryTime(colander.Time):
def deserialize(self, node, cstruct):
if not cstruct:
return colander.null
try:
return colander.timeparse(cstruct, '%I:%M %p')
except ValueError:
try:
return colander.timeparse(cstruct, '%I:%M%p')
except:
# re-try first format, for "better" error
return colander.timeparse(cstruct, '%I:%M %p')