This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Maksym Shalenyi (Enkidulan)
Recipients Maksym Shalenyi (Enkidulan)
Date 2018-08-14.18:18:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1534270684.14.0.56676864532.issue34407@psf.upfronthosting.co.za>
In-reply-to
Content
In some cases datetime.time.isoformat shows timezone info, but in some does not. Consider the example below.

import datetime
import pytz

t = dict(hour=12, minute=31, second=21, microsecond=213456)

# `datetime.time.isoformat` has inconsistent behavior. Some of printed has timezone, but others does not.
print(datetime.time(tzinfo=pytz.timezone('Asia/Seoul'), **t).isoformat())
print(datetime.time(tzinfo=pytz.timezone('Etc/GMT-9'), **t).isoformat())
print(datetime.time(tzinfo=pytz.timezone('Australia/Sydney'), **t).isoformat())
print(datetime.time(tzinfo=pytz.timezone('Etc/UTC'), **t).isoformat())
# output:
# 12:31:21.213456
# 12:31:21.213456+09:00
# 12:31:21.213456
# 12:31:21.213456+00:00



# `datetime.time.isoformat` is inconsistent with `datetime.datetime.isoformat`. `datetime` objects always shows tz information when tz is present.
d = dict(year=2018, month=2, day=2, **t)
print(datetime.datetime(tzinfo=pytz.timezone('Asia/Seoul'), **d).isoformat())
print(datetime.datetime(tzinfo=pytz.timezone('Etc/GMT-9'), **d).isoformat())
print(datetime.datetime(tzinfo=pytz.timezone('Australia/Sydney'), **d).isoformat())
print(datetime.datetime(tzinfo=pytz.timezone('Etc/UTC'), **d).isoformat())
# output:
# 2018-02-02T12:31:21.213456+08:28
# 2018-02-02T12:31:21.213456+09:00
# 2018-02-02T12:31:21.213456+10:05
# 2018-02-02T12:31:21.213456+00:00
History
Date User Action Args
2018-08-14 18:18:04Maksym Shalenyi (Enkidulan)setrecipients: + Maksym Shalenyi (Enkidulan)
2018-08-14 18:18:04Maksym Shalenyi (Enkidulan)setmessageid: <1534270684.14.0.56676864532.issue34407@psf.upfronthosting.co.za>
2018-08-14 18:18:04Maksym Shalenyi (Enkidulan)linkissue34407 messages
2018-08-14 18:18:03Maksym Shalenyi (Enkidulan)create