[Bug 1884458] Re: pytz mishandles Africa/Khartoum in 2017

Stuart Bishop 1884458 at bugs.launchpad.net
Mon Jul 6 07:10:43 UTC 2020


The (awful) API provided by pytz and the requirement for localize() is
there for legacy reasons. At the time, it was the only way to get the
Python datetime library to do what was needed to get cross-timezone, DST
aware arithmetic working. The future is the new built-in support in
Python 3.9, available as a backport to earlier Python versions at
https://pypi.org/project/backports.zoneinfo/

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python-tz in Ubuntu.
https://bugs.launchpad.net/bugs/1884458

Title:
  pytz mishandles Africa/Khartoum in 2017

Status in pytz:
  New

Bug description:
  Here's a scenario illustrating the bug, on Fedora 31:

  $ python3
  Python 3.7.7 (default, Mar 13 2020, 10:23:39) 
  [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import datetime
  >>> import pytz
  >>> print(datetime.datetime(2017,10,31, tzinfo=pytz.timezone('Africa/Khartoum')))
  2017-10-31 00:00:00+02:10

  That "+02:10" is incorrect, as Khartoum was 3 hours ahead of UTC, not
  2 hours and 10 minutes ahead of UTC. GNU 'date' gets it right:

  $ TZ=Africa/Khartoum date -d'2017-10-31' +'%Y-%m-%d %H:%M:%S %z'
  2017-10-31 00:00:00 +0300

  For more, see:

  https://stackoverflow.com/questions/62501007/pytz-giving-wrong-
  timezone-offset-for-africa-khartoum

To manage notifications about this bug go to:
https://bugs.launchpad.net/pytz/+bug/1884458/+subscriptions



More information about the foundations-bugs mailing list