How does Linux handle DST/ST? It's all about time...

Michael ODonnell mod.gnhlug at b0rken.com
Tue Nov 10 15:12:25 EST 2020



If some variation of that sleazy hack doesn't work and you can't
find some some source for the info you want (maybe something like
https://isDSTactiveInMyTimezone.com/ :) then you'll have to determine
if DST is active on your own.

That requires a timezone file for your locale and some source of "current
UTC time"; your system clock chip can presumably supply the latter.

Here's hoping you can find existing code (like a Python library) to
paddle around in timezone files.

If not, you can dump a timezone file with zdump; the output shows (among
other things) the exact dates/times of transitions into and out of DST,
as well as your locale's offset from UTC after each transition.

The timezone files typically live in /usr/{share,lib}/zoneinfo/

The timezone file governing your system is specified in /etc/timezone

So, on my Ubuntu system this command dumps the current timezone file:

   zdump -v /usr/share/zoneinfo/$(cat /etc/timezone)

...in a text format that could be parsed to discover if DST is in effect
in my timezone.  Ick.



More information about the gnhlug-discuss mailing list