1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24:
25: class Date_Ferie
26: {
27:
28: 29: 30: 31:
32: private $tabDay = array();
33:
34: 35: 36: 37:
38: private $annee;
39:
40: 41: 42: 43:
44: public function __construct($annee)
45: {
46: if (strlen($annee) < 4)
47: throw new InvalidArgumentException('Annee doit être sur 4 chiffres');
48:
49: $this->annee = $annee;
50: $this->tabDay[] = $annee . '-01-01';
51: $this->tabDay[] = ($annee + 1) . '-01-01';
52: $this->tabDay[] = ($annee - 1) . '-01-01';
53: $this->tabDay[] = $annee . '-05-01';
54: $this->tabDay[] = $annee . '-05-08';
55: $this->tabDay[] = $annee . '-07-14';
56: $this->tabDay[] = $annee . '-08-15';
57: $this->tabDay[] = $annee . '-11-01';
58: $this->tabDay[] = $annee . '-11-11';
59: $this->tabDay[] = $annee . '-12-25';
60: $this->computeDay();
61: }
62:
63: 64: 65:
66: private function computeDay()
67: {
68:
69: $tsPaques = @easter_date($this->annee);
70: $this->tabDay[] = date("Y-m-d", $tsPaques + 86400);
71:
72: $this->tabDay[] = date("Y-m-d", strtotime('+39 days', $tsPaques));
73:
74: $this->tabDay[] = date("Y-m-d", strtotime('+50 days', $tsPaques));
75: }
76:
77: 78: 79: 80: 81:
82: public function isFerie($date)
83: {
84: if (!is_string($date))
85: throw new InvalidArgumentException('Date sous forme Y-m-d');
86:
87: return in_array($date, $this->tabDay);
88: }
89:
90: 91: 92: 93:
94: public function getDays()
95: {
96: return $this->tabDay;
97: }
98:
99: }
100:
101: ?>