mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 8.2.2894: MS-Windows: using enc_locale() for strftime() might not work
Problem: MS-Windows: using enc_locale() for strftime() might not work. Solution: Use wcsftime(). (Ken Takata, closes #8271)
This commit is contained in:
16
src/time.c
16
src/time.c
@@ -252,7 +252,6 @@ f_reltimestr(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
void
|
void
|
||||||
f_strftime(typval_T *argvars, typval_T *rettv)
|
f_strftime(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
char_u result_buf[256];
|
|
||||||
struct tm tmval;
|
struct tm tmval;
|
||||||
struct tm *curtime;
|
struct tm *curtime;
|
||||||
time_t seconds;
|
time_t seconds;
|
||||||
@@ -271,6 +270,20 @@ f_strftime(typval_T *argvars, typval_T *rettv)
|
|||||||
rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
|
rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
# ifdef MSWIN
|
||||||
|
WCHAR result_buf[256];
|
||||||
|
WCHAR *wp;
|
||||||
|
|
||||||
|
wp = enc_to_utf16(p, NULL);
|
||||||
|
if (wp != NULL)
|
||||||
|
(void)wcsftime(result_buf, sizeof(result_buf) / sizeof(WCHAR),
|
||||||
|
wp, curtime);
|
||||||
|
else
|
||||||
|
result_buf[0] = NUL;
|
||||||
|
rettv->vval.v_string = utf16_to_enc(result_buf, NULL);
|
||||||
|
vim_free(wp);
|
||||||
|
# else
|
||||||
|
char_u result_buf[256];
|
||||||
vimconv_T conv;
|
vimconv_T conv;
|
||||||
char_u *enc;
|
char_u *enc;
|
||||||
|
|
||||||
@@ -296,6 +309,7 @@ f_strftime(typval_T *argvars, typval_T *rettv)
|
|||||||
// Release conversion descriptors
|
// Release conversion descriptors
|
||||||
convert_setup(&conv, NULL, NULL);
|
convert_setup(&conv, NULL, NULL);
|
||||||
vim_free(enc);
|
vim_free(enc);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2894,
|
||||||
/**/
|
/**/
|
||||||
2893,
|
2893,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user