ISO to Gregorian, strptime madness

Afanasiy abelikov72 at hotmail.com
Thu Dec 4 12:51:10 EST 2003


On Thu, 04 Dec 2003 10:43:38 -0500, Peter Hansen <peter at engcorp.com>
wrote:

>Afanasiy wrote:
>> 
>> While I'm posting, how about this old dilemma... from the 2.3 modules.
>> strptime exists in time, but not in datetime, while strftime exists in
>> both. 
>
>Uh, really?

Ok, I checked it out, even though it's not my primary concern.

>Looks to me like strptime and strftime are both in time and not in datetime.

datetime the class in the datetime module has strftime but no strptime

>>> datetime.datetime.strftime
<method 'strftime' of 'datetime.date' objects>
>>> datetime.datetime.strptime
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: type object 'datetime.datetime' has no attribute
'strptime'
>>>

So... I do this sort of thing :

  t1tmp = time.strptime(sometext,timeformat)
  t1 = datetime.datetime(*t1tmp[0:6])      

-AB





More information about the Python-list mailing list