|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-09-18 09:57 UTC] mj@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 19:00:01 2025 UTC |
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