Timezone – How to Get the Rules

timezone

How can I see my current timezone rules?

I found out about to set it (tzdata, zic, /etc/timezone) but not how to go the other direction. (The files in /usr/share/zoneinfo are binary and I can't read them; maybe they got compiled with zic?)

How do I know if and what TZ rules are in place (for example, the switch to/from DST)?

Best Answer

You already know about zic, which compiles source zone files to the binaries you see in /usr/share/zoneinfo. Tucked away at the bottom of the man page is a reference to zdump, and this turns out to the tool you may be looking for (zdump - time zone dumper).

Here's some example output for the timezone used in France, showing the DST jump date/time for the two years 2017 and 2018.

zdump -V -c 2017,2019 Europe/Paris
Europe/Paris  Sun Mar 26 00:59:59 2017 UT = Sun Mar 26 01:59:59 2017 CET isdst=0 gmtoff=3600
Europe/Paris  Sun Mar 26 01:00:00 2017 UT = Sun Mar 26 03:00:00 2017 CEST isdst=1 gmtoff=7200
Europe/Paris  Sun Oct 29 00:59:59 2017 UT = Sun Oct 29 02:59:59 2017 CEST isdst=1 gmtoff=7200
Europe/Paris  Sun Oct 29 01:00:00 2017 UT = Sun Oct 29 02:00:00 2017 CET isdst=0 gmtoff=3600
Europe/Paris  Sun Mar 25 00:59:59 2018 UT = Sun Mar 25 01:59:59 2018 CET isdst=0 gmtoff=3600
Europe/Paris  Sun Mar 25 01:00:00 2018 UT = Sun Mar 25 03:00:00 2018 CEST isdst=1 gmtoff=7200
Europe/Paris  Sun Oct 28 00:59:59 2018 UT = Sun Oct 28 02:59:59 2018 CEST isdst=1 gmtoff=7200
Europe/Paris  Sun Oct 28 01:00:00 2018 UT = Sun Oct 28 02:00:00 2018 CET isdst=0 gmtoff=3600

To get the DST jumps for your own timezone is a little more fiddly, but this command will return them for the year 2017. Here you can see that I'm in the UK timezone with BST/GMT as its timezone labels (summer/winter time):

zdump -V -c2017,2018 $(cat /etc/timezone)
Europe/London  Sun Mar 26 00:59:59 2017 UT = Sun Mar 26 00:59:59 2017 GMT isdst=0 gmtoff=0
Europe/London  Sun Mar 26 01:00:00 2017 UT = Sun Mar 26 02:00:00 2017 BST isdst=1 gmtoff=3600
Europe/London  Sun Oct 29 00:59:59 2017 UT = Sun Oct 29 01:59:59 2017 BST isdst=1 gmtoff=3600
Europe/London  Sun Oct 29 01:00:00 2017 UT = Sun Oct 29 01:00:00 2017 GMT isdst=0 gmtoff=0

I'm not aware of a tool to decompile the binaries in /usr/share/zoneinfo back into rules files. You'd probably find it easier to start with the source rulesets; they're easily enough available.

Related Question