[Python] Why does zoneinfo available_timezones include links?

Discussão em 'Python' iniciado por Stack, Julho 29, 2025.

  1. Stack

    Stack Membro Participativo

    I'm looking for a list of canonical timezone names. In my mind, "canonical" means that there is exactly one name for each zone. For example, America/New_York is the canonical zone name, and US/Eastern is a link to it, as shown in the tzdata.zi file inside tzdata:

    Z America/New_York -4:56:2 - LMT 1883 N 18 17u
    L America/New_York US/Eastern


    The zoneinfo documentation says it has a function for this:


    zoneinfo.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.
    ​

    However, that function returns a list of 598 items, including both the zones and the links. It seems like it's not parsing anything at all, just returning the full list.

    I'm using Python 3.13.5 on MacOS and I have tzdata installed.

    Continue reading...

Compartilhe esta Página