vim-patch:8.2.0949: strptime() does not use DST

Problem:    Strptime() does not use DST.
Solution:   Set the tm_isdst field to -1. (Tomáš Janoušek, closes vim/vim#6230)
ea1233fccf
This commit is contained in:
Jan Edmund Lazo 2020-12-06 11:05:22 -05:00
parent 93e9cf4b6c
commit a7e0b0edbc
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 7 additions and 1 deletions

View File

@ -10195,7 +10195,9 @@ static void f_strptime(typval_T *argvars, typval_T *rettv, FunPtr fptr)
char fmt_buf[NUMBUFLEN]; char fmt_buf[NUMBUFLEN];
char str_buf[NUMBUFLEN]; char str_buf[NUMBUFLEN];
struct tm tmval = { 0 }; struct tm tmval = {
.tm_isdst = -1,
};
char *fmt = (char *)tv_get_string_buf(&argvars[0], fmt_buf); char *fmt = (char *)tv_get_string_buf(&argvars[0], fmt_buf);
char *str = (char *)tv_get_string_buf(&argvars[1], str_buf); char *str = (char *)tv_get_string_buf(&argvars[1], str_buf);

View File

@ -225,6 +225,10 @@ func Test_strptime()
call assert_equal(1484653763, strptime('%Y-%m-%d %T', '2017-01-17 11:49:23')) call assert_equal(1484653763, strptime('%Y-%m-%d %T', '2017-01-17 11:49:23'))
" Force DST and check that it's considered
let $TZ = 'WINTER0SUMMER,J1,J365'
call assert_equal(1484653763 - 3600, strptime('%Y-%m-%d %T', '2017-01-17 11:49:23'))
call assert_fails('call strptime()', 'E119:') call assert_fails('call strptime()', 'E119:')
call assert_fails('call strptime("xxx")', 'E119:') call assert_fails('call strptime("xxx")', 'E119:')
call assert_equal(0, strptime("%Y", '')) call assert_equal(0, strptime("%Y", ''))