#19334 [NEW]: NWeekdayOfMonth() in Date::Calc makes incorrect function calls

From: Date: Tue, 10 Sep 2002 14:16:38 +0000
Subject: #19334 [NEW]: NWeekdayOfMonth() in Date::Calc makes incorrect function calls
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-8999@lists.php.net to get a copy of this message
From: dswhite42@yahoo.com Operating system: Linux 2.4.18 (Red Hat) PHP version: 4.2.3 PHP Bug Type: PEAR related Bug description: NWeekdayOfMonth() in Date::Calc makes incorrect function calls 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 bug report at http://bugs.php.net/?id=19334&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=19334&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=19334&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=19334&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=19334&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=19334&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=19334&r=support Expected behavior: http://bugs.php.net/fix.php?id=19334&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=19334&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=19334&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=19334&r=globals

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