mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:50 +01:00
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:
parent
bb797132fe
commit
bdf2cb9d91
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user