patch 8.1.1567: localtime_r() does not respond to $TZ changes
Problem: Localtime_r() does not respond to $TZ changes.
Solution: If $TZ changes then call tzset(). (Tom Ryder)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 66612e8..5c9400e 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -13188,9 +13188,7 @@
f_strftime(typval_T *argvars, typval_T *rettv)
{
char_u result_buf[256];
-# ifdef HAVE_LOCALTIME_R
struct tm tmval;
-# endif
struct tm *curtime;
time_t seconds;
char_u *p;
@@ -13202,11 +13200,7 @@
seconds = time(NULL);
else
seconds = (time_t)tv_get_number(&argvars[1]);
-# ifdef HAVE_LOCALTIME_R
- curtime = localtime_r(&seconds, &tmval);
-# else
- curtime = localtime(&seconds);
-# endif
+ curtime = vim_localtime(&seconds, &tmval);
/* MSVC returns NULL for an invalid value of seconds. */
if (curtime == NULL)
rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));