[issue30699] Misleading class names in datetime.tzinfo usage examples

New submission from Robert Tasarz: https://docs.python.org/3/library/datetime.html#datetime-objects gives in an example two classes named GMT1 and GMT2 subclassing tzinfo, defined with dst(…) methods returning one hour timedelta for summer periods. This is in conflict with naming, as GMT timezone is not defined with any daylight saving time, so any timezone offsetted from it shouldn't be as well. I would suggest renaming them to something like BrusselsTZ and HelsinkiTZ (with a comment that this is simplified implementation, that doesn't account for exact hour when dst switch is made, and maybe mentioning pytz) and tzname(…) to return ('CET', 'CEST')[bool(self.dst(dt))] and ('EET', 'EEST')[bool(self.dst(dt))] accordingly. Also https://docs.python.org/3/library/datetime.html#time-objects has an example with GMT1 class, though this time dst(…) unconditionally returns offset 0 properly, tzname(…) gives 'Europe/Prague' – region that uses dst. IMHO returning any of: "CET", "GMT+1", "Africa/Tunis" would be better here. ---------- assignee: docs@python components: Documentation messages: 296296 nosy: Robert.Tasarz, docs@python priority: normal severity: normal status: open title: Misleading class names in datetime.tzinfo usage examples type: enhancement versions: Python 2.7, Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue30699> _______________________________________

Change by Mario Corchero <mariocj89@gmail.com>: ---------- keywords: +patch pull_requests: +4253 stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30699> _______________________________________

Change by Mario Corchero <mariocj89@gmail.com>: ---------- nosy: +mariocj89 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30699> _______________________________________

Change by Berker Peksag <berker.peksag@gmail.com>: ---------- nosy: +belopolsky _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30699> _______________________________________

STINNER Victor <vstinner@redhat.com> added the comment: New changeset f0b5ae4567637b24035ecda93a3240efc96b6dd9 by Victor Stinner (Mario Corchero) in branch 'master': bpo-30699: Improve example on datetime tzinfo instances (GH-4290) https://github.com/python/cpython/commit/f0b5ae4567637b24035ecda93a3240efc96... ---------- nosy: +vstinner _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30699> _______________________________________

Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +13697 pull_request: https://github.com/python/cpython/pull/13811 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30699> _______________________________________

miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 12c178799a23b47c5f8ebc072cbdf09a370649ae by Miss Islington (bot) in branch '3.7': bpo-30699: Improve example on datetime tzinfo instances (GH-4290) https://github.com/python/cpython/commit/12c178799a23b47c5f8ebc072cbdf09a370... ---------- nosy: +miss-islington _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30699> _______________________________________

STINNER Victor <vstinner@redhat.com> added the comment: Thanks Mario Corchero for the doc enhancement, and Paul for the review! Python 2.7 is not affected: datetime has no timeinfo class. ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: +Python 3.7, Python 3.8 -Python 2.7, Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue30699> _______________________________________
participants (5)
-
Berker Peksag
-
Mario Corchero
-
miss-islington
-
Robert Tasarz
-
STINNER Victor