ucrtbase: Correct behavior of strftime formats %c %r.
Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f174eb072d
commit
0b78dd17ae
|
@ -1234,6 +1234,18 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max,
|
|||
|
||||
switch(*format) {
|
||||
case 'c':
|
||||
#if _MSVCR_VER>=140
|
||||
if(time_data == &cloc_time_data && !alternate)
|
||||
{
|
||||
static const WCHAR datetime_format[] =
|
||||
{ '%','a',' ','%','b',' ','%','e',' ','%','T',' ','%','Y',0 };
|
||||
tmp = strftime_impl(str+ret, max-ret, datetime_format, mstm, time_data, loc);
|
||||
if(!tmp)
|
||||
return 0;
|
||||
ret += tmp;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if(!strftime_format(str, &ret, max, mstm, time_data,
|
||||
alternate ? STRFTIME_TD(time_data, date) : STRFTIME_TD(time_data, short_date)))
|
||||
return 0;
|
||||
|
@ -1387,7 +1399,7 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max,
|
|||
break;
|
||||
#if _MSVCR_VER>=140
|
||||
case 'r':
|
||||
if(time_data == MSVCRT_locale->locinfo->lc_time_curr)
|
||||
if(time_data == &cloc_time_data)
|
||||
{
|
||||
if(!MSVCRT_CHECK_PMT(mstm->tm_hour>=0 && mstm->tm_hour<=23))
|
||||
goto einval_error;
|
||||
|
|
|
@ -1004,8 +1004,8 @@ static void test_strftime(void)
|
|||
{"%y", "00", { 0, 0, 0, 0, 0, -1900, 0, 0, 0 }},
|
||||
{"%y", "99", { 0, 0, 0, 0, 0, 8099, 0, 0, 0 }},
|
||||
{"%y", "", { 0, 0, 0, 0, 0, 8100, 0, 0, 0 }},
|
||||
{"%c", "Thu Jan 1 00:00:00 1970", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }, TRUE, TRUE},
|
||||
{"%c", "Thu Feb 30 00:00:00 1970", { 0, 0, 0, 30, 1, 70, 4, 0, 0 }, TRUE, 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 }},
|
||||
|
@ -1197,8 +1197,8 @@ static void test_strftime(void)
|
|||
ok(ret == 19, "ret = %d\n", ret);
|
||||
ok(!strcmp(buf, "01/01/1970 00:00:00"), "buf = \"%s\", expected \"%s\"\n", buf, "01/01/1970 00:00:00");
|
||||
ret = p_strftime(buf, sizeof(buf), "%r", &epoch);
|
||||
todo_wine ok(ret == 8, "ret = %d\n", ret);
|
||||
todo_wine ok(!strcmp(buf, "00:00:00"), "buf = \"%s\", expected \"%s\"\n", buf, "00:00:00");
|
||||
ok(ret == 8, "ret = %d\n", ret);
|
||||
ok(!strcmp(buf, "00:00:00"), "buf = \"%s\", expected \"%s\"\n", buf, "00:00:00");
|
||||
p_setlocale(LC_ALL, "C");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue