time.strftime()

jsaul jsaul at gmx.de
Mon Mar 10 10:28:38 CET 2003


Hi there,

I have a problem when using time.strftime() to compose a RFC822
date, namely the printed time zone is incorrect:

>>> time.strftime("%a, %d %b %Y %H:%M:%S %z", time.localtime())
'Mon, 10 Mar 2003 10:26:51 +0000'

It should be '+0100' because this is CET time zone:
>>> time.strftime("%Z",time.localtime())
'CET'

>>> time.timezone
-3600
>>> time.strftime("%a, %d %b %Y %H:%M:%S %z", time.gmtime())
'Mon, 10 Mar 2003 09:26:54 +0000'

This is all correct. But I don't want to go via 'time.timezone'
to get the proper offset into the date string. Unless the above
behaviour is a bug, I must have overlooked something, but what?

Cheers,
jsaul




More information about the Python-list mailing list