[tz] IANA timezone database - request to add Omaha, Nebraska
Paul Eggert
eggert at cs.ucla.edu
Tue Jul 26 18:13:30 UTC 2022
On 7/26/22 04:45, Florian Weimer via tz wrote:
> How does this system implement a programming interface that enumerates
> the TZ rules? The typical way is to use readlink to get the IANA
> identifier, and then use that to look up the rules in the zic input file
> (because the compiled blobs lack this information).
It depends on what "TZ rules" means.
If it means the Rule lines in .zi files, that's not intended for
end-user consumption. That information is absent from the TZif files
output by zic. So I doubt whether you meant that.
If it means the TZ strings at the end of TZif files, then that would be
determined by enumerating all the TZif files and looking at their
contents. But this means one first needs to enumerate all the TZif file
names which is begging the question.
If it means to enumerate all the supported Zone and Link names, then on
a pre-2017c implementation that would mean recursively looking for all
TZif files under /usr/share/zoneinfo (or whatever) and discarding names
of non-TZif files. Although doable, this is awkward. A simpler way with
2017c-and-later is to read /usr/share/zoneinfo/tzdata.zi and look for
Link and Zone lines.
If it means to enumerate only Zones and omit Links, which is what I
think you mean, then readlink will work only if Links are implemented
via symbolic links. Although Debian and Red Hat based systems do that,
the default TZDB installation does not (it uses hard links), and Alpine,
macOS, NetBSD, OpenBSD, OpenSUSE etc. use the default either because it
is the default or because it is a bit more efficient. (FreeBSD uses
neither hard nor symbolic links: it uses copies and I don't know why.)
And I think Android has its own scheme where all the entries are in a
single file. So although readlink is common, I wouldn't call it "typical".
A good way to enumerate only Zones with 2017c-and-later is to read the
installed tzdata.zi file and look for Zone lines. Unfortunately only
some systems (e.g., Debian, Red Hat) install tzdata.zi; however, as a
reasonable substitute one can use the third column of zone1970.tab, as
this enumerates all but legacy Zones like CST6CDT, Etc/GMT+10, and
Factory. Reading tzdata.zi and/or zone1970.tab should be more portable
and faster than issuing readlink calls.
Distros like FreeBSD should consider installing tzdata.zi as that will
make it easier for applications to enumerate all supported Zone and Link
names, as well as do other things.
More information about the tz
mailing list