strptime on Unix systems
Oleg Broytmann
phd at phd.russ.ru
Wed Dec 22 04:41:04 EST 1999
On Wed, 22 Dec 1999, Malcolm Tredinnick wrote:
> The following does *not* work under Linux (at least):
>
> import time
> format = '%a %b %d %H:%M:%S %Z %Y'
> t = time.localtime(time.time())
> timestring = time.strftime(format, tt) # Works OK
> timetuple = time.strptime(tt, format) # Throws ValueError
>
> The reason for this problem is that strftime and strptime are based on their
> C-library counterparts and according the man pages, while strftime does take a
> %Z modifier in the format string, strptime does NOT understand this modifier.
> (so you can remove the %Z from format and the above snippet is fine.)
>
> Two questions:
> (1) What is the story on other Unix systems? Is this a general problem (I hope
> not)?
I've tested your program (replaced "t =" with "tt =") on pentium linux,
freebsd and sprac solaris. All the same ValueError...
Oleg.
----
Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list