Fix: Bad month return by function
This commit is contained in:
parent
05fe8e45b3
commit
742d0e37ee
@ -518,8 +518,8 @@ function dol_get_last_day($year,$month=12,$gm=false)
|
|||||||
* @param int $day Day
|
* @param int $day Day
|
||||||
* @param int $month Month
|
* @param int $month Month
|
||||||
* @param int $year Year
|
* @param int $year Year
|
||||||
* @param int $gm False = Return date to compare with server TZ, True to compare with GM date.
|
* @param int $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
|
||||||
* @return array year,month, week,first_day,prev_year,prev_month,prev_day
|
* @return array year,month,week,first_day,prev_year,prev_month,prev_day
|
||||||
*/
|
*/
|
||||||
function dol_get_first_day_week($day,$month,$year,$gm=false)
|
function dol_get_first_day_week($day,$month,$year,$gm=false)
|
||||||
{
|
{
|
||||||
@ -542,7 +542,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
|
|||||||
$tmpday = date($tmparray[0])-$seconds;
|
$tmpday = date($tmparray[0])-$seconds;
|
||||||
$tmpday = date("d",$tmpday);
|
$tmpday = date("d",$tmpday);
|
||||||
|
|
||||||
//Check first day of week is form this month or not
|
//Check first day of week is in same month than current day or not
|
||||||
if ($tmpday>$day)
|
if ($tmpday>$day)
|
||||||
{
|
{
|
||||||
$prev_month = $month-1;
|
$prev_month = $month-1;
|
||||||
@ -559,15 +559,17 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
|
|||||||
$prev_month = $month;
|
$prev_month = $month;
|
||||||
$prev_year = $year;
|
$prev_year = $year;
|
||||||
}
|
}
|
||||||
|
$tmpmonth = $prev_month;
|
||||||
|
$tmpyear = $prev_year;
|
||||||
|
|
||||||
//Get first day of next week
|
//Get first day of next week
|
||||||
$tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0);
|
$tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0);
|
||||||
$tmptime-=24*60*60*7;
|
$tmptime-=24*60*60*7;
|
||||||
$tmparray=dol_getdate($tmptime,true);
|
$tmparray=dol_getdate($tmptime,true);
|
||||||
$prev_day = $tmparray['mday'];
|
$prev_day = $tmparray['mday'];
|
||||||
|
|
||||||
//Check first day of week is form this month or not
|
//Check prev day of week is in same month than first day or not
|
||||||
if ($prev_day>$tmpday)
|
if ($prev_day > $tmpday)
|
||||||
{
|
{
|
||||||
$prev_month = $month-1;
|
$prev_month = $month-1;
|
||||||
$prev_year = $year;
|
$prev_year = $year;
|
||||||
@ -579,9 +581,9 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$week = date("W",dol_mktime(0,0,0,$month,$tmpday,$year,$gm));
|
$week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm));
|
||||||
|
|
||||||
return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day);
|
return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'first_month' => $tmpmonth, 'first_year' => $tmpyear, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user