On 2022-09-17 08:42 UTC, Klemens Nanni <k...@openbsd.org> wrote: > On Sat, Sep 17, 2022 at 09:40:27AM +0200, Florian Obser wrote: >> On 2021-10-24 03:06 +02, James Russell Stickney <j...@outband.net> wrote: >> > I recently found myself wanting to moniter local time from a number of >> > locations around the world. >> > Setting the TZ environment variable on grdc did a wonderfull job at this. >> > At which point, I wanted to know which clock was showing what time. >> > This lead to the following patch. >> > >> > If curious as to how this looked, it was sort of like the image below. >> > https://nl1.outband.net/image/grdc_desktop_example.png >> > >> >> I recently found a use for this as well and remembered this diff. One >> long line re-wrapped. >> >> OK? > > Reads fine, but I don't use this "game". > >> >> (Or commit it with OK florian) >> >> diff --git grdc.6 grdc.6 >> index 16c1fb5cd3d..69febddc9a2 100644 >> --- grdc.6 >> +++ grdc.6 >> @@ -30,6 +30,13 @@ skips seconds. >> Pressing the >> .Sq q >> key exits the program. >> +.Sh ENVIRONMENT >> +.Bl -tag -width "daemon_timeout" >> +.It Ev TZ >> +Time shown will be from zone as found under /usr/share/zonefile. > > This should be > .Pa /usr/share/zonefile .
Good catch, I have adapted the text from date(1) for this, I think it flows nicer and dropped the example. Update diff with a local variable for getenv(3) and pulled the call up, it's not going to change during runtime. OK? diff --git grdc.6 grdc.6 index 16c1fb5cd3d..a7258488e5a 100644 --- grdc.6 +++ grdc.6 @@ -30,6 +30,15 @@ skips seconds. Pressing the .Sq q key exits the program. +.Sh ENVIRONMENT +.Bl -tag -width Ds +.It Ev TZ +The time zone to use for displaying the time. +It is specified as a pathname relative to +.Pa /usr/share/zoneinfo . +If this variable is not set, the time zone is determined based on +.Pa /etc/localtime . +.El .Sh AUTHORS .An -nosplit .An Amos Shapir , diff --git grdc.c grdc.c index 287fb14e95f..94f80a865c0 100644 --- grdc.c +++ grdc.c @@ -78,6 +78,9 @@ main(int argc, char *argv[]) int xbase; int ybase; int wintoosmall; + char *tz; + + tz = getenv("TZ"); scrol = wintoosmall = 0; while ((i = getopt(argc, argv, "sh")) != -1) { @@ -139,6 +142,16 @@ main(int argc, char *argv[]) alarm(n); } do { + mask = 0; + tm = localtime(&now.tv_sec); + set(tm->tm_sec % 10, 0); + set(tm->tm_sec / 10, 4); + set(tm->tm_min % 10, 10); + set(tm->tm_min / 10, 14); + set(tm->tm_hour % 10, 20); + set(tm->tm_hour / 10, 24); + set(10, 7); + set(10, 17); if (sigwinched) { sigwinched = 0; wintoosmall = 0; @@ -171,21 +184,17 @@ main(int argc, char *argv[]) move(ybase, xbase + XLENGTH); vline(ACS_VLINE, YDEPTH); + if (tz != NULL) { + move(ybase - 1, xbase); + printw("[ %s %+d ]", tz, + tm->tm_gmtoff / 60 / 60 ); + } + attrset(COLOR_PAIR(2)); } for (k = 0; k < 6; k++) old[k] = 0; } - mask = 0; - tm = localtime(&now.tv_sec); - set(tm->tm_sec % 10, 0); - set(tm->tm_sec / 10, 4); - set(tm->tm_min % 10, 10); - set(tm->tm_min / 10, 14); - set(tm->tm_hour % 10, 20); - set(tm->tm_hour / 10, 24); - set(10, 7); - set(10, 17); if (wintoosmall) { move(0, 0); printw("%02d:%02d:%02d", tm->tm_hour, tm->tm_min, -- I'm not entirely sure you are real.