diff --git a/tailbone/forms2/types.py b/tailbone/forms2/types.py index 139aa784..977b8bc6 100644 --- a/tailbone/forms2/types.py +++ b/tailbone/forms2/types.py @@ -37,11 +37,18 @@ 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: + + formats = [ + '%I:%M %p', + '%I:%M%p', + '%I %p', + '%I%p', + ] + for fmt in formats: try: - return colander.timeparse(cstruct, '%I:%M%p') - except: - # re-try first format, for "better" error - return colander.timeparse(cstruct, '%I:%M %p') + return colander.timeparse(cstruct, fmt) + except ValueError: + pass + + # re-try first format, for "better" error message + return colander.timeparse(cstruct, formats[0])