<?php
function getEaster ($iYear = null) {
if (is_null ($iYear)) {
$iYear = (int)date ('Y');
}
$iN = $iYear - 1900;
$iA = $iN%19;
$iB = floor (((7*$iA)+1)/19);
$iC = ((11*$iA)-$iB+4)%29;
$iD = floor ($iN/4);
$iE = ($iN-$iC+$iD+31)%7;
$iResult = 25-$iC-$iE;
if ($iResult > 0) {
$iEaster = strtotime ($iYear.'/04/'.$iResult);
} else {
$iEaster = strtotime ($iYear.'/03/'.(31+$iResult));
}
return $iEaster;
}
echo 'Paques : ', date ('d-m-Y', getEaster (2006));
echo '<br />';
function getNextOpenDay ($iDate, $iDays) {
$aBankHolidays = array (
'1_1',
'1_5',
'8_5',
'14_7',
'15_8',
'1_11',
'11_11',
'25_12'
);
if (function_exists ('easter_date')) {
$iEaster = easter_date ((int)date('Y'), $iDate);
} else {
$iEaster = getEaster ((int)date('Y'), $iDate);
}
$aBankHolidays[] = date ('j_n',$iEaster);
$aBankHolidays[] = date ('j_n', $iEaster + (86400*39));
$aBankHolidays[] = date ('j_n', $iEaster + (86400*49));
print_r ($aBankHolidays);
$iEnd = $iDays * 86400;
$i = 0;
while ($i < $iEnd) {
$i = strtotime ('+1 day', $i);
if (in_array (date ('w', $iDate+$i),array (0,6) ) || in_array (date ('j_n', $iDate+$i), $aBankHolidays)) {
$iEnd = strtotime ('+1 day', $iEnd);
$iDays ++;
}
}
return $iDays;
}
$iDate = strtotime ('2006-06-30');
$iDays = getNextOpenDay ($iDate, 2);
echo 'Prochain jour ouvrable à partir du 30/06/2006, avec un delta de 2 jours : ', date ('d/m/Y', $iDate + (86400*$iDays));
?>