[conspire] "Time zones exist to make programmers' lives miserable" ...

Rick Moen rick at linuxmafia.com
Fri Feb 12 21:08:50 PST 2021


Quoting Michael Paoli (Michael.Paoli at cal.berkeley.edu):

> >And _that_ is why my tzall shell function greps them out.  ;->
> 
> That's why I used:
> /usr/share/zoneinfo/*/
> rather than any of these:
> /usr/share/zoneinfo/*
> /usr/share/zoneinfo/
> /usr/share/zoneinfo
> For non-ancient *nix, in general, ending with / limits to
> directories, or at least files that resolve to directory.
> And, by my so doing, starts the (e.g. find) search at the first
> directory level below zoneinfo - thus likewise misses
> those files (which are all at top level under zoneinfo, whereas
> all the timezone files are at least one directory level lower).
> 
> Might also want to grep out some additional files, if you have
> newer version:
> $ find * -type f -exec file \{\} \; 2>>/dev/null | sed -ne '/:
> timezone data.*$/d;s/: .*$//p'
> iso3166.tab
> leap-seconds.list
> zone.tab
> zone1970.tab
> $

[snip a lot for brevity's sake]


I did some further pondering, and examination of
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones , noting
zonefile names/categories are deprecated and why.  As a reminder, my 
aim was not to determine which /usr/share/zoneinfo/* files are bitwise
unique, nor which might be used in weird circumstances (such as the
'right' tree when you want atomic clock leap seconds or whatever that
was).  The aim was to output approximately what /usr/share/zoneinfo/*
files ought to be used in 2021 with GNU date(1) to accurately reflect
particular locations in the world and get correct results.

So, for example, it would be _valid_ to use TZ value "PST8PDT" in
reference to all California and Washington LUG online meetings -- but 
that is a deprecated timezone spec, which is why the Wikipedia page says
for it "Choose a zone that observes PST with United States daylight
saving time rules, such as America/Los_Angeles."  

Another example:  Kitchener-Waterloo Linux User Group online meetings
are in Ontario.  "EST5EDT" is functional and correct but is deprecated
for the same reason as "PST8PDT", and the Wikipedia page says "Choose a
zone that observes EST with United States daylight saving time rules,
such as America/New_York."  But even that choice is a little suboptimal,
or at least presumptuous as to international diplomacy:  Ontario has 
always historically followed "EST with United States daylight saving
time rules', but technically it follows Canadian rules, not US rules,
so I judge "America/Toronto" a better TZ choice.

Arizona (relevant to Phoenix Linux Users Group and Ubuntu Arizona Team
online meetings (hi, Akkana!) is its own thing in that the state of
Arizona -- except for the Navajo lands, because nothing about timezones
can be allowed to be simple -- eschews DST and remains on MST
year-round.  But for previously alluded-to reasons, "MST" is deprecated,
and the optimal TZ reference is "America/Phoenix".

Anyhow, after geeking out on these matters and researching each entry on
https://www.wiki.balug.org/wiki/doku.php?id=balug:covid-19 , I've
supplied what I _believe_ to be the optimal TZ spec for each online
meeting, and added new section
https://www.wiki.balug.org/wiki/doku.php?id=balug:covid-19#timezone_conversion 
at the bottom, as a cheatsheet about effective use of GNU date(1) to
contend with timezone madness.


Also FYI, I've further refined the exclusions on my 'tzall' shell
function, excluding more deprecated specs and leaving _almost_ entirely 
ones reasonable to pick for timezone conversion.


    tzall () {
      find /usr/share/zoneinfo/* -type f -print | sed -r 's_/usr/share/zoneinfo/__' | grep -v -e .tab -e posixrules -e leap-seconds.list -e ^SystemV -e ^Factory -e ^posix -e ^right -e ^US -e ^Brazil -e ^Canada -e ^Chile -e ^Cuba -e ^EET -e ^CET -e ^CST6CDT -e ^Egypt -e ^Eire -e ^EST -e EST5EDT -e Hongkong -e ^HST -e ^Iceland -e ^Iran -e ^Israel -e ^Jamaica -e ^Japan -e ^Kwajalein -e ^Libya -e ^MET -e ^Mexico -e ^MST -e ^Navajo -e ^NZ -e ^Poland -e ^Portugal -e ^PRC -e ^PST8PDT -e ^ROC -e ^ROK -e ^Singapore -e ^Turkey -e ^UCT -e ^Universal -e ^W-SU -e ^WET -e ^Zulu
    }





> And, slightly corrected to count how many unique timezone file data
> contents ... well, heck, we can even improve further ... don't need
> to examine symbolic links ...
> 
> $ sha512sum $(find * -type f -exec file \{\} \; 2>>/dev/null | sed
> -ne 's/: timezone data.*$//p') | awk '{print $1;}' | sort -u | wc -l
> 774
> $

Since I don't consider bitwise-unique or not relevant to my criteria,
but have now exclude a bunch of subdirs and individual files as
deprecated,  I come up with:

$ tzall | wc -l
504
$ 

(That still includes some deprecated entries, but I'm bearing in mind 
diminishing returns, and I don't care much that "America/Atka" ought to be
"America/Adak".  I'm not going to waste cycles on fine points of
Aleutian Island naming.)

Anyway, have a look at the revised wiki page at your convenience, good
sir.  Thanks.



More information about the conspire mailing list