strptime in 2.3.3

Holger Joukl Holger.Joukl at LBBW.de
Thu Mar 25 08:12:19 EST 2004


Andy writes:
Folks,

I am parsing a list of directories that have a name format
'YearWeekNoDay', using the follwoing code

            print list_dir[j]
            print "%s" % (time.strptime (list_dir[j], '%Y%U%w'))
            ttuple = time.strptime (list_dir[j], '%Y%U%w')
            year   = ttuple[0]
            month  = ttuple[1]
            day    = ttuple[2]
            print day, month, year

I get the following output:

2004123
(2004, 1, 1, 0, 0, 0, 2, 1, -1)
1 1 2004

2004124
(2004, 1, 1, 0, 0, 0, 3, 1, -1)
1 1 2004

====

Are you sure you are using the correct format string?
%U is week number of year [00-53], so I am not sure what happens
if you combine that with a day of month that surely is not in this week..

Cheers
 Holger

Der Inhalt dieser E-Mail ist vertraulich. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
verständigen Sie bitte den Absender sofort und löschen Sie die E-Mail
sodann. Das unerlaubte Kopieren sowie die unbefugte Übermittlung sind nicht
gestattet. Die Sicherheit von Übermittlungen per E-Mail kann nicht
garantiert werden. Falls Sie eine Bestätigung wünschen, fordern Sie bitte
den Inhalt der E-Mail als Hardcopy an.

The contents of this  e-mail are confidential. If you are not the named
addressee or if this transmission has been addressed to you in error,
please notify the sender immediately and then delete this e-mail.  Any
unauthorized copying and transmission is forbidden. E-Mail transmission
cannot be guaranteed to be secure. If verification is required, please
request a hard copy version.





More information about the Python-list mailing list