Why don't you use try .. except ? python: try: x = DateTime(...) except: x = None In DTML you have dtml-try .. dtml-except Dragos ----- Original Message ----- From: "Jeff Nielsen" <Jeff@UgoFast.com> To: "Andreas Jung" <andreas@andreas-jung.com>; <zope@zope.org> Sent: Monday, September 22, 2003 6:22 PM Subject: RE: [Zope] How do I test a date to be valid? I was working on that. How do I catch the exception before it becomes an error? I saw something in the various docs about DateTime.DateTimeError, but I can't figure out how to implement it. Jeff Nielsen http://www.UgoFast.com -----Original Message----- From: Andreas Jung [mailto:andreas@andreas-jung.com] Sent: Sunday, September 21, 2003 11:00 PM To: Jeff Nielsen; zope@zope.org Subject: Re: [Zope] How do I test a date to be valid? pass it to DateTime(). It should raise an exception for wrong dates. -aj --On Sonntag, 21. September 2003 22:54 Uhr -0700 Jeff Nielsen <Jeff@UgoFast.com> wrote:
When a user inputs a date from a form, how can I test it to be valid? I'd want 01/15/2003 to test as valid, but 02/31/2003 to test as false.
Jeff Nielsen http://www.UgoFast.com
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )