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

Index: grdc.6
==================================================================
--- grdc.6
+++ grdc.6
@@ -28,10 +28,17 @@
 .Nm
 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.
+For Example:
+TZ=Asia/Tokyo grdc
+.El
 .Sh AUTHORS
 .An -nosplit
 .An Amos Shapir ,
 modified for curses by
 .An John Lupien .

Index: grdc.c
==================================================================
--- grdc.c
+++ grdc.c
@@ -140,10 +140,20 @@
        if (n) {
                signal(SIGALRM, sigalrm);
                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;
                        getwinsize(&i, &j);
                        if (i >= XLENGTH + 2)
@@ -171,26 +181,21 @@
                                move(ybase, xbase - 1);
                                vline(ACS_VLINE, YDEPTH);
 
                                move(ybase, xbase + XLENGTH);
                                vline(ACS_VLINE, YDEPTH);
+
+                               if (getenv("TZ") ) {
+                                       move(ybase - 1, xbase);
+                                       printw("[ %s %+d ]", getenv("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,
                            tm->tm_sec);
                } else for (k = 0; k < 6; k++) {

Reply via email to