[PATCH 5/5] ucrtbase: Correct behavior of strftime formats %c %r.

Jeff Smith whydoubt at gmail.com
Mon Dec 2 11:52:04 CST 2019


Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
 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..885166e638 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 == MSVCRT_time_curr && !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 == MSVCRT_time_curr)
             {
                 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 606e74b524..51620dd0f2 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 == strlen(expected), "ret = %d\n", ret);
     ok(!strcmp(buf, expected), "buf = \"%s\", expected \"%s\"\n", buf, expected);
     ret = p_strftime(buf, sizeof(buf), "%x %r", &epoch);
-    todo_wine ok(ret == strlen(expected), "ret = %d\n", ret);
-    todo_wine ok(!strcmp(buf, expected), "buf = \"%s\", expected \"%s\"\n", buf, expected);
+    ok(ret == strlen(expected), "ret = %d\n", ret);
+    ok(!strcmp(buf, expected), "buf = \"%s\", expected \"%s\"\n", buf, expected);
     p_setlocale(LC_ALL, locale);
 }
 
-- 
2.23.0




More information about the wine-devel mailing list