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

Source for file Netherlands.php

Documentation is available at Netherlands.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. /**
  4.  * Driver for determining holidays in the Netherlands.
  5.  *
  6.  * PHP Version 5
  7.  *
  8.  * Copyright (c) 1997-2008 The PHP Group
  9.  *
  10.  * This source file is subject to version 3.0 of the PHP license,
  11.  * that is bundled with this package in the file LICENSE, and is
  12.  * available at through the world-wide-web at
  13.  * http://www.php.net/license/3_01.txt.
  14.  * If you did not receive a copy of the PHP license and are unable to
  15.  * obtain it through the world-wide-web, please send a note to
  16.  * license@php.net so we can mail you a copy immediately.
  17.  *
  18.  * @category Date
  19.  * @package  Date_Holidays
  20.  * @author   Jos van der Woude <jos@veerkade.com>
  21.  * @author   Arjen de Korte <build+date_holidays@de-korte.org>
  22.  * @license  http://www.php.net/license/3_01.txt PHP License 3.0.1
  23.  * @version  CVS: $Id: Netherlands.php,v 1.9 2009/03/15 20:17:00 kguest Exp $
  24.  * @link     http://pear.php.net/package/Date_Holidays
  25.  */
  26.  
  27. require_once 'Date/Holidays/Driver/Christian.php';
  28.  
  29. /**
  30.  * Driver class that calculates Dutch holidays
  31.  *
  32.  * @category   Date
  33.  * @package    Date_Holidays
  34.  * @subpackage Driver
  35.  * @author     Jos van der Woude <jos@veerkade.com>
  36.  * @author     Arjen de Korte <build+date_holidays@de-korte.org>
  37.  * @license    http://www.php.net/license/3_01.txt PHP License 3.0.1
  38.  * @version    $Id: Netherlands.php,v 1.9 2009/03/15 20:17:00 kguest Exp $
  39.  * @link       http://pear.php.net/package/Date_Holidays
  40.  */
  41.  
  42. class Date_Holidays_Driver_Netherlands extends Date_Holidays_Driver
  43. {
  44.     /**
  45.      * this driver's name
  46.      *
  47.      * @access   protected
  48.      * @var      string 
  49.      */
  50.     var $_driverName = 'Netherlands';
  51.  
  52.     /**
  53.      * Constructor
  54.      *
  55.      * Use the Date_Holidays::factory() method to construct an object of a
  56.      * certain driver
  57.      *
  58.      * @access protected
  59.      */
  60.     {
  61.     }
  62.  
  63.     /**
  64.      * Build the internal arrays that contain data about the calculated holidays
  65.      *
  66.      * @access protected
  67.      * @return boolean true on success, otherwise a PEAR_ErrorStack object
  68.      * @throws object PEAR_ErrorStack
  69.      */
  70.     function _buildHolidays()
  71.     {
  72.         /**
  73.          * Start with all holidays that are on a fixed date each year
  74.          */
  75.  
  76.         /**
  77.          * New Year's Day
  78.          */
  79.         $this->_addHoliday(
  80.             'newYearsDay',
  81.             $this->_year '-01-01',
  82.             'New Year\'s Day'
  83.         );
  84.  
  85.         /**
  86.          * Epiphanias
  87.          */
  88.         $this->_addHoliday('epiphany'$this->_year '-01-06''Epiphany');
  89.  
  90.         /**
  91.          * Valentine's Day
  92.          */
  93.         $this->_addHoliday(
  94.             'valentineDay',
  95.             $this->_year '-02-14',
  96.             'Valentine\'s Day'
  97.         );
  98.  
  99.         /**
  100.          * Labour Day
  101.          */
  102.         $this->_addHoliday('labourDay'$this->_year '-05-01''Labour Day');
  103.  
  104.         /**
  105.          * Commemoration Day
  106.          */
  107.         $this->_addHoliday(
  108.             'commemorationDay',
  109.             ($this->_year >= 1947$this->_year '-05-04' '1947-05-04',
  110.             'Commemoration Day'
  111.         );
  112.  
  113.         /**
  114.          * Liberation Day
  115.          */
  116.         $this->_addHoliday(
  117.             'liberationDay',
  118.             ($this->_year >= 1947$this->_year '-05-05' '1947-05-05',
  119.             'Liberation Day'
  120.         );
  121.  
  122.         /**
  123.          * World Animal Day
  124.          */
  125.         $this->_addHoliday(
  126.             'worldAnimalDay',
  127.             $this->_year '-10-04',
  128.             'World Animal Day'
  129.         );
  130.  
  131.         /**
  132.          * Halloween
  133.          */
  134.         $this->_addHoliday('halloween'$this->_year '-10-31''Halloween');
  135.  
  136.         /**
  137.          * St. Martins Day
  138.          */
  139.         $this->_addHoliday(
  140.             'stMartinsDay',
  141.             $this->_year '-11-11',
  142.             'St. Martin\'s Day'
  143.         );
  144.  
  145.         /**
  146.          * St. Nicholas' Day
  147.          */
  148.         $this->_addHoliday(
  149.             'stNicholasDay',
  150.             $this->_year '-12-05',
  151.             'St. Nicholas\' Day'
  152.         );
  153.  
  154.         /**
  155.          * Christmas day
  156.          */
  157.         $this->_addHoliday(
  158.             'christmasDay',
  159.             $this->_year '-12-25',
  160.             'Christmas Day'
  161.         );
  162.  
  163.         /**
  164.          * Second Christmas Day
  165.          */
  166.         $this->_addHoliday(
  167.             'secondChristmasDay',
  168.             $this->_year '-12-26',
  169.             'Boxing Day'
  170.         );
  171.  
  172.         /**
  173.          * New Year's Eve
  174.          */
  175.         $this->_addHoliday(
  176.             'newYearsEve',
  177.             $this->_year '-12-31',
  178.             'New Year\'s Eve'
  179.         );
  180.  
  181.  
  182.         /**
  183.          * Following section is holidays that are a fixed offset from Easter (which
  184.          * differs each year)
  185.          */
  186.         $easterDate = Date_Holidays_Driver_Christian::calcEaster($this->_year);
  187.  
  188.         /**
  189.          * Carnival
  190.          */
  191.         $this->_addHoliday(
  192.             'carnival1',
  193.             $this->_addDays($easterDate-49),
  194.             'Carnival'
  195.         );
  196.         $this->_addHoliday(
  197.             'carnival2',
  198.             $this->_addDays($easterDate-48),
  199.             'Carnival'
  200.         );
  201.         $this->_addHoliday(
  202.             'carnival3',
  203.             $this->_addDays($easterDate-47),
  204.             'Carnival'
  205.         );
  206.  
  207.         /**
  208.          * Ash Wednesday
  209.          */
  210.         $this->_addHoliday(
  211.             'ashWednesday',
  212.             $this->_addDays($easterDate-46),
  213.             'Ash Wednesday'
  214.         );
  215.  
  216.         /**
  217.          * Green Thursday
  218.          */
  219.         $this->_addHoliday(
  220.             'greenThursday',
  221.             $this->_addDays($easterDate-3),
  222.             'Green Thursday'
  223.         );
  224.  
  225.         /**
  226.          * Good Friday / Black Friday
  227.          */
  228.         $this->_addHoliday(
  229.             'goodFriday',
  230.             $this->_addDays($easterDate-2),
  231.             'Good Friday'
  232.         );
  233.  
  234.         /**
  235.          * Silent Saturday
  236.          */
  237.         $this->_addHoliday(
  238.             'silentSaturday',
  239.             $this->_addDays($easterDate-1),
  240.             'Silent Saturday'
  241.         );
  242.  
  243.         /**
  244.          * Easter Sunday
  245.          */
  246.         $this->_addHoliday('easter'$easterDate'Easter Sunday');
  247.  
  248.         /**
  249.          * Easter Monday
  250.          */
  251.         $this->_addHoliday(
  252.             'easterMonday',
  253.             $this->_addDays($easterDate1),
  254.             'Easter Monday'
  255.         );
  256.  
  257.         /**
  258.          * Ascension Day
  259.          */
  260.         $this->_addHoliday(
  261.             'ascensionDay',
  262.             $this->_addDays($easterDate39),
  263.             'Ascension Day'
  264.         );
  265.  
  266.         /**
  267.          * Whitsun
  268.          */
  269.         $this->_addHoliday('whitsun'$this->_addDays($easterDate49)'Whitsun');
  270.  
  271.         /**
  272.          * Whit Monday
  273.          */
  274.         $this->_addHoliday(
  275.             'whitMonday',
  276.             $this->_addDays($easterDate50),
  277.             'Whit Monday'
  278.         );
  279.  
  280.  
  281.         /**
  282.          * Queen's Day was celebrated between 1891 and 1948 (inclusive) on
  283.          * August 31. Between 1949 and 2013 (inclusive) it was celebrated
  284.          * April 30.
  285.          * If these dates are on a Sunday, Queen's Day was celebrated one
  286.          * day later until 1980 (on the following Monday), starting 1980 one
  287.          * day earlier (on the preceding Saturday).
  288.          */
  289.         if (($this->_year >= 1891&& ($this->_year <= 2013)) {
  290.             $queenDay = new Date(($this->_year <= 1948$this->_year '-08-31' $this->_year '-04-30');
  291.             if ($queenDay->getDayOfWeek(== 0{
  292.                 $queenDay $this->_addDays($queenDay($this->_year < 1980? 1 : -1);
  293.             }
  294.         }
  295.         $this->_addHoliday('queenDay'isset($queenDay$queenDay '1980-04-30''Queen\'s Day');
  296.  
  297.  
  298.         /**
  299.          * King's Day is celebrated from 2014 onwards on April 27th. But
  300.          * here also, if this happens to be on a Sunday, it will be
  301.          * celebrated the day before instead.
  302.          */
  303.         if ($this->_year >= 2014{
  304.             $kingsDay = new Date($this->_year '-04-27');
  305.             if ($kingsDay->getDayOfWeek(== 0{
  306.                 $kingsDay $this->_addDays($kingsDay-1);
  307.             }
  308.         }
  309.         $this->_addHoliday('kingsDay'isset($kingsDay$kingsDay '2014-04-27''King\'s Day');
  310.  
  311.  
  312.         /**
  313.          * Lastly a number of holidays that are the second/third/last Sunday
  314.          * or Tuesday in a specific month (offset is calculated from the first
  315.          * of last possible date)
  316.          */
  317.  
  318.         /**
  319.          * Summertime last sunday of march
  320.          */
  321.         $summerTime = new Date($this->_year '-03-31');
  322.         $dayOfWeek  $summerTime->getDayOfWeek();
  323.         $summerTime $this->_addDays($summerTime-$dayOfWeek);
  324.         $this->_addHoliday('summerTime'$summerTime'Summertime');
  325.  
  326.         /**
  327.          * Mothers' Day second sunday of may
  328.          */
  329.         $mothersDay = new Date($this->_year '-05-08');
  330.         $dayOfWeek  $mothersDay->getDayOfWeek();
  331.         if ($dayOfWeek != 0{
  332.             $mothersDay $this->_addDays($mothersDay7 - $dayOfWeek);
  333.         }
  334.         $this->_addHoliday('mothersDay'$mothersDay'Mothers\' Day');
  335.  
  336.         /**
  337.          * Fathers' Day third sunday of june
  338.          */
  339.         $fathersDay = new Date($this->_year '-06-15');
  340.         $dayOfWeek  $fathersDay->getDayOfWeek();
  341.         if ($dayOfWeek != 0{
  342.             $fathersDay $this->_addDays($fathersDay7 - $dayOfWeek);
  343.         }
  344.         $this->_addHoliday('fathersDay'$fathersDay'Fathers\' Day');
  345.  
  346.         /**
  347.          * Start of Parliamentary Year third tuesday of september
  348.          */
  349.         $princesDay = new Date($this->_year '-09-15');
  350.         $dayOfWeek  $princesDay->getDayOfWeek();
  351.         if ($dayOfWeek <= 2{
  352.             $princesDay $this->_addDays($princesDay2 - $dayOfWeek);
  353.         else {
  354.             $princesDay $this->_addDays($princesDay9 - $dayOfWeek);
  355.         }
  356.         $this->_addHoliday('princesDay'$princesDay'Start of Parliamentary Year');
  357.  
  358.         /**
  359.          * Wintertime last sunday of october
  360.          */
  361.         $winterTime = new Date($this->_year '-10-31');
  362.         $dayOfWeek  $winterTime->getDayOfWeek();
  363.         $winterTime $this->_addDays($winterTime-$dayOfWeek);
  364.         $this->_addHoliday('winterTime'$winterTime'Wintertime');
  365.  
  366.         if (Date_Holidays::errorsOccurred()) {
  367.             return Date_Holidays::getErrorStack();
  368.         }
  369.  
  370.         return true;
  371.     }
  372.  
  373.     /**
  374.      * Method that returns an array containing the ISO3166 codes that may possibly
  375.      * identify a driver.
  376.      *
  377.      * @static
  378.      * @access public
  379.      * @return array possible ISO3166 codes
  380.      */
  381.     function getISO3166Codes()
  382.     {
  383.         return array('nl''nld');
  384.     }
  385. }
  386. ?>

Documentation generated on Tue, 01 Oct 2013 00:00:04 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.