msvcrt: Added support for %W and %U format in strftime.
This commit is contained in:
parent
34457aa4c3
commit
bfa3045816
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue