[issue17486] datetime.timezone returns the wrong tzname()
Alexander Belopolsky
report at bugs.python.org
Fri Jun 7 00:33:48 CEST 2013
Alexander Belopolsky added the comment:
This is not a bug in datetime.timezone. The value returned by timezone.tzname() is documented and the code works correctly. %Z should not be used to produce machine-readable timestamps and for a human reader 'UTC+03:00+0300' should not be confusing.
Note that calling the astimezone() method (without arguments) will return local time with tzname set:
>>> os.putenv('TZ', 'XYZ-3')
>>> time.tzset()
>>> utctime = datetime.datetime.now(datetime.timezone.utc)
>>> localtime = utctime.astimezone()
>>> localtime.strftime('%Z%z')
'XYZ+0300'
----------
nosy: +belopolsky
resolution: -> invalid
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17486>
_______________________________________
More information about the Python-bugs-list
mailing list