[Tutor] Date validation?

W W srilyk at gmail.com
Thu Nov 6 20:33:51 CET 2008


On Thu, Nov 6, 2008 at 1:27 PM, Eric Dorsey <dorseye at gmail.com> wrote:

> Greetings,I have a program where I ask a user to enter a date in format
> YYYY-MM-DD, and get a string like: '2008-10-25'
>
> Can anyone tell me how I would verify this is a real date before allowing
> it to be passed on to the next part of the program?
>

I guess it depends on what your definition of "real date" is... Should the
year fall in a certain range? How about the month and day?

Are you going to require - between each element? Do you know how to split a
string and convert the elements to integers?

That should give you some clues to your solution...
HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081106/e5be6410/attachment.htm>


More information about the Tutor mailing list