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

Paul Ganssle paul at ganssle.io
Fri May 15 14:39:04 UTC 2020


This is very tough, because there are a lot of plausible subsets that
someone could want, and there are not good names for them all (nor, it
seems, do they all have a foolproof method of detection). I'd say one
could easily want:

1. Every valid value for key that doesn't raise an error when you call
ZoneInfo(key)
2. All the values found in tzdata.zi
3. The intersection of the values found in tzdata.zi and the keys that
actually exist on disk
4. All the values from zone.tab and/or zone1970.tab
5. The intersection of #4 and all the keys that actually exist on disk
6. #4 or #5, but also including "UTC" (and possibly the fixed-offset
zones like Etc/GMT+5 or whatever)

My inclination would be to compile a list of zones annotated with each
entry's membership in each of these groups and let the end user filter
as desired, but that's slightly complicated by the fact that almost all
the indicators other than #1 may be manipulated by the install
mechanism, and it becomes hard to distinguish between "not present in
tzdata.zi" and "tzdata.zi not shipped".

That said, it sounds to me like we can probably safely say that it is
unlikely that we won't have to special case any names of folders or
files /other/ than posixrules, posix/ and right/ for the foreseeable
future and that if distros rename those files but still put them under
the zoneinfo root, that's probably safely considered a bug in the distro.

I'm still mildly uncertain as to whether it's possible that tzdata.zi
might have more zones than are actually installed (for example if a
distro doesn't install anything in backward or antarctica for some reason).

With regards to this:

> If you also want the leap-second entries, you'll need the right/* entries though.

Is it always the case that the right/ and posix/ trees are identical to
the primary tree? If so, it's reasonable to leave right/ and posix/ out
of the listings and users can know that if they want the right/*
entries, they can just prepend "right/" to any given key.

Best,
Paul

On 5/15/20 9:43 AM, Filipe Laíns wrote:
> On Wed, 2020-05-13 at 19:13 -0700, Paul Eggert wrote:
>> Yup. The method I'd suggest is tzdata.zi if available, or the "shorter list"
>> mentioned above, whichever's faster. This is because zone1970.tab and zone.tab
>> don't list some of the duplicates, and some users like the duplicates.
>>
>> If you also want the leap-second entries, you'll need the right/* entries though.
> I am thinking the best approach should be reading tzdata.zi when
> available, and potentially fallback to ignoring posix/* and
> right/* and posixrules. I am not sure about this last one though, for
> reasons outlined in the PR. What do you think Paul (G.)?
>
> Filipe Laíns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20200515/b8f3f6b5/attachment.htm>
-------------- 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/20200515/b8f3f6b5/attachment.sig>


More information about the tz mailing list