Jeff Smith : ucrtbase: Correct behavior of strftime formats %c %r.
Alexandre Julliard
julliard at winehq.org
Wed Dec 4 16:13:05 CST 2019
Module: wine
Branch: master
Commit: 0b78dd17aed035b430ce6e9b5a0087f4dcb38ee7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0b78dd17aed035b430ce6e9b5a0087f4dcb38ee7
Author: Jeff Smith <whydoubt at gmail.com>
Date: Wed Dec 4 15:30:57 2019 +0100
ucrtbase: Correct behavior of strftime formats %c %r.
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/time.c | 14 +++++++++++++-
dlls/ucrtbase/tests/misc.c | 8 ++++----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c
index ef4f228554..7f565e350d 100644
--- a/dlls/msvcrt/time.c
+++ b/dlls/msvcrt/time.c
@@ -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;
diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c
index a3a20aa9b1..f637997a0d 100644
--- a/dlls/ucrtbase/tests/misc.c
+++ b/dlls/ucrtbase/tests/misc.c
@@ -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");
}
More information about the wine-cvs
mailing list