Bug#294591: clock-applet fails to obey TZ

Stephen Gildea Stephen Gildea <gildea@stop.mail-abuse.org>, 294591@bugs.debian.org
Thu, 10 Feb 2005 11:50:30 -0500


Package: gnome-panel
Version: 2.8.2-2
Tags: patch

If you have $TZ set in your GNOME session environment, the panel
clock applet fails to obey it.  All other applications--bash, oclock,
emacs, etc--display the time correctly.  But GNOME clock-applet
displays the system time, ignoring TZ.

I judge the problem to be in
debian/patches/04_clockapplet_reload_timezone.patch,
which appears to be manipulating TZ to get the clock-applet's "Adjust
Date & Time" timezone-changing feature to work.  Unfortunately, the
patch fails to reset TZ to its original value, instead always using
the default system value.

I have revised 04_clockapplet_reload_timezone.patch to save the
original TZ and restore that.  Here is my version of the patch file:


--- applets/clock/clock.c.orig 2004-12-08 18:52:20.000000000 +0100
+++ applets/clock/clock.c      2005-02-08 21:49:37.000000000 -0800
@@ -330,6 +330,20 @@
   char date[256], hour[256];
   char *utf8, *loc;
 
+        char *tz_orig = g_strdup(getenv("TZ"));
+	 /* Setting "TZ" environment to another location say "" */
+        setenv("TZ","",1);
+        time_t tmptime_t=time(NULL);           /* These variables are not*/
+        struct tm *tmtmp=localtime(&tmptime_t);/* using further */
+	 /* Resetting "TZ" to original location
+	 then only it can refresh according to the New timezone */
+        if (tz_orig != NULL) {
+                setenv("TZ", tz_orig, 1);
+        } else {
+                unsetenv("TZ");
+        }
+        g_free(tz_orig);
+
	time (&cd->current_time);
	
	if (cd->gmt_time)
	


Additional comments:

It turned out to be tricky to set TZ for a GNOME session; passing TZ
in the environment to gdm wasn't sufficient.  I had to add a file to
/etc/X11/Xsession.d/ to read /etc/tzname.  Is it a gdm bug that it
doesn't pass an inherited TZ on to Xsession?  It is a bug that gdm
doesn't use /etc/login.defs to set the time zone like console logins
do?

I need the system time zone and my session time zone to be different
because this is a server that has temporarily been moved to new time
zone but must still serve applications in its original time zone.  In
some cases, the system time zone is visible.

I understand that by using TZ in my session I cannot use the
clock-applet to change the system time zone.  This is okay, as long
as the GNOME panel obeys my TZ at all.

 < Stephen