Signed-off-by: Vijay Kiran Kamuju infyquest@gmail.com --- dlls/msvcrt/tests/time.c | 5 +++++ dlls/msvcrt/time.c | 7 +++++++ dlls/ucrtbase/tests/misc.c | 4 ++++ 3 files changed, 16 insertions(+)
diff --git a/dlls/msvcrt/tests/time.c b/dlls/msvcrt/tests/time.c index 016c9775de7..86799c900f7 100644 --- a/dlls/msvcrt/tests/time.c +++ b/dlls/msvcrt/tests/time.c @@ -608,6 +608,11 @@ static void test_strftime(void) gmt_tm = p_gmtime(&gmt); ok(gmt_tm != NULL, "gmtime failed\n");
+ errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%C", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + errno = 0xdeadbeef; retA = p_strftime(bufA, 256, "%D", gmt_tm); ok(retA == 0, "expected 0, got %ld\n", retA); diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index 450663fd1f5..b9fcde79789 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -1153,6 +1153,13 @@ static MSVCRT_size_t strftime_helper(char *str, MSVCRT_size_t max, const char *f if(!strftime_str(str, &ret, max, time_data->str.names.mon[mstm->tm_mon])) return 0; break; +#if _MSVCR_VER>=140 + case 'C': + tmp = (1900+mstm->tm_year)/100; + if(!strftime_int(str, &ret, max, tmp, alternate ? 0 : 2, 0, 99)) + return 0; + break; +#endif case 'd': if(!strftime_int(str, &ret, max, mstm->tm_mday, alternate ? 0 : 2, 0, 31)) return 0; diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c index c58b6315656..1ba4280a546 100644 --- a/dlls/ucrtbase/tests/misc.c +++ b/dlls/ucrtbase/tests/misc.c @@ -895,6 +895,10 @@ static void test_strftime(void) char bufA[256]; size_t retA;
+ retA = p_strftime(bufA, sizeof(bufA), "%C", &epoch); + ok(retA == 2, "expected 2, got %d\n", (int)retA); + ok(!strcmp(bufA, "19"), "got %s\n", bufA); + retA = p_strftime(bufA, sizeof(bufA), "%D", &epoch); ok(retA == 8, "expected 8, got %d\n", (int)retA); ok(!strcmp(bufA, "01/01/70"), "got %s\n", bufA);
Signed-off-by: Vijay Kiran Kamuju infyquest@gmail.com --- dlls/msvcrt/tests/time.c | 5 +++++ dlls/msvcrt/time.c | 6 ++++++ dlls/ucrtbase/tests/misc.c | 8 ++++++++ 3 files changed, 19 insertions(+)
diff --git a/dlls/msvcrt/tests/time.c b/dlls/msvcrt/tests/time.c index 86799c900f7..9795c92baf8 100644 --- a/dlls/msvcrt/tests/time.c +++ b/dlls/msvcrt/tests/time.c @@ -618,6 +618,11 @@ static void test_strftime(void) ok(retA == 0, "expected 0, got %ld\n", retA); ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
+ errno = 0xdeadbeef; + retA = p_strftime(bufA, 256, "%e", gmt_tm); + ok(retA == 0, "expected 0, got %ld\n", retA); + ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); + errno = 0xdeadbeef; retA = p_strftime(bufA, 256, "%F", gmt_tm); ok(retA == 0, "expected 0, got %ld\n", retA); diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index b9fcde79789..ea06e23b806 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -1177,6 +1177,12 @@ static MSVCRT_size_t strftime_helper(char *str, MSVCRT_size_t max, const char *f if(!strftime_int(str, &ret, max, mstm->tm_year%100, alternate ? 0 : 2, 0, 99)) return 0; break; + case 'e': + if(!strftime_int(str, &ret, max, mstm->tm_mday, alternate ? 0 : 2, 0, 31)) + return 0; + if(str[ret-2] == '0') + str[ret-2] = ' '; + break; case 'F': tmp = 1900+mstm->tm_year; if(!strftime_int(str, &ret, max, tmp, alternate ? 0 : 4, 0, 9999)) diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c index 1ba4280a546..aecbc9dca52 100644 --- a/dlls/ucrtbase/tests/misc.c +++ b/dlls/ucrtbase/tests/misc.c @@ -907,6 +907,14 @@ static void test_strftime(void) ok(retA == 6, "expected 6, got %d\n", (int)retA); ok(!strcmp(bufA, "1/1/70"), "got %s\n", bufA);
+ retA = p_strftime(bufA, sizeof(bufA), "%e", &epoch); + ok(retA == 2, "expected 2, got %d\n", (int)retA); + ok(!strcmp(bufA, " 1"), "got %s\n", bufA); + + retA = p_strftime(bufA, sizeof(bufA), "%#e", &epoch); + ok(retA == 1, "expected 1, got %d\n", (int)retA); + ok(!strcmp(bufA, "1"), "got %s\n", bufA); + retA = p_strftime(bufA, sizeof(bufA), "%F", &epoch); ok(retA == 10, "expected 10, got %d\n", (int)retA); ok(!strcmp(bufA, "1970-01-01"), "got %s\n", bufA);
Hi Vijay,
On 10/2/19 11:49 AM, Vijay Kiran Kamuju wrote:
if(str[ret-2] == '0')
str[ret-2] = ' ';
The if condition is incorrect, please fix it.
Thanks, Piotr