Use Formencode TimeConverter validators but do not convert

57 views Asked by At

I'd like all the validation abilities of http://www.formencode.org/en/1.2-branch/modules/validators.html#formencode.validators.TimeConverter but do not want the value to actually be converted into (h, m, s) format. So I want to be able to input 09:45 or 17:00, etc. and have all the validation, but to save to the DB as I entered, not as (9, 45, 0) or (17, 0, 0).

1

There are 1 answers

0
user1087973 On

You can actually do TimeConverter(use_datetime=True). Although setting that always saves the seconds, even if they are optional. If you didn't pass in seconds like 09:30, it saves 09:30:00 to the DB.