1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
class Date_Ferie
{
private $tabDay = array();
private $annee;
public function __construct($annee)
{
$this->annee = $annee;
$this->tabDay[] = $annee . '-01-01';
$this->tabDay[] = ($annee + 1) . '-01-01';
$this->tabDay[] = ($annee - 1) . '-01-01';
$this->tabDay[] = $annee . '-05-01';
$this->tabDay[] = $annee . '-05-08';
$this->tabDay[] = $annee . '-07-14';
$this->tabDay[] = $annee . '-08-15';
$this->tabDay[] = $annee . '-11-01';
$this->tabDay[] = $annee . '-11-11';
$this->tabDay[] = $annee . '-12-25';
$this->computeDay();
}
private function computeDay()
{
//Paques
$tsPaques = @easter_date($this->annee);
$this->tabDay[] = date("Y-m-d", $tsPaques + 86400);
//Ascencion
$this->tabDay[] = date("Y-m-d", strtotime('+39 days', $tsPaques));
//Pantecote
$this->tabDay[] = date("Y-m-d", strtotime('+50 days', $tsPaques));
}
//Format de la date Y-m-d
public function isFerie($date)
{
return in_array($date, $this->tabDay);
}
}
$date= new Date_Ferie(2011);
$date->isFerie('2011-12-25'); // true |
Partager