You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide parseable repr to datetime.timezone #53246
I am attaching a python prototype. I am following the convention in place for the other datetime classes of prepending the repr with 'datetime.'. This may not be ideal, but better than to introduce an inconsistency. The only question I think is worth considering is the representation of timezone.utc. I would like to have repr(timezone(timedelta(0))) == 'datetime.timezone.utc' even though currently timezone(timedelta(0)) and timezone.utc are different but equal objects. This is going to change, however. See bpo-9051.
Activity
abalkin commentedon Jun 15, 2010
Recently added datetime.timezone class does not have a custom repr, so one gets
instead of parseable
This is inconsistent with the way other classes in datetime module behave.
abalkin commentedon Jun 15, 2010
Merged bpo-5094 nosy list.
abalkin commentedon Jul 6, 2010
I am attaching a python prototype. I am following the convention in place for the other datetime classes of prepending the repr with 'datetime.'. This may not be ideal, but better than to introduce an inconsistency. The only question I think is worth considering is the representation of timezone.utc. I would like to have repr(timezone(timedelta(0))) == 'datetime.timezone.utc' even though currently timezone(timedelta(0)) and timezone.utc are different but equal objects. This is going to change, however. See bpo-9051.
[1] http://bugs.python.org/issue5094#msg106411
abalkin commentedon Jul 6, 2010
Attaching a C patch.
abalkin commentedon Jul 6, 2010
Replacing the patch. The previously attached patch reverted bpo-9051 a bit too aggressively.
abalkin commentedon Jul 6, 2010
Committed in r82617. Python version committed to sandbox in r82616.