summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorPaul Ganssle <paul@ganssle.io>2020-05-18 01:55:11 (GMT)
committerGitHub <noreply@github.com>2020-05-18 01:55:11 (GMT)
commite527ec8abe0849e784ce100f53c2736986b670ae (patch)
tree1b638f564cbb69517ba7d9a5fe5d1cbd225bff40 /Doc/library
parent9681953c99b686cf23d1c476a2b26d2ddbec7694 (diff)
downloadcpython-e527ec8abe0849e784ce100f53c2736986b670ae.zip
cpython-e527ec8abe0849e784ce100f53c2736986b670ae.tar.gz
cpython-e527ec8abe0849e784ce100f53c2736986b670ae.tar.bz2
bpo-40536: Add zoneinfo.available_timezones (GH-20158)
This was not specified in the PEP, but it will likely be a frequently requested feature if it's not included. This includes only the "canonical" zones, not a simple listing of every valid value of `key` that can be passed to `Zoneinfo`, because it seems likely that that's what people will want.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/zoneinfo.rst23
1 files changed, 23 insertions, 0 deletions
diff --git a/Doc/library/zoneinfo.rst b/Doc/library/zoneinfo.rst
index d8e2796..1b6f2e7 100644
--- a/Doc/library/zoneinfo.rst
+++ b/Doc/library/zoneinfo.rst
@@ -337,6 +337,29 @@ pickled in an environment with a different version of the time zone data.
Functions
---------
+.. function:: available_timezones()
+
+ Get a set containing all the valid keys for IANA time zones available
+ anywhere on the time zone path. This is recalculated on every call to the
+ function.
+
+ This function only includes canonical zone names and does not include
+ "special" zones such as those under the ``posix/`` and ``right/``
+ directories, or the ``posixrules`` zone.
+
+ .. caution::
+
+ This function may open a large number of files, as the best way to
+ determine if a file on the time zone path is a valid time zone is to
+ read the "magic string" at the beginning.
+
+ .. note::
+
+ These values are not designed to be exposed to end-users; for user
+ facing elements, applications should use something like CLDR (the
+ Unicode Common Locale Data Repository) to get more user-friendly
+ strings. See also the cautionary note on :attr:`ZoneInfo.key`.
+
.. function:: reset_tzpath(to=None)
Sets or resets the time zone search path (:data:`TZPATH`) for the module.