cvs: php4 /pear/Date Calc.php
| From: | Monte Ohrt | Date: | Tue, 17 Oct 2000 14:05:13 +0000 |
| Subject: | cvs: php4 /pear/Date Calc.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2087@lists.php.net to get a copy of this message | ||
mohrt Tue Oct 17 07:05:13 2000 EDT
Modified files:
/php4/pear/Date Calc.php
Log:
fixed a bug in daysInMonth()
Index: php4/pear/Date/Calc.php
diff -u php4/pear/Date/Calc.php:1.3 php4/pear/Date/Calc.php:1.4
--- php4/pear/Date/Calc.php:1.3 Mon Oct 16 07:24:50 2000
+++ php4/pear/Date/Calc.php Tue Oct 17 07:05:12 2000
@@ -19,7 +19,7 @@
*
* @access public
*
- * @version 1.0.3
+ * @version 1.0.4
* @author Monte Ohrt <monte@ispi.net>
*/
@@ -90,7 +90,7 @@
return false;
if($month < 1 || $month > 12)
return false;
- if($day < 1 || $day > 31 || $day > $this->daysInMonth($month))
+ if($day < 1 || $day > 31 || $day > $this->daysInMonth($year,$month))
return false;
return true;
@@ -386,7 +386,7 @@
$day = $this->dateNow("%d");
}
- $day = $this->daysInMonth($month);
+ $day = $this->daysInMonth($year,$month);
if($month < 12)
{
@@ -466,7 +466,7 @@
$day = $this->dateNow("%d");
}
- $day = $this->daysInMonth($month);
+ $day = $this->daysInMonth($year,$month);
if($month > 1)
{
@@ -684,10 +684,12 @@
* @return int number of days
*/
- function daysInMonth($month="")
+ function daysInMonth($year="",$month="")
{
if(empty($month))
$month = $this->dateNow("%m");
+ if(empty($year))
+ $month = $this->dateNow("%Y");
if($month == 2)
{
@@ -973,7 +975,7 @@
- $this->firstOfMonthWeekday($year,$month,"01") +
$this->begin_weekday);
// number of days in this month
- $daysInMonth = $this->daysInMonth($month);
+ $daysInMonth = $this->daysInMonth($year,$month);
for($row_counter=0; $row_counter <= 5; $row_counter++)
{
@@ -1145,7 +1147,7 @@
$wdate = ($occurance - 1) * 7 + 1 +
(7 + $dayOfWeek - $DOW1) % 7;
- if( $wdate > $this->daysInMonth($date))
+ if( $wdate > $this->daysInMonth($year,$month))
return -1;
else
return($this->dateFormat($year,$month,$wdate,$format));
@@ -1429,7 +1431,7 @@
$weekday_names = array("Sunday","Monday","Tuesday",
"Wednesday","Thursday","Friday","Saturday");
- $weekday = $this->dayOfWeek($year,$month,$date);
+ $weekday = $this->dayOfWeek($year,$month,$day);
return substr($weekday_names[$weekday],0,$length);