[tz] Proper (stable) way to list installed time zones?

Paul Ganssle paul at ganssle.io
Wed May 13 18:19:23 UTC 2020


As part of the implementation of IANA time zone support in the Python
standard library (which is now accepted
<https://www.python.org/dev/peps/pep-0615/> for inclusion in Python 3.9
— many thanks to those who commented on the original proposal), I
realized that likely a common feature request is to get the list of time
zones installed in the system. I have a candidate implementation
<https://github.com/pganssle/zoneinfo/pull/60> for this, which basically
walks each potential install directory (there's a "time zone search
path" equivalent to PATH) and populates a list of every file installed
there which starts with the `TZif` magic string.

The problem I'm running into is that tzcode installs `posix/` and
`right/` folders, so for each entry in zoneinfo, I get three entries:
"Africa/Abidjan", "posix/Africa/Abidjan" and "right/Africa/Abidjan". I'm
also seeing a `posixrules` zone in the zoneinfo root.

My questions are:

1. Is there a better source for the list of installed time zones
(leaving aside `tzdata.zi`, which I don't think I can count on to exist
in all environments).
2. Is there any stable and standard way to distinguish between proper
zones and other things that are also zone files like posixrules and
right/ and posix/?

In my own redistribution of the data, I populate a list of zones from
`make zonenames`, which I note does /not/ include posix/, right/ or
posixrules, but I don't think that information is included in standard
distributions of zoneinfo. The closest I can find is `zone1970.tab` and
`zone.tab` (which I think is not even always included), and that appears
to be only a subset of the output of `make zonenames`.

Thanks,
Paul

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20200513/2882a0d2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://mm.icann.org/pipermail/tz/attachments/20200513/2882a0d2/signature.asc>


More information about the tz mailing list