Date validation
Andrew Bennetts
andrew-pythonlist at puzzling.org
Fri Apr 25 04:06:58 EDT 2003
On Fri, Apr 25, 2003 at 09:48:56AM +0200, Fredrik Lundh wrote:
> James Gregory wrote:
>
> > I mean I *could* write this myself, but I had to ask the computer how
> > many days in April - someone with a better grasp of the date must have
> > written this stuff before :)
>
> don't you have any knuckles on your left hand?
And which knuckles do you use to remember which years are leap years? ;)
> if you want your program to check how many days there are in
> a given month, use the calendar module:
He does. In his words: "how can I check whether or not such strings
represent a valid date?"
His problem is verifying that the entire date is correct. By the time you
factor in the varying days of the months and leap years, I can understand
wanting to use a prewritten and tested module rather than an ad-hoc solution
for a problem that many people must have encountered before.
-Andrew.
More information about the Python-list
mailing list