Piotr Caban : msvcrt: Added support for %W and %U format in strftime.
Alexandre Julliard
julliard at winehq.org
Mon Apr 16 13:35:46 CDT 2012
Module: wine
Branch: master
Commit: bfa3045816d2d9caf64b4a13fb06fb77b6361ef6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bfa3045816d2d9caf64b4a13fb06fb77b6361ef6
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon Apr 16 12:26:16 2012 +0200
msvcrt: Added support for %W and %U format in strftime.
---
dlls/msvcrt/tests/time.c | 26 ++++++++++++++++++++++++++
dlls/msvcrt/time.c | 16 +++++++++++++---
2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcrt/tests/time.c b/dlls/msvcrt/tests/time.c
index 6fb7491..c6e2a9c 100644
--- a/dlls/msvcrt/tests/time.c
+++ b/dlls/msvcrt/tests/time.c
@@ -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);
diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c
index 69bd391..bc68218 100644
--- a/dlls/msvcrt/time.c
+++ b/dlls/msvcrt/time.c
@@ -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;
More information about the wine-cvs
mailing list