msvcrt: Implement %F format for strftime.

Signed-off-by: Vijay Kiran Kamuju <infyquest@gmail.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Vijay Kiran Kamuju 2019-10-01 11:51:08 +02:00 committed by Alexandre Julliard
parent 1ed44b3554
commit 5da8af40dd
3 changed files with 26 additions and 0 deletions

View File

@ -613,6 +613,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, "%F", 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, "%R", gmt_tm);
ok(retA == 0, "expected 0, got %ld\n", retA);

View File

@ -1170,6 +1170,19 @@ 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 'F':
tmp = 1900+mstm->tm_year;
if(!strftime_int(str, &ret, max, tmp, alternate ? 0 : 4, 0, 9999))
return 0;
if(ret < max)
str[ret++] = '-';
if(!strftime_int(str, &ret, max, mstm->tm_mon+1, alternate ? 0 : 2, 1, 12))
return 0;
if(ret < max)
str[ret++] = '-';
if(!strftime_int(str, &ret, max, mstm->tm_mday, alternate ? 0 : 2, 0, 31))
return 0;
break;
#endif
case 'H':
if(!strftime_int(str, &ret, max, mstm->tm_hour, alternate ? 0 : 2, 0, 23))

View File

@ -903,6 +903,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), "%F", &epoch);
ok(retA == 10, "expected 10, got %d\n", (int)retA);
ok(!strcmp(bufA, "1970-01-01"), "got %s\n", bufA);
retA = p_strftime(bufA, sizeof(bufA), "%#F", &epoch);
ok(retA == 8, "expected 8, got %d\n", (int)retA);
ok(!strcmp(bufA, "1970-1-1"), "got %s\n", bufA);
retA = p_strftime(bufA, sizeof(bufA), "%R", &epoch);
ok(retA == 5, "expected 5, got %d\n", (int)retA);
ok(!strcmp(bufA, "00:00"), "got %s\n", bufA);