54159: strftime: respect empty TZ

+ README update due to potential compatibility breakage
This commit is contained in:
dana
2026-01-20 19:57:46 -06:00
parent 34c93228c2
commit 63f7b6efb6
5 changed files with 20 additions and 2 deletions

View File

@@ -1,5 +1,9 @@
2026-04-05 dana <dana@dana.is>
* 54159: Doc/Zsh/mod_datetime.yo, README,
Src/Modules/datetime.c, Test/V09datetime.ztst: strftime:
respect empty TZ
* 54144: Src/Zle/termquery.c: termquery: don't warn about
creating .term.* params

View File

@@ -33,7 +33,7 @@ function tt(strptime); see manref(strptime)(3). This means that zsh
format extensions are not available, but for reverse lookup they are not
required.
In most implementations of tt(strftime) any timezone in the
In most implementations of tt(strptime) any timezone in the
var(timestring) is ignored and the local timezone declared by the tt(TZ)
environment variable is used; other parameters are set to zero if not
present.

4
README
View File

@@ -128,6 +128,10 @@ Tied parameters created with the zsh/db/gdbm module may not be re-tied
as locals in nested function scope. This prevents database corruption
when a function scope ends.
The zsh/datetime module's strftime builtin now exports a set-but-empty
TZ parameter (as in `TZ= strftime ...`) for use by the underlying
library. On most systems, this is equivalent to setting TZ to UTC.
Incompatibilities between 5.8.1 and 5.9
---------------------------------------

View File

@@ -190,7 +190,7 @@ bin_strftime(char *nam, char **argv, Options ops, int func)
char *tz = getsparam("TZ");
startparamscope();
if (tz && *tz) {
if (tz) {
Param pm = createparam("TZ", PM_LOCAL|PM_SCALAR|PM_EXPORTED);
if (pm)
pm->level = locallevel; /* because createparam() doesn't */

View File

@@ -134,3 +134,13 @@
strftime -n 'one line%n' 2> /dev/null
0:-n option
>one line
# most platforms treat a set-but-empty TZ as UTC. however, it's not actually
# required by POSIX, so we'll only test on systems we can be fairly sure about
if [[ $OSTYPE != (darwin|freebsd|netbsd|openbsd|linux-gnu)* ]]; then
ZTST_skip='unsure of empty-TZ behaviour'
else
( unset TZ; TZ= strftime '%F %T' 1234567890 )
fi
0:empty TZ respected
>2009-02-13 23:31:30