[Zope] Validating a Date

Oliver Bleutgen myzope@gmx.net
Thu, 06 Mar 2003 02:48:18 +0100


Peter Bengtsson wrote:
> At 02:01 2003-02-28 -0600, Edward Muller wrote:
> 
>> Does anyone know of a good module/product/hack that I can feed a date to
>> and it will let me know if it's valid or not?
>>
>> It should check leap years ... end days of the month and the like...
> 
> 
> try:
>     ok_date = context.ZopeTime('2003/13/13')
>     print "Yes, date OK"
> except:
>     print "No, not OK"
> 
> return printed

Nope, ZopeTime(DateTime) is very (too) liberal in what it accepts for 
this purpose:

context.ZopeTime('2002/30/3')

returns "2002/03/30"

cheers,
oliver