From 42b97d1e1a3485be1b2cd859bdbec0dd385f506c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 20 Dec 2017 21:30:14 -0600 Subject: [PATCH] Add a bit more flexibility to jquery time input values i.e. for when the user hand-keys a value --- tailbone/forms2/types.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tailbone/forms2/types.py b/tailbone/forms2/types.py index 2521adec..139aa784 100644 --- a/tailbone/forms2/types.py +++ b/tailbone/forms2/types.py @@ -37,4 +37,11 @@ class JQueryTime(colander.Time): def deserialize(self, node, cstruct): if not cstruct: return colander.null - return colander.timeparse(cstruct, '%I:%M %p') + 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')