Date_Holidays
[ class tree: Date_Holidays ] [ index: Date_Holidays ] [ all elements ]

Source for file EnglandWales.php

Documentation is available at EnglandWales.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors:   Tim Dodge <timmy@invisibles.org>                          |
  17. // +----------------------------------------------------------------------+
  18. //
  19. //    $Id: EnglandWales.php,v 1.2 2007/06/01 16:09:32 luckec Exp $
  20. require_once 'Date/Holidays/Driver/Christian.php'
  21. require_once 'Date/Holidays/Driver/USA.php'
  22.  
  23. /** 
  24.  * Driver class that calculates Danish holidays
  25.  * 
  26.  * @category Date
  27.  * @package Date_Holidays
  28.  * @subpackage Driver
  29.  * @version $Id: EnglandWales.php,v 1.2 2007/06/01 16:09:32 luckec Exp $
  30.  * @author Tim Dodge
  31.  */ 
  32. {
  33.     /** 
  34.      * Constructor
  35.      * 
  36.      * Use the Date_Holidays::factory() method to construct an object of a certain driver
  37.      * 
  38.      * @access protected
  39.      */
  40.     function Date_Holidays_Driver_EnglandWales({
  41.     
  42.     /** 
  43.      * Build the internal arrays that contain data about the calculated holidays
  44.      * 
  45.      * @access protected
  46.      * @return boolean true on success, otherwise a PEAR_ErrorStack object
  47.      * @throws object PEAR_ErrorStack
  48.      */ 
  49.     function _buildHolidays(
  50.     
  51.         /** 
  52.          * New Year's Day 
  53.          */ 
  54.         $newYearsDay = new Date($this->_year . '-01-01')
  55.         if ($newYearsDay->getDayOfWeek(== 0
  56.             $this->_addHoliday(
  57.                     'newYearsDay'
  58.                     $this->_year . '-01-02'
  59.                     'Substitute Bank Holiday in lieu of New Year\'s Day'
  60.             )
  61.         elseif ($newYearsDay->getDayOfWeek(== 6
  62.             $this->_addHoliday(
  63.                     'newYearsDay'
  64.                     $this->_year . '-01-03'
  65.                     'Substitute Bank Holiday in lieu of New Year\'s Day'
  66.             )
  67.         else 
  68.             $this->_addHoliday(
  69.                     'newYearsDay'
  70.                     $newYearsDay
  71.                     'New Year\'s Day'
  72.             )
  73.         
  74.         
  75.         /** 
  76.          * Easter Sunday 
  77.          */ 
  78.         $easterDate Date_Holidays_Driver_Christian::calcEaster($this->_year)
  79.         
  80.         /** 
  81.          * Good Friday 
  82.          */ 
  83.         $goodFridayDate = new Date($easterDate)
  84.         $goodFridayDate->subtractSpan(new Date_Span('2, 0, 0, 0'))
  85.         $this->_addHoliday('goodFriday'$goodFridayDate'Good Friday')
  86.         
  87.         /** 
  88.          * Easter Monday 
  89.          */ 
  90.         $this->_addHoliday('easterMonday'$easterDate->getNextDay()'Easter Monday')
  91.         
  92.         /** 
  93.          * May Day Bank Holiday 
  94.          */ 
  95.         $earlyMayDate Date_Holidays_Driver_USA::_calcNthMondayInMonth(51)
  96.         $this->_addHoliday('mayDay'$earlyMayDate'May Day Bank Holiday')
  97.         
  98.         /**
  99.          * Spring Bank Holiday 
  100.          */
  101.         $springBankDate Date_Holidays_Driver_USA::_calcLastMondayInMonth(5);
  102.         $this->_addHoliday('springBank'$springBankDate'Spring Bank Holiday')
  103.          
  104.         /** 
  105.          * Summer Bank Holiday 
  106.          */ 
  107.         $summerBankDate Date_Holidays_Driver_USA::_calcLastMondayInMonth(8)
  108.         $this->_addHoliday('summerBank'$summerBankDate'Summer Bank Holiday')
  109.          
  110.         /** 
  111.          * Christmas and Boxing Day 
  112.          */ 
  113.         $xmasDay = new Date($this->_year . '-12-25')
  114.         if ($xmasDay->getDayOfWeek(== 0
  115.             $this->_addHoliday('boxingDay'$this->_year . '-12-26''Boxing Day')
  116.             $this->_addHoliday(
  117.                     'xmasDay'
  118.                     $this->_year . '-12-27'
  119.                     'Substitute Bank Holiday in lieu of Christmas Day'
  120.             )
  121.         elseif ($xmasDay->getDayOfWeek(== 5
  122.             $this->_addHoliday('xmasDay'$xmasDay'Christmas Day')
  123.             $this->_addHoliday(
  124.                     'boxingDay'
  125.                     $this->_year . '-12-28'
  126.                     'Substitute Bank Holiday in lieu of Boxing Day'
  127.             )
  128.         elseif ($xmasDay->getDayOfWeek(== 6
  129.             $this->_addHoliday(
  130.                     'xmasDay'
  131.                     $this->_year . '-12-28'
  132.                     'Substitute Bank Holiday in lieu of Christmas Day'
  133.             )
  134.             $this->_addHoliday(
  135.                     'boxingDay'
  136.                     $this->_year . '-12-27'
  137.                     'Substitute Bank Holiday in lieu of Boxing Day'
  138.             );
  139.         else 
  140.             $this->_addHoliday('xmasDay'$xmasDay'Christmas Day')
  141.             $this->_addHoliday('boxingDay'$this->_year . '-12-26''Boxing Day')
  142.         
  143.         
  144.         if (Date_Holidays::errorsOccurred()) 
  145.             return Date_Holidays::getErrorStack()
  146.         
  147.         
  148.         return true; 
  149.     }
  150.     
  151.     /** 
  152.      * Method that returns an array containing the ISO3166 codes that may possibly
  153.      * identify a driver.
  154.      * 
  155.      * @static
  156.      * @access public
  157.      * @return array possible ISO3166 codes
  158.      */ 
  159.     function getISO3166Codes(
  160.         return array('gb''gbr')
  161.     
  162. ?>

Documentation generated on Mon, 11 Mar 2019 15:03:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.