#19334 [Opn->Csd]: NWeekdayOfMonth() in Date::Calc makes incorrect function calls

From: Date: Wed, 18 Sep 2002 14:57:26 +0000
Subject: #19334 [Opn->Csd]: NWeekdayOfMonth() in Date::Calc makes incorrect function calls
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-9169@lists.php.net to get a copy of this message
ID: 19334 Updated by: mj@php.net Reported By: dswhite42@yahoo.com -Status: Open +Status: Closed Bug Type: PEAR related Operating System: Linux 2.4.18 (Red Hat) PHP Version: 4.2.3 New Comment: This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2002-09-10 09:16:38] dswhite42@yahoo.com The NWeekdayOfMonth() function in the PEAR Date::Calc class calls 2 other Date::Calc functions using incorrect parameters. This produces results that are almost always invalid. Line 1246 of Date/Calc.php is: $DOW1 = Date_Calc::dayOfWeek($month,$year,$DOW1day); when it should be: $DOW1 = Date_Calc::dayOfWeek($DOW1day,$month,$year); Line 1254 of Date/Calc.php is: return(Date_Calc::dateFormat($month,$year,$wdate,$format)); when it should be: return(Date_Calc::dateFormat($wdate,$month,$year,$format)); Here is the patch: ------------------------------------- --- Calc.php.orig Tue Sep 10 09:51:08 2002 +++ Calc.php Tue Sep 10 09:51:09 2002 @@ -1243,7 +1243,7 @@ $month = sprintf("%02d",$month); $DOW1day = sprintf("%02d",(($occurance - 1) * 7 + 1)); - $DOW1 = Date_Calc::dayOfWeek($month,$year,$DOW1day); + $DOW1 = Date_Calc::dayOfWeek($DOW1day,$month,$year); $wdate = ($occurance - 1) * 7 + 1 + (7 + $dayOfWeek - $DOW1) % 7; @@ -1251,7 +1251,7 @@ if( $wdate > Date_Calc::daysInMonth($month,$year)) return -1; else - return(Date_Calc::dateFormat($month,$year,$wdate,$format)); + return(Date_Calc::dateFormat($wdate,$month,$year,$format)); } // end func NWeekdayOfMonth ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19334&edit=1

« previous php.pear.dev (#9169) next »