cvs: php4 /pear/Date Calc.php

From: Date: Wed, 06 Dec 2000 19:36:44 +0000
Subject: cvs: php4 /pear/Date Calc.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2978@lists.php.net to get a copy of this message
mohrt Wed Dec 6 11:36:44 2000 EDT Modified files: /php4/pear/Date Calc.php Log: fixed bug with weeksInMonth() Index: php4/pear/Date/Calc.php diff -u php4/pear/Date/Calc.php:1.9 php4/pear/Date/Calc.php:1.10 --- php4/pear/Date/Calc.php:1.9 Wed Nov 22 06:21:42 2000 +++ php4/pear/Date/Calc.php Wed Dec 6 11:36:44 2000 @@ -24,7 +24,7 @@ * * @access public * - * @version 1.2.2 + * @version 1.2.3 * @author Monte Ohrt <monte@ispi.net> */ @@ -805,8 +805,20 @@ if(empty($month)) $month = Date_Calc::dateNow("%m"); - return ceil((Date_Calc::daysInMonth($month,$year)+Date_Calc::firstOfMonthWeekday($month,$year) - DATE_CALC_BEGIN_WEEKDAY)/7); + if(DATE_CALC_BEGIN_WEEKDAY == 1) + { + if(Date_Calc::firstOfMonthWeekday($month,$year) == 0) + $first_week_days = 1; + else + $first_week_days = 7 - (Date_Calc::firstOfMonthWeekday($month,$year) - 1); + + } + else + $first_week_days = 7 - Date_Calc::firstOfMonthWeekday($month,$year); + + return ceil(((Date_Calc::daysInMonth($month,$year) - $first_week_days) / 7) + 1); + } // end func weeksInMonth /** @@ -1056,8 +1068,17 @@ $month_array = array(); // date for the first row, first column of calendar month - $curr_day = (Date_Calc::dateToDays("01",$month,$year) - - Date_Calc::firstOfMonthWeekday($month,$year) + DATE_CALC_BEGIN_WEEKDAY); + if(DATE_CALC_BEGIN_WEEKDAY == 1) + { + if(Date_Calc::firstOfMonthWeekday($month,$year) == 0) + $curr_day = Date_Calc::dateToDays("01",$month,$year) - 6; + else + $curr_day = Date_Calc::dateToDays("01",$month,$year) + - Date_Calc::firstOfMonthWeekday($month,$year) + 1; + } + else + $curr_day = (Date_Calc::dateToDays("01",$month,$year) + - Date_Calc::firstOfMonthWeekday($month,$year)); // number of days in this month $daysInMonth = Date_Calc::daysInMonth($month,$year); @@ -1096,18 +1117,7 @@ $year_array = array(); for($curr_month=0; $curr_month <=11; $curr_month++) - { - $year_array[$curr_month] = Date_Calc::getCalendarMonth(sprintf("%02d",$curr_month+1),$year,$format); - - /* for ($x=0; $x< count($year_array[$curr_month]); $x++) - { - for($y=0; $y< count($year_array[$curr_month][$x]); $y++) - { - echo "DEBUG: $x,$y:".$year_array[$curr_month][$x][$y]."<br>\n"; - } - } */ - } return $year_array;

« previous php.cvs (#2978) next »