Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/msvcrt/time.c | 35 +++++++++++++++++++++++++++-------- dlls/ucrtbase/tests/misc.c | 4 ++-- 2 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index ec8f45d140..93700e3048 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -1195,6 +1195,8 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max, MSVCRT___lc_time_data *time_data, MSVCRT__locale_t loc) { MSVCRT_size_t ret, tmp; + MSVCRT_pthreadlocinfo locinfo; + BOOL time_data_from_param = (time_data) ? TRUE : FALSE; BOOL alternate; int year = mstm ? mstm->tm_year + 1900 : -1;
@@ -1205,8 +1207,9 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max, return 0; }
+ locinfo = loc ? loc->locinfo : get_locinfo(); if(!time_data) - time_data = loc ? loc->locinfo->lc_time_curr : get_locinfo()->lc_time_curr; + time_data = locinfo->lc_time_curr;
for(ret=0; *format && ret<max; format++) { if(*format != '%') { @@ -1233,13 +1236,29 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max,
switch(*format) { case 'c': - if(!strftime_format(str, &ret, max, mstm, time_data, - alternate ? STRFTIME_TD(time_data, date) : STRFTIME_TD(time_data, short_date))) - return 0; - if(ret < max) - str[ret++] = ' '; - if(!strftime_format(str, &ret, max, mstm, time_data, STRFTIME_TD(time_data, time))) - return 0; +#if _MSVCR_VER>=140 + if(!strcmp(locinfo->lc_category[MSVCRT_LC_TIME].locale, "C") && + !time_data_from_param && !alternate) + { + static const WCHAR date_format[] = { 'd','d','d',' ','M','M','M',' ','d','d', + ' ','H','H',':','m','m',':','s','s',' ','y','y','y','y',0 }; + MSVCRT_size_t day_offset = ret + 8; + if(!strftime_format(str, &ret, max, mstm, time_data, date_format)) + return 0; + if(str[day_offset] == '0') + str[day_offset] = ' '; + } + else +#endif + { + if(!strftime_format(str, &ret, max, mstm, time_data, + alternate ? STRFTIME_TD(time_data, date) : STRFTIME_TD(time_data, short_date))) + return 0; + if(ret < max) + str[ret++] = ' '; + if(!strftime_format(str, &ret, max, mstm, time_data, STRFTIME_TD(time_data, time))) + return 0; + } break; case 'x': if(!strftime_format(str, &ret, max, mstm, time_data, diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c index 6314662eac..9598333fc8 100644 --- a/dlls/ucrtbase/tests/misc.c +++ b/dlls/ucrtbase/tests/misc.c @@ -992,8 +992,8 @@ static void test_strftime(void) {"%g", "72", { 0, 0, 0, 3, 0, 72, 1, 2, 0 }}, {"%G", "1971", { 0, 0, 0, 2, 0, 72, 0, 1, 0 }}, {"%G", "1972", { 0, 0, 0, 3, 0, 72, 1, 2, 0 }}, - {"%c", "Thu Jan 1 00:00:00 1970", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }, TRUE}, - {"%c", "Thu Feb 30 00:00:00 1970", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE}, + {"%c", "Thu Jan 1 00:00:00 1970", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, + {"%c", "Thu Feb 30 00:00:00 1970", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }}, {"%#c", "Thursday, January 01, 1970 00:00:00", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }}, {"%#c", "Thursday, February 30, 1970 00:00:00", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }}, {"%x", "01/01/70", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},