[Tutor] datetime syntax error for May 8th and 9th 2008??

Che M pine508 at hotmail.com
Sat May 17 06:18:39 CEST 2008




From: pine508 at hotmail.com

To: tutor at python.org
Subject: datetime syntax error for May 8th and 9th 2008??
Date: Sat, 17 May 2008 00:09:03 -0400








Am I missing something?  Why does May 7th
and other dates work but I'm getting "invalid
token" for May 8th and 9th?  (I have not tested
many other dates of the year in this way) This 
is from a freshly begun IDLE session:

IDLE 1.2      
>>> import datetime
>>> datetime.datetime(2008,05,07)
datetime.datetime(2008, 5, 7, 0, 0)
>>> datetime.datetime(2008, 05, 08)
SyntaxError: invalid token
>>> datetime.datetime(2008, 05, 09)
SyntaxError: invalid token

After trying it a bit more, I see that writing it this way works:

>>> datetime.datetime(2008,05,8)
datetime.datetime(2008, 5, 8, 0, 0)

So, then, why can one not use YYYY-MM-DD with these two 
dates and must instead switch to YYYY-MM-D?  I have a feeling
the explanation will be interesting and somehow make sense,
though right now it seems odd.




_________________________________________________________________
Keep your kids safer online with Windows Live Family Safety.
http://www.windowslive.com/family_safety/overview.html?ocid=TXT_TAGLM_WL_Refresh_family_safety_052008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080517/e2f5ea15/attachment.htm>


More information about the Tutor mailing list