How to check the date validity?

gregor gregor at ediwo.com
Tue Dec 24 11:14:11 CET 2013


Am Mon, 23 Dec 2013 16:30:35 -0800
schrieb Igor Korot <ikorot01 at gmail.com>:

> 
> Now, it looks that the python way of validating the date/time of the
> string is to call strptime(). However looking at the docs and trying
> to use the function I didn't find a way to check for the milliseconds.
> Now the dates can be formatted differently I think according to the
> locale under which the csv is generated.

you can also use an validator package like formencode:

http://www.formencode.org/en/latest/Validator.html

It has an TimeConverter but it does not understand milliseconds either.
But it should be trivial to implement it based on TimeConverter.

Using formencode the validation / conversion is seperated and therefore reusable.
You also get nice human readable validation messages in different languages.
It supports also Schemas to validate complete records.

--
Greg




More information about the Python-list mailing list