ucrtbase: Add support for strftime format %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
40f5cffadd
commit
c6bafaa6d9
|
@ -1386,6 +1386,34 @@ static MSVCRT_size_t strftime_impl(STRFTIME_CHAR *str, MSVCRT_size_t max,
|
|||
return 0;
|
||||
break;
|
||||
#if _MSVCR_VER>=140
|
||||
case 'r':
|
||||
if(time_data == MSVCRT_locale->locinfo->lc_time_curr)
|
||||
{
|
||||
if(!MSVCRT_CHECK_PMT(mstm->tm_hour>=0 && mstm->tm_hour<=23))
|
||||
goto einval_error;
|
||||
if(!strftime_int(str, &ret, max, (mstm->tm_hour + 11) % 12 + 1,
|
||||
alternate ? 0 : 2, 1, 12))
|
||||
return 0;
|
||||
if(ret < max)
|
||||
str[ret++] = ':';
|
||||
if(!strftime_int(str, &ret, max, mstm->tm_min, alternate ? 0 : 2, 0, 59))
|
||||
return 0;
|
||||
if(ret < max)
|
||||
str[ret++] = ':';
|
||||
if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, MAX_SECONDS))
|
||||
return 0;
|
||||
if(ret < max)
|
||||
str[ret++] = ' ';
|
||||
if(!strftime_str(str, &ret, max, mstm->tm_hour<12 ?
|
||||
STRFTIME_TD(time_data, am) : STRFTIME_TD(time_data, pm)))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!strftime_format(str, &ret, max, mstm, time_data, STRFTIME_TD(time_data, time)))
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 'R':
|
||||
if(!strftime_int(str, &ret, max, mstm->tm_hour, alternate ? 0 : 2, 0, 23))
|
||||
return 0;
|
||||
|
|
|
@ -974,8 +974,10 @@ static void test_strftime(void)
|
|||
{"%I", "11", { 0, 0, 23, 1, 0, 70, 4, 0, 0 }},
|
||||
{"%I", "", { 0, 0, 24, 1, 0, 70, 4, 0, 0 }},
|
||||
{"%n", "\n", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||
{"%r", "12:00:00 AM", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }, TRUE, TRUE},
|
||||
{"%r", "02:00:00 PM", { 0, 0, 14, 1, 0, 121, 6, 0, 0 }, TRUE, TRUE},
|
||||
{"%r", "12:00:00 AM", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||
{"%r", "02:00:00 PM", { 0, 0, 14, 1, 0, 121, 6, 0, 0 }},
|
||||
{"%#r", "12:0:0 AM", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||
{"%#r", "2:0:0 PM", { 0, 0, 14, 1, 0, 121, 6, 0, 0 }},
|
||||
{"%t", "\t", { 0, 0, 0, 1, 0, 70, 4, 0, 0 }},
|
||||
{"%g", "", { 0, 0, 0, 1, 0, -1901, 4, 0, 0 }},
|
||||
{"%g", "", { 0, 0, 0, 1, 0, -1901, 3, 364, 0 }},
|
||||
|
@ -1077,6 +1079,7 @@ static void test_strftime(void)
|
|||
{ "%#x", "y70", 0, L"yyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||
{ "%#x", "1970", 0, L"yyyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||
{ "%#x", "y1970", 0, L"yyyyy", 0, { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||
{ "%r", "z", L"x", L"y", L"z", { 0, 0, 0, 1, 0, 70, 0, 0, 0 }},
|
||||
};
|
||||
|
||||
const struct {
|
||||
|
|
Loading…
Reference in New Issue