Bug in time module - %z works in perl, not in python?

bwooster47 at gmail.com bwooster47 at gmail.com
Wed Feb 21 21:17:59 EST 2007


Following python code prints out incorrect UTC Offset - the python
docs say that %z is not fully supported on all platforms - but on
Linux Fedora FC5, perl code works and python does not - is this a bug
or is this expected behavior? For a EST timezone setup, Perl prints
correct -0500, while Python prints +0000 - this is Python 2.4.

Perl:
$now_string = strftime "%Y-%m-%d %H:%M:%S %Z%z", localtime;
print $now_string, "(iso local)\n";

2007-02-21 21:16:16 EST-0500 (iso localtime, perl)

Python:
now_string = time.strftime("%Y-%m-%d %H:%M:%S %Z%z", time.localtime())
print now_string, " (iso localtime, python)"

2007-02-21 21:15:58 EST+0000  (iso localtime, python)

Is this expected behavior, or a bug?




More information about the Python-list mailing list