msvcrt: Implement %u 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>
stable
Vijay Kiran Kamuju 2019-10-18 11:58:59 +02:00 committed by Alexandre Julliard
parent 6c6afb2ce9
commit 679cdc4010
3 changed files with 15 additions and 0 deletions

View File

@ -653,6 +653,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, "%u", 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(NULL, 0, "copy", gmt_tm);
ok(retA == 0, "expected 0, got %ld\n", retA);

View File

@ -1264,6 +1264,11 @@ static MSVCRT_size_t strftime_helper(char *str, MSVCRT_size_t max, const char *f
if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, 59))
return 0;
break;
case 'u':
tmp = mstm->tm_wday ? mstm->tm_wday : 7;
if(!strftime_int(str, &ret, max, tmp, 0, 1, 7))
return 0;
break;
#endif
case 'w':
if(!strftime_int(str, &ret, max, mstm->tm_wday, 0, 0, 6))

View File

@ -901,6 +901,7 @@ static void test_asctime(void)
static void test_strftime(void)
{
const struct tm epoch = { 0, 0, 0, 1, 0, 70, 4, 0, 0 };
const struct tm tm1 = { 0, 0, 0, 1, 0, 117, 0, 0, 0 };
char bufA[256];
size_t retA;
@ -948,6 +949,10 @@ static void test_strftime(void)
ok(retA == 5, "expected 5, got %d\n", (int)retA);
ok(!strcmp(bufA, "0:0:0"), "got %s\n", bufA);
retA = p_strftime(bufA, sizeof(bufA), "%u", &tm1);
ok(retA == 1, "expected 1, got %d\n", (int)retA);
ok(!strcmp(bufA, "7"), "got %s\n", bufA);
retA = p_strftime(bufA, sizeof(bufA), "%h", &epoch);
ok(retA == 3, "expected 3, got %d\n", (int)retA);
ok(!strcmp(bufA, "Jan"), "got %s\n", bufA);