On Feb 21, 6:17 pm, [EMAIL PROTECTED] wrote: > 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?
Seems to be a bug. I can duplicate the problem here (Python 2.4.3, Red Hat Desktop release 4). I do see the correct output, however, if I pass just the format string to strftime: >>> print time.strftime("%Y-%m-%d %H:%M:%S %Z %z") 2007-02-21 18:42:03 PST -0800 >>> print time.strftime("%Y-%m-%d %H:%M:%S %Z %z", time.localtime()) 2007-02-21 18:42:11 PST +0000 -- Hope this helps, Steven -- http://mail.python.org/mailman/listinfo/python-list