comparison src/evalfunc.c @ 17135:d03a52e02f1a v8.1.1567

patch 8.1.1567: localtime_r() does not respond to $TZ changes commit https://github.com/vim/vim/commit/db51730df1817fc4b6ecf5a065c69fac518ad821 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 18 22:53:24 2019 +0200 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)
author Bram Moolenaar <Bram@vim.org>
date Tue, 18 Jun 2019 23:00:07 +0200
parents efc6f5e3b543
children 3fd0765f454f
comparison
equal deleted inserted replaced
17134:afef6986c785 17135:d03a52e02f1a
13186 */ 13186 */
13187 static void 13187 static void
13188 f_strftime(typval_T *argvars, typval_T *rettv) 13188 f_strftime(typval_T *argvars, typval_T *rettv)
13189 { 13189 {
13190 char_u result_buf[256]; 13190 char_u result_buf[256];
13191 # ifdef HAVE_LOCALTIME_R
13192 struct tm tmval; 13191 struct tm tmval;
13193 # endif
13194 struct tm *curtime; 13192 struct tm *curtime;
13195 time_t seconds; 13193 time_t seconds;
13196 char_u *p; 13194 char_u *p;
13197 13195
13198 rettv->v_type = VAR_STRING; 13196 rettv->v_type = VAR_STRING;
13200 p = tv_get_string(&argvars[0]); 13198 p = tv_get_string(&argvars[0]);
13201 if (argvars[1].v_type == VAR_UNKNOWN) 13199 if (argvars[1].v_type == VAR_UNKNOWN)
13202 seconds = time(NULL); 13200 seconds = time(NULL);
13203 else 13201 else
13204 seconds = (time_t)tv_get_number(&argvars[1]); 13202 seconds = (time_t)tv_get_number(&argvars[1]);
13205 # ifdef HAVE_LOCALTIME_R 13203 curtime = vim_localtime(&seconds, &tmval);
13206 curtime = localtime_r(&seconds, &tmval);
13207 # else
13208 curtime = localtime(&seconds);
13209 # endif
13210 /* MSVC returns NULL for an invalid value of seconds. */ 13204 /* MSVC returns NULL for an invalid value of seconds. */
13211 if (curtime == NULL) 13205 if (curtime == NULL)
13212 rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)")); 13206 rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
13213 else 13207 else
13214 { 13208 {