From 6342caa4e633abbbd5d8ddac58e637341b4d57fb Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 13 Sep 2001 20:40:49 +0000 Subject: Thu Sep 13 08:49:49 2001 Jason Tishler * strftime.c (strftime): Fix "%W" implementation to properly handle Mondays too. --- newlib/libc/time/strftime.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'newlib/libc/time/strftime.c') diff --git a/newlib/libc/time/strftime.c b/newlib/libc/time/strftime.c index 1e6154f12..1b44e1db9 100644 --- a/newlib/libc/time/strftime.c +++ b/newlib/libc/time/strftime.c @@ -362,9 +362,10 @@ _DEFUN (strftime, (s, maxsize, format, tim_p), case 'W': if (count < maxsize - 2) { + int wday = (tim_p->tm_wday) ? tim_p->tm_wday - 1 : 6; sprintf (&s[count], "%2.2d", - (tim_p->tm_yday + ((8 - - tim_p->tm_wday) % 7)) / 7); + (tim_p->tm_yday + 7 - + wday) / 7); count += 2; } else -- cgit v1.2.3