Subject: bug#19874: 25.0.50; encode-time not working as expected

From: Paul Eggert <[email-masked]>
Date: Thu, 26 Feb 2015 00:39:57 -0800

Ashish SHUKLA wrote:
> I did this in X11 window (note the absence
> of '-batch' option)
>
> --8<---------------cut here---------------start------------->8---
> emacs-25.0.50.20150206.5c9ad35f/src % ../src/emacs -Q -eval '(progn (setenv "TZ" "Asia/Kolkata") (print (encode-time 44 42 6 15 2 2015 0 nil 0)))'
> oldtz=(null) tz=XXX-0:00:00 oldTZ=(null) TZ=(null) 2015-02-15 06:42:44 -1 -> 2015-02-15 06:42:44 0 = 1423962764

This makes it look like immediately after set_time_zone_rule ("XXX-0:00:00") was 
called, getenv ("TZ") returned NULL.  That shouldn't happen: set_time_zone_rule 
is supposed to arrange for TZ to have the specified value.

Could you please try similar tests with the attached patch instead?  It should 
tell us whether set_time_zone_rule is properly affecting the TZ environment 
variable.
diff --git a/src/editfns.c b/src/editfns.c
index dbcb316..4c542bd 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2359,6 +2359,11 @@ set_time_zone_rule (const char *tzstring)
       xputenv (tzval);
     }
 
+  char const *TZ = getenv ("TZ");
+  fprintf (stderr, ("set_time_zone_rule (\"%s\"); "
+		    "tzval = \"%s\"; getenv (\"TZ\") -> %s\n"),
+	   tzstring ? tzstring : "(null)", tzval, TZ ? TZ : "(null)");
+
 #ifdef HAVE_TZSET
   tzset ();
 #endif