The line of code: date=DateTime('2003/13/03') causes zope to try to create a date variable based on the string '2003/13/03'. Zope will try a variety of formats to find one that works (zope does not know that you want yyyy/mm/dd, it just tries to make it work). The line of code: print date.strftime("%Y %B %d") just takes a date variable and prints it out according to the format supplied ("%Y %B %d"). There is no relationship between the two lines of code (ie. the second line of code does not supply the format that you want the first line of code to use). There is a function called strptime in the python Time module that will parse a string according to a given format. I have never used it, but you can find a description of this routine in the Python Library Reference manual. Jonathan ----- Original Message ----- From: Philippe Vignaux To: zope@zope.org Sent: November 24, 2003 9:37 AM Subject: [Zope] date formats Hi all ! . can't get rid off my dates problems .. I would like the following python statements to apply validity checks on a date always inputed under format YYYY / MM / DD (GMT+1) The 2 first examples behaves as expected. The last one not. try: date=DateTime('2003/07/03') print date.strftime("%Y %B %d") except: print 'error' return printed 2003 July 03 (OK) try: date=DateTime('2003/03/07') print date.strftime("%Y %B %d") except: print 'error' return printed 2003 March 07 (OK) try: date=DateTime('2003/13/03') print date.strftime("%Y %B %d") except: print 'error' return printed 2003 March 13 (NOK) While I'm expecting an error (no months with id 13 !!!) it reverses the month part and the day part !! Why ?? Is that the normal behaviour ?? Or is there any parameter to provide so that python knows the format is always YYYY / MM / DD (the setup: Windows 2000 server Zope 2.6.2 python 2.1 ) Thanks for any help ! Phil. ------------------------------------------------------------------------------ _______________________________________________ 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 )