diff options
author | Paul Ganssle <paul@ganssle.io> | 2020-05-16 16:14:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-16 16:14:58 (GMT) |
commit | b17e49e0def23238b9e7f48c8a02e2d7bbf1f653 (patch) | |
tree | 76e9f172832a34e53bdb4feeeedf91c33bedc771 /Doc/whatsnew | |
parent | 1b97b9b0ad9a2ff8eb5c8f2e2e7c2aec1d13a330 (diff) | |
download | cpython-b17e49e0def23238b9e7f48c8a02e2d7bbf1f653.zip cpython-b17e49e0def23238b9e7f48c8a02e2d7bbf1f653.tar.gz cpython-b17e49e0def23238b9e7f48c8a02e2d7bbf1f653.tar.bz2 |
bpo-40503: Add documentation and what's new entry for zoneinfo (GH-20006)
This adds the documentation for the `zoneinfo` module added in PEP 615: https://www.python.org/dev/peps/pep-0615/
The implementation itself was GH-19909: https://github.com/python/cpython/pull/19909
bpo-40503: https://bugs.python.org/issue40503
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r-- | Doc/whatsnew/3.9.rst | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index bddb710..479c33b 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -205,7 +205,44 @@ Other Language Changes New Modules =========== -* None yet. +zoneinfo +-------- + +The :mod:`zoneinfo` module brings support for the IANA time zone database to +the standard library. It adds :class:`zoneinfo.ZoneInfo`, a concrete +:class:`datetime.tzinfo` implementation backed by the system's time zone data. + +Example:: + + >>> from zoneinfo import ZoneInfo + >>> from datetime import datetime, timedelta + + >>> # Daylight saving time + >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles")) + >>> print(dt) + 2020-10-31 12:00:00-07:00 + >>> dt.tzname() + 'PDT' + + >>> # Standard time + >>> dt += timedelta(days=7) + >>> print(dt) + 2020-11-07 12:00:00-08:00 + >>> print(dt.tzname()) + PST + + +As a fall-back source of data for platforms that don't ship the IANA database, +the |tzdata|_ module was released as a first-party package -- distributed via +PyPI and maintained by the CPython core team. + +.. |tzdata| replace:: ``tzdata`` +.. _tzdata: https://pypi.org/project/tzdata/ + +.. seealso:: + + :pep:`615` -- Support for the IANA Time Zone Database in the Standard Library + PEP written and implemented by Paul Ganssle Improved Modules |