about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-04-25 10:57:44 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2015-04-25 10:57:44 -0700
commit0164457a199d826e8d2018c94f57a7803071b63a (patch)
treeeddd879d2b4bc422ed4b2df188f7068da7f9bfaf
parentf8fb6ebae8a829ce20291c9f37fb23c48fd4c32e (diff)
downloadzsh-0164457a199d826e8d2018c94f57a7803071b63a.tar.gz
zsh-0164457a199d826e8d2018c94f57a7803071b63a.tar.xz
zsh-0164457a199d826e8d2018c94f57a7803071b63a.zip
34961: $TZ is implicitly local in builtin strftime (originally workers/34602 from workers/34596)
-rw-r--r--ChangeLog3
-rw-r--r--Src/Modules/datetime.c21
2 files changed, 23 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 713da5337..d86846ff2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-04-25  Barton E. Schaefer  <schaefer@zsh.org>
 
+	* 34961: Src/Modules/datetime.c: $TZ is implicitly local in
+	builtin strftime (originally workers/34602 from workers/34596)
+
 	* 34961: Src/hist.c: clean up decl's of quote() and quotebreak()
 
 	* 34961: Doc/Zsh/mod_system.yo: sysparams[pid] and sysparams[ppid]
diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c
index 00ebd2b49..63a04dc89 100644
--- a/Src/Modules/datetime.c
+++ b/Src/Modules/datetime.c
@@ -94,7 +94,7 @@ reverse_strftime(char *nam, char **argv, char *scalar, int quiet)
 }
 
 static int
-bin_strftime(char *nam, char **argv, Options ops, UNUSED(int func))
+output_strftime(char *nam, char **argv, Options ops, UNUSED(int func))
 {
     int bufsize, x;
     char *endptr = NULL, *scalar = NULL, *buffer;
@@ -145,6 +145,25 @@ bin_strftime(char *nam, char **argv, Options ops, UNUSED(int func))
     return 0;
 }
 
+static int
+bin_strftime(char *nam, char **argv, Options ops, int func)
+{
+    int result = 1;
+    char *tz = getsparam("TZ");
+
+    startparamscope();
+    if (tz && *tz) {
+	Param pm = createparam("TZ", PM_LOCAL|PM_SCALAR|PM_EXPORTED);
+	if (pm)
+	    pm->level = locallevel; /* because createparam() doesn't */
+	setsparam("TZ", ztrdup(tz));
+    }
+    result = output_strftime(nam, argv, ops, func);
+    endparamscope();
+
+    return result;
+}
+
 static zlong
 getcurrentsecs(UNUSED(Param pm))
 {