Overview

Packages

  • Auth
  • Config
  • Controller
  • Date
  • Db
  • Feed
    • Abstract
    • Writers
  • File
    • Decorator
  • Form
    • Element
  • Image
  • Log
    • Writer
  • Net
    • Exception
  • None
  • PHP
  • PHPMailer
  • Session
  • Util
  • Validate
    • Validator
  • Zend
    • Registry

Classes

  • Date_Ferie
  • Date_Weeks
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * Pry Framework
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file LICENSE.txt.
 10:  * 
 11:  * @version $Revision: 276 $
 12:  */
 13: 
 14: /**
 15:  * Classe Ferie
 16:  *
 17:  * Class permettant de trouver les jours fériés d'une année. Valable pour la France
 18:  *
 19:  * @category Pry
 20:  * @package Date
 21:  * @version 1.1.0
 22:  * @author Olivier ROGER <oroger.fr>
 23:  *
 24:  */
 25: class Date_Ferie
 26: {
 27: 
 28:     /**
 29:      * Liste des jours férié
 30:      * @var array
 31:      */
 32:     private $tabDay = array();
 33: 
 34:     /**
 35:      * Année format YYYY
 36:      * @var int
 37:      */
 38:     private $annee;
 39: 
 40:     /**
 41:      * Constructeur. Initialise les jours fériés fixes
 42:      * @param int $annee
 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:      * Calcul les jours fériés pouvant l'être
 65:      */
 66:     private function computeDay()
 67:     {
 68:         //Paques
 69:         $tsPaques = @easter_date($this->annee);
 70:         $this->tabDay[] = date("Y-m-d", $tsPaques + 86400);
 71:         //Ascencion
 72:         $this->tabDay[] = date("Y-m-d", strtotime('+39 days', $tsPaques));
 73:         //Pantecote
 74:         $this->tabDay[] = date("Y-m-d", strtotime('+50 days', $tsPaques));
 75:     }
 76: 
 77:     /**
 78:      * Vérifie si un jour est férié
 79:      * @param string $date Date au format Y-m-d
 80:      * @return boolean
 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:      * Liste des jours fériés
 92:      * @return array Liste des jours fériés 
 93:      */
 94:     public function getDays()
 95:     {
 96:         return $this->tabDay;
 97:     }
 98: 
 99: }
100: 
101: ?>
Pry Framework API documentation generated by ApiGen 2.6.1