strptime on Unix systems

Niels Diepeveen niels at endea.demon.nl
Fri Dec 24 14:29:22 EST 1999


Malcolm Tredinnick schreef:
> 
> On Wed, Dec 22, 1999 at 04:46:27PM -0500, Justin Sheehy wrote:
> > "Malcolm Tredinnick" <malcolmt at smart.net.au> writes:
> >
> > > 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())

<snip>

> My conclusions from this (and private emails a few have sent me):
> (1) The problem is with the Linux library

Not really. It's standard UNIX. Take a look at
http://www.opengroup.org/onlinepubs/7908799/xsh/strftime.html
and
http://www.opengroup.org/onlinepubs/7908799/xsh/strptime.html

I can think of at least two reasons for the omission of %Z from standard
strptime():
1. There is AFAIK no universally accepted standard for naming time
zones. This would make it hard to parse a time zone field reliably.
2. If it did parse the time zone, what would it do with it? strftime()
just gets the local time zone name from a global variable. If strptime()
did the reverse, it might throw the whole program into a time warp.

So, on the whole it's not very clear what %Z should do. BTW, what does
it do on BSD?

-- 
Niels Diepeveen
Endea automatisering




More information about the Python-list mailing list