This is the last major version of dateutil that will support any version of Python older than 3.11. The next release will be the 4.x series, which will support Python 3.11 and later. We may release fixes for serious bugs in the 3.0.x series, but there are no plans for new features there.
The biggest change in this release is a rewrite of tz.tzfile, which affects nearly every user of dateutil.tz and changes the UTC offset of nonexistent times (see below). dateutil also now depends on the tzdata package, and no longer ships its own time zone database.
Data updates
dateutilno longer bundles a copy of the IANA time zone database. Time zone data now comes from the system (seedateutil.tz.TZPATH) or, failing that, from the newtzdatadependency, so the data version is whatever version oftzdatais installed. (gh pr #1130)
Features
- Rewrote
tz.tzfilebased on a backport of thezoneinfomodule's pure-Python implementation. This adds support for Version 2 and Version 3tzfile(5)binaries, resolving issues with timestamps beyond 2038 and "slim" format binaries. (gh issues #462, #1059, gh pr #1130) - Added
dateutil.tz.TZPATHanddateutil.tz.reset_tzpathto allow for runtime configuration of the IANA time zone data search path. These replace the mutabledateutil.tz.TZPATHSlist, which has been removed. (gh pr #1130) dateutilnow depends on thetzdatapackage, whichgettzconsults after the search path and before the Windows registry. On Windows this means that names that are both IANA keys and Windows time zone names, such as"UTC", now return atzfilerather than atzwin. (gh pr #1130)
Bugfixes
tz.tzfilenow follows PEP 495 for times that fall in a gap: withfold=0it uses the offset from before the transition, and withfold=1the offset from after it. Previously it always used the offset from after the transition, so for exampledatetime(2003, 4, 6, 2, 30, tzinfo=tz.gettz("America/New_York"))had a UTC offset of -04:00, where it now has -05:00, the same as withzoneinfo. (gh pr #1130)tz.tzfileobjects for fixed-offset zones, such astz.gettz("UTC"), now return their offset, DST offset and abbreviation whenutcoffset,dstandtznameare called withNone, astz.tzutc,tz.tzoffsetandzoneinfo.ZoneInfodo. This means thatdatetime.timeobjects with such a zone attached are now aware:time(12, tzinfo=tz.gettz("UTC")).isoformat()is now"12:00:00+00:00"rather than"12:00:00". (gh pr #1130)tz.tzfilenow infersdst()from the standard time on both sides of each DST period, rather than only the one before it, and does so for each transition rather than for each local time type. This fixesdst()for double summer time (e.g. inEurope/Londonin the 1940s), for half-hour DST (e.g. inPacific/Rarotonga) and where the standard offset changed at the same time as a DST transition (e.g. inAmerica/Bahia_Banderasin 2010). Against the standard offsets in the tz database source, the only remaining errors are inEurope/Parisin 1944 and 1945. (gh pr #1130)- Fixed
rrulestrraisingValueErroron experimentalX-parameters in anRRULEline (such as GNOME Evolution'sX-EVOLUTION-ENDDATE); these are now ignored as RFC 5545 permits. Fixed by @yajo (gh pr #1374) - Enabled pickling and deepcopy of cached
rruleandrrulesetinstances. The cache setting is preserved, and cached results are regenerated on demand without copying locks or generators. Reported by @niccokunzmann (gh issue #1369). Fixed by @Jay1023CN (gh pr #1600). - Fixed
relativedelta.__ne__raisingTypeErrorwhen comparing against an unsupported type such asNone; it now returnsTrue. Reported and fixed by @kevinkt1 (gh issue #1157, gh pr #1158) - Raised the minimum version of
sixto 1.6, fixingNo module named 'six.moves'errors with older versions. Reported by @skytreader (gh issue #1415), fixed by @jdarias3 (gh pr #1424).
Deprecations
- Deprecated the
dateutil.zoneinfomodule. The module now acts as a wrapper around thetzdatapackage and will be removed in a future version. Users are encouraged to migrate todateutil.tz.gettzor the standard library'szoneinfomodule.dateutil.zoneinfo.rebuild.rebuildno longer does anything, and by default raisesRebuildDeprecationWarningas an error; filter the warning to call it as a no-op. (gh pr #1130) - Deprecated passing
gettza relative key that refers to a file outside of every directory onTZPATH, such as"../../etc/localtime". By default this now raisesdateutil.tz.DeprecatedTzKeyWarningas an error; filter the warning to keep the old behavior for now, or pass an absolute path instead. (gh pr #1130)
Documentation changes
- Added intersphinx to the docs build and cleaned up some broken links. (gh pr #1463)
Misc
- Releases are now uploaded to PyPI using trusted publishing, and the built sdist and wheel are tested on all supported platforms before upload. (gh pr #1619, #1622)
- Changes to CI, tests and release tooling that do not affect users of the package: gh pr #1417, #1462, #1464, #1465, #1466, #1467, #1468, #1469, #1470, #1499, #1501, #1504, #1576, #1577, #1578, #1581, #1585.