Commit 20810377 authored by Vijay Kiran Kamuju's avatar Vijay Kiran Kamuju Committed by Alexandre Julliard

msvcrt: Implement %R format for strftime.

parent 30913ff5
...@@ -609,6 +609,11 @@ static void test_strftime(void) ...@@ -609,6 +609,11 @@ static void test_strftime(void)
ok(gmt_tm != NULL, "gmtime failed\n"); ok(gmt_tm != NULL, "gmtime failed\n");
errno = 0xdeadbeef; errno = 0xdeadbeef;
retA = p_strftime(bufA, 256, "%R", 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, "%T", gmt_tm); retA = p_strftime(bufA, 256, "%T", gmt_tm);
ok(retA == 0, "expected 0, got %ld\n", retA); ok(retA == 0, "expected 0, got %ld\n", retA);
ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno); ok(errno==EINVAL || broken(errno==0xdeadbeef), "errno = %d\n", errno);
......
...@@ -1189,6 +1189,16 @@ static MSVCRT_size_t strftime_helper(char *str, MSVCRT_size_t max, const char *f ...@@ -1189,6 +1189,16 @@ static MSVCRT_size_t strftime_helper(char *str, MSVCRT_size_t max, const char *f
time_data->str.names.am : time_data->str.names.pm)) time_data->str.names.am : time_data->str.names.pm))
return 0; return 0;
break; break;
#if _MSVCR_VER>=140
case 'R':
if(!strftime_int(str, &ret, max, mstm->tm_hour, alternate ? 0 : 2, 0, 23))
return 0;
if(ret < max)
str[ret++] = ':';
if(!strftime_int(str, &ret, max, mstm->tm_min, alternate ? 0 : 2, 0, 59))
return 0;
break;
#endif
case 'S': case 'S':
if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, 59)) if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, 59))
return 0; return 0;
......
...@@ -895,6 +895,14 @@ static void test_strftime(void) ...@@ -895,6 +895,14 @@ static void test_strftime(void)
char bufA[256]; char bufA[256];
size_t retA; size_t retA;
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);
retA = p_strftime(bufA, sizeof(bufA), "%#R", &epoch);
ok(retA == 3, "expected 3, got %d\n", (int)retA);
ok(!strcmp(bufA, "0:0"), "got %s\n", bufA);
retA = p_strftime(bufA, sizeof(bufA), "%T", &epoch); retA = p_strftime(bufA, sizeof(bufA), "%T", &epoch);
ok(retA == 8, "expected 8, got %d\n", (int)retA); ok(retA == 8, "expected 8, got %d\n", (int)retA);
ok(!strcmp(bufA, "00:00:00"), "got %s\n", bufA); ok(!strcmp(bufA, "00:00:00"), "got %s\n", bufA);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment