reimplemented the days_between function because it led to an infinite recursion in some cases and its simpler/faster now

This commit is contained in:
Ralf Becker 2003-02-26 16:44:11 +00:00
parent bb797132fe
commit bdf2cb9d91

View File

@ -425,40 +425,12 @@
/*!
@function days_between
@abstract Get the number of days between two dates
@author Steven Cramer
@author Steven Cramer/Ralf Becker
@param $m1 - Month_1, $d1 - Day_1, $y1 - Year_1, $m2 - Month_2, $d2 - Day_2, $y2 - Year_2
*/
function days_between($m1,$d1,$y1,$m2,$d2,$y2)
{
// $start = "$d1.$m1.$y1";
if ($y1 == $y2 && $m1 == $m2)
{
$days = $d2 - $d1;
}
else
{
$days = $this->days_in_month($m1,$y1) - $d1;
while ($m1 != $m2 || $y1 != $y2)
{
if ($m1+1 == 13)
{
$m1 = 1;
$y1++;
}
else
{
$m1++;
}
if ($m1 != $m2 || $y1 != $y2)
{
$days += $this->days_in_month($m1,$y1);
}
}
$days += $d2;
}
return $days;
return intval((mktime(0,0,0,$m2,$d2,$y2) - mktime(0,0,0,$m1,$d1,$y1)) / 86400);
}
function date_compare($a_year,$a_month,$a_day,$b_year,$b_month,$b_day)