[conspire] "Time zones exist to make programmers' lives miserable"
Rick Moen
rick at linuxmafia.com
Sat Feb 6 21:16:51 PST 2021
Deirdre cited for me the Subject header as a saying by Jamis Buck,
and it seemed amusing to quote, here.
Anyway, what follows is what _some_ of us do for fun on a Saturday
evening.
Extra credit question: Why am I grepping out ".tab" and "posixrules"
from the timezone names list? Class?
----- Forwarded message from Wayne <Wayne at TradeTimer.com> -----
Date: Sat, 6 Feb 2021 17:33:03 -0800
From: Wayne <Wayne at TradeTimer.com>
To: Felton Linux Users Group LUG <felton-lug at googlegroups.com>
Subject: [Felton LUG] More online meeting fun...
In case you're interested, here is a partial list of time-practical online LUG meetings you might like to check out. I hope I got the time translations correct...
https://meet.jit.si/SurreyLUGBaB - 2nd and 4th Saturday, 11:00 to 17:00 UTC, 3AM-9AM PT
https://jitsimeet.jitsimeeting.co.uk/ManLUG - 3rd Saturday, 2-4PM UTC, 6AM PT
https://meet.jit.si/ALE-NW - every Sunday at 3PM ET, Noon PST
https://meet.jit.si/sf-lug.org - 1st Sunday, 11:00 AM PT
https://meet.jit.si/BerkeleyLUG - 2nd and 4th Sundays, 11AM PT
https://meet.jit.si/Pi.BerkeleyLUG - 3rd Sunday, 11AM PT
https://meet.jit.si/TheCall - every-other Monday, 8:30AM PT
https://meet.jit.si/livlug - 1st Wednesday 19:00 UTC, 11AM PST
More at the BALUG wiki...
https://www.wiki.balug.org/wiki/doku.php?id=balug:covid-19
----- End forwarded message -----
----- Forwarded message from Rick Moen <rick at linuxmafia.com> -----
Date: Sat, 6 Feb 2021 18:56:19 -0800
From: Rick Moen <rick at linuxmafia.com>
To: Felton Linux Users Group LUG <felton-lug at googlegroups.com>
Subject: Re: [Felton LUG] More online meeting fun...
Organization: If you lived here, you'd be $HOME already.
Quoting Wayne (Wayne at TradeTimer.com):
> In case you're interested, here is a partial list of time-practical
> online LUG meetings you might like to check out. I hope I got the time
> translations correct...
Time calculations involving multiple time zones are vexingly difficult.
In fact, even _without_ multiple time zones, they're a pain. E.g.,
this tiny shell script of mine is not entirely 100% correct because of
an awkward definitional problem about when a day begins and ends for
purposes of day count:
$ cat $(which daysuntil)
#!/bin/sh
echo "Type the future date in ISO 8601 (YYYY-MM-DD) format."
read futuredate
echo $futuredate | tr -s '-' ' ' | awk '{dt=mktime($0 "00-00-00")-systime(); print int(dt/86400+1) " days";}'
$
I haven't been moved to improve it lately, but maybe will come back to
it. Anyway, point is, doing a similar trick involving inputting a time
in zone X and programmatically converting it to zone Y seems like an
even more daunting task. Anyone feeling cocky about that? Maybe a
perlista? ;->
What I _have_ done is the lazy 80% solution of saying "What is the time
_right now_ in zone Y?" That's a lot simpler:
:r! grep worldclock .bashrc
alias worldclock='zdump America/{Los_Angeles,Phoenix,Mexico_City,New_York,Toronto,Sao_Paulo} Europe/{London,Berlin,Oslo,Moscow} Asia/{Calcutta,Shanghai,Tokyo} Australia/{Perth,Melbourne} Pacific/Auckland'
I personally like that a lot. It's elegant.
Sooner or later, I'll nail down the larger problem, maybe using this set
of Python tips:
https://stackoverflow.com/questions/10997577/python-timezone-conversion
With all these Zoom/Jitsi meet things happening all over the world, I
don't know about you, but I really need something like that -- and I
feel a little sheepish relying on some stranger's hidden-away script via
CGI, e.g, using things like
https://www.timeanddate.com/worldclock/converter.html . That's not the
Unix way, Grasshopper. ;->
----- End forwarded message -----
----- Forwarded message from Rick Moen <rick at linuxmafia.com> -----
Date: Sat, 6 Feb 2021 19:47:02 -0800
From: Rick Moen <rick at linuxmafia.com>
To: Felton Linux Users Group LUG <felton-lug at googlegroups.com>
Subject: Re: [Felton LUG] More online meeting fun...
Organization: If you lived here, you'd be $HOME already.
I wrote:
> Sooner or later, I'll nail down the larger problem...
Actually, I think this is a lot easier than I imagined. Just manipulate
shell variable 'TZ' in scripting, and then ask date(1) to state what a
time in a certain specified time converts to, in the TZ-value zone:
$ TZ=MST date -d "19:43 EST"
Sat Feb 6 17:43:00 MST 2021
$
----- End forwarded message -----
----- Forwarded message from Rick Moen <rick at linuxmafia.com> -----
Date: Sat, 6 Feb 2021 21:06:13 -0800
From: Rick Moen <rick at linuxmafia.com>
To: Felton Linux Users Group LUG <felton-lug at googlegroups.com>
Subject: Re: [Felton LUG] More online meeting fun...
Organization: If you lived here, you'd be $HOME already.
I wrote:
> Actually, I think this is a lot easier than I imagined. Just
> manipulate shell variable 'TZ' in scripting, and then ask date(1) to
> state what a time in a certain specified time converts to, in the
> TZ-value zone:
>
> $ TZ=MST date -d "19:43 EST"
> Sat Feb 6 17:43:00 MST 2021
> $
Also, I made a little thing to let me type 'tzall' or 'tzall | less' or
'tzall | grep [something]' as the lazy way to find a timezone descriptor
for somewhere I care about.
Voila, a new shell function defined in my .bashrc:
tzall () {
find /usr/share/zoneinfo/* -type f -print | sed -r 's_/usr/share/zoneinfo/__' | grep -v -e .tab -e posixrules
}
I first tried defining it as a shell _alias_ (out of habit), but the
gyrations you'd have to go through to escape the quotation characters
(for sed) seemed painful, so I did an end-run around that problem by
writing it as a shell function, instead.
There are a _whole_ lot of valid timezone names, many of them existing
for weird purposes. There are actually 'only' 38 timezones in the
world[1] ; it's just that Linux systems let you refer to them by a lot
of distinct names. How many names?
$ tzall | wc -l
1755
$
That many names.
[1] https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
----- End forwarded message -----
More information about the conspire
mailing list