21

I would like to have a list of all the timezones in my system's zoneinfo database (note : system is a debian strecth linux)

The current solution I have is : list all paths under /usr/share/zoneinfo/posix, which are either plain files or symlinks

cd /usr/share/zoneinfo/posix && find * -type f -or -type l | sort

I am not sure, however, that each and every known timezone is mapped to a path under this directory.

Question

Is there a command which gives the complete list of timezones in the system's current zoneinfo database ?

LeGEC
  • 315
  • 1
  • 2
  • 7

2 Answers2

22

On Debian 9, your command gave me all of the timezones listed here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Additionally, systemd provides timedatectl list-timezones, which outputs a list identical to your command.

As far as I know, the data in tzdata is provided directly from IANA:

This package contains data required for the implementation of
 standard local time for many representative locations around the
 globe. It is updated periodically to reflect changes made by
 political bodies to time zone boundaries, UTC offsets, and
 daylight-saving rules.

So just keep the tzdata package updated.

  • 1
    Yes, nowadays IANA is the canonical distribution point for the tz database. – fpmurphy Mar 03 '19 at 05:14
  • 1
    Would LOVE to use this for a script....Lacks compatibility with WSL unfortunately because it depends on systemd. Guess I figured you could grep out the timezone list from tzdata. Wonder why something so simple is not available. – Lon Kaut Aug 26 '20 at 14:24
6

If you want to retrieve the list on a system which does not use systemd here is an awk script which I have derived from the implementation of timedatectl list-timezones:

awk '/^Z/ { print $2 }; /^L/ { print $3 }' /usr/share/zoneinfo/tzdata.zi

Pipe its output into sort and you get almost the identical result as timedatectl list-timezones.

  • 1
    Note that Debian only started installing /usr/share/zoneinfo/tzdata.zi with tzdata version 2019c-2. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=940852 https://salsa.debian.org/glibc-team/tzdata/-/commit/f3e93f5967e90a8480be734bd0136562ac69737c – therealneil Dec 21 '22 at 22:41