vim-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)
db51730df1
This commit is contained in:
Jan Edmund Lazo
2020-03-29 11:59:22 -04:00
parent 573671b1fb
commit 10c5434f9c
2 changed files with 41 additions and 4 deletions

View File

@@ -186,6 +186,29 @@ func Test_strftime()
call assert_fails('call strftime([])', 'E730:')
call assert_fails('call strftime("%Y", [])', 'E745:')
" Check that the time changes after we change the timezone
" Save previous timezone value, if any
if exists('$TZ')
let tz = $TZ
endif
" Force EST and then UTC, save the current hour (24-hour clock) for each
let $TZ = 'EST' | let est = strftime('%H')
let $TZ = 'UTC' | let utc = strftime('%H')
" Those hours should be two bytes long, and should not be the same; if they
" are, a tzset(3) call may have failed somewhere
call assert_equal(strlen(est), 2)
call assert_equal(strlen(utc), 2)
call assert_notequal(est, utc)
" If we cached a timezone value, put it back, otherwise clear it
if exists('tz')
let $TZ = tz
else
unlet $TZ
endif
endfunc
func Test_resolve()