Commit bfa30458 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added support for %W and %U format in strftime.

parent 34457aa4
......@@ -704,6 +704,32 @@ static void test_strftime(void)
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "AM"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%U", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "00"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%W", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "00"), "got %s\n", bufA);
gmt_tm->tm_wday = 0;
retA = strftime(bufA, 256, "%U", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "01"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%W", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "00"), "got %s\n", bufA);
gmt_tm->tm_yday = 365;
retA = strftime(bufA, 256, "%U", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "53"), "got %s\n", bufA);
retA = strftime(bufA, 256, "%W", gmt_tm);
ok(retA == 2, "expected 2, got %ld\n", retA);
ok(!strcmp(bufA, "52"), "got %s\n", bufA);
gmt_tm->tm_mon = 1;
gmt_tm->tm_mday = 30;
retA = strftime(bufA, 256, "%c", gmt_tm);
......
......@@ -1077,9 +1077,19 @@ MSVCRT_size_t CDECL _Strftime(char *str, MSVCRT_size_t max, const char *format,
break;
case 'U':
case 'W':
FIXME("format %c not yet supported (%x)\n", *format, alternate);
str[0] = 0;
return 0;
if(mstm->tm_wday<0 || mstm->tm_wday>6 || mstm->tm_yday<0 || mstm->tm_yday>365)
goto einval_error;
if(*format == 'U')
tmp = mstm->tm_wday;
else if(!mstm->tm_wday)
tmp = 6;
else
tmp = mstm->tm_wday-1;
tmp = mstm->tm_yday/7 + (tmp<=mstm->tm_yday%7);
if(!strftime_int(str, &ret, max, tmp, alternate ? 0 : 2, 0, 53))
return 0;
break;
case '%':
str[ret++] = '%';
break;
......
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