X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fcommon%2Fstrftime.c;h=803c3d8cd0d8803dde4e9b5b29672274d0912f68;hb=ea75fef1bf99fabff9c9eaa804468ee40339f87f;hp=467d13516452c958f896503434a2dbf77298d289;hpb=3ed8d565d468714b3958558c64c73533455c82e8;p=cc65 diff --git a/libsrc/common/strftime.c b/libsrc/common/strftime.c index 467d13516..803c3d8cd 100644 --- a/libsrc/common/strftime.c +++ b/libsrc/common/strftime.c @@ -67,7 +67,6 @@ size_t __fastcall__ strftime (char* buf, size_t bufsize, const char* format, char c; char arg[40]; const char* argptr; - unsigned week; /* Copy until we reach the end of the format string or a format specifier */ count = 0; @@ -132,20 +131,12 @@ size_t __fastcall__ strftime (char* buf, size_t bufsize, const char* format, break; case 'U': - week = tm->tm_yday / 7; - if (tm->tm_mday % 7 > tm->tm_wday) { - ++week; - } - sprintf (arg, "%02u", week); + sprintf (arg, "%02d", (tm->tm_yday + 7 - tm->tm_wday) / 7); break; case 'W': - /* ### This one is buggy */ - week = tm->tm_yday / 7; - if (tm->tm_mday % 7 > tm->tm_wday) { - ++week; - } - sprintf (arg, "%2u", week); + sprintf (arg, "%02d", + (tm->tm_yday + 7 - (tm->tm_wday? tm->tm_wday - 1 : 6)) / 7); break; case 'X':