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

Source for file Germany.php

Documentation is available at Germany.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. /**
  4.  * Driver for holidays in Germany
  5.  *
  6.  * PHP Version 4
  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   Stephan Schmidt <schst@php-tools.net>
  21.  * @author   Carsten Lucke <luckec@tool-garage.de>
  22.  * @license  http://www.php.net/license/3_01.txt PHP License 3.0.1
  23.  * @version  CVS: $Id: Germany.php,v 1.11 2008/01/26 00:08:34 kguest Exp $
  24.  * @link     http://pear.php.net/package/Date_Holidays
  25.  */
  26.  
  27. /**
  28.  * Extends Christian driver
  29.  */
  30. require_once 'Date/Holidays/Driver/Christian.php';
  31.  
  32. /**
  33.  * class that calculates German holidays
  34.  *
  35.  * @category   Date
  36.  * @package    Date_Holidays
  37.  * @subpackage Driver
  38.  * @author     Carsten Lucke <luckec@tool-garage.de>
  39.  * @author     Stephan Schmidt <schst@php.net>
  40.  * @license    http://www.php.net/license/3_01.txt PHP License 3.0.1
  41.  * @version    CVS: $Id: Germany.php,v 1.11 2008/01/26 00:08:34 kguest Exp $
  42.  * @link       http://pear.php.net/package/Date_Holidays
  43.  */
  44. {
  45.     /**
  46.      * Constructor
  47.      *
  48.      * Use the Date_Holidays::factory() method to construct an object of a
  49.      * certain driver
  50.      *
  51.      * @access   protected
  52.      */
  53.     function Date_Holidays_Driver_Germany()
  54.     {
  55.     }
  56.  
  57.     /**
  58.      * Build the internal arrays that contain data about the calculated holidays
  59.      *
  60.      * @access   protected
  61.      * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  62.      * @throws   object PEAR_ErrorStack
  63.      */
  64.     function _buildHolidays()
  65.     {
  66.         parent::_buildHolidays();
  67.  
  68.         $easterDate       $this->getHolidayDate('easter');
  69.         $ashWednesdayDate $this->getHolidayDate('ashWednesday');
  70.         $ascensionDayDate $this->getHolidayDate('ascensionDay');
  71.         $advent1Date      $this->getHolidayDate('advent1');
  72.  
  73.         /**
  74.          * New Year's Day
  75.          */
  76.         $this->_addHoliday('newYearsDay',
  77.                            $this->_year . '-01-01',
  78.                            'New Year\'s Day');
  79.  
  80.         /**
  81.          * Valentine's Day
  82.          */
  83.         $this->_addHoliday('valentinesDay',
  84.                            $this->_year . '-02-14',
  85.                            'Valentine\'s Day');
  86.  
  87.         /**
  88.          * "Weiberfastnacht"
  89.          */
  90.         $wFasnetDate = new Date($ashWednesdayDate);
  91.         $wFasnetDate->subtractSpan(new Date_Span('6, 0, 0, 0'));
  92.         $this->_addHoliday('womenFasnet'$wFasnetDate'Carnival');
  93.  
  94.         /**
  95.          * Carnival / "Fastnacht"
  96.          */
  97.         $fasnetDate = new Date($easterDate);
  98.         $fasnetDate->subtractSpan(new Date_Span('47, 0, 0, 0'));
  99.         $this->_addHoliday('fasnet'$fasnetDate'Carnival');
  100.  
  101.         /**
  102.          * Rose Monday
  103.          */
  104.         $roseMondayDate = new Date($easterDate);
  105.         $roseMondayDate->subtractSpan(new Date_Span('48, 0, 0, 0'));
  106.         $this->_addHoliday('roseMonday'$roseMondayDate'Rose Monday');
  107.  
  108.         /**
  109.          * International Women's Day
  110.          */
  111.         $this->_addHoliday('womensDay',
  112.                            $this->_year . '-03-08',
  113.                            'International Women\'s Day');
  114.  
  115.         /**
  116.          * April 1st
  117.          */
  118.         $this->_addHoliday('april1st'$this->_year . '-04-01''April 1st');
  119.  
  120.         /**
  121.          * Girls' Day (fourth Thursday in April)
  122.          */
  123.         $girlsDayDate = new Date($this->_year . '-04-01');
  124.         $dayOfWeek    $girlsDayDate->getDayOfWeek();
  125.         switch ($dayOfWeek{
  126.         case 0:
  127.         case 1:
  128.         case 2:
  129.         case 3:
  130.             $span = new Date_Span(sprintf('%d, 0, 0, 0'4 - $dayOfWeek + 21));
  131.             breaK;
  132.         case 4:
  133.             $span = new Date_Span('21, 0, 0, 0');
  134.             breaK;
  135.         case 5:
  136.         case 6:
  137.             $span = new Date_Span(sprintf('%d, 0, 0, 0'-1 * $dayOfWeek + 11 + 21));
  138.             breaK;
  139.         }
  140.         $girlsDayDate->addSpan($span);
  141.         $this->_addHoliday('girlsDay'$girlsDayDate'Girls\' Day');
  142.  
  143.         /**
  144.          * International Earth' Day
  145.          */
  146.         $this->_addHoliday('earthDay',
  147.                            $this->_year . '-04-22',
  148.                            'International Earth\' Day');
  149.  
  150.         /**
  151.          * German Beer's Day
  152.          */
  153.         $this->_addHoliday('beersDay',
  154.                            $this->_year . '-04-23',
  155.                            'German Beer\'s Day');
  156.  
  157.         /**
  158.          * Walpurgis Night
  159.          */
  160.         $this->_addHoliday('walpurgisNight',
  161.                            $this->_year . '-04-30',
  162.                            'Walpurgis Night');
  163.  
  164.         /**
  165.          * Day of Work
  166.          */
  167.         $this->_addHoliday('dayOfWork',
  168.                            $this->_year . '-05-01',
  169.                            'Day of Work');
  170.  
  171.         /**
  172.          * World's Laughing Day
  173.          */
  174.         $laughingDayDate = new Date($this->_year . '-05-01');
  175.         while ($laughingDayDate->getDayOfWeek(!= 0{
  176.             $laughingDayDate $laughingDayDate->getNextDay();
  177.         }
  178.         $this->_addHoliday('laughingDay',
  179.                            $laughingDayDate,
  180.                            'World\'s Laughing Day');
  181.  
  182.         /**
  183.          * Europe Day
  184.          */
  185.         $this->_addHoliday('europeDay',
  186.                            $this->_year . '-05-05',
  187.                            'Europe Day');
  188.  
  189.         /**
  190.          * Mothers' Day
  191.          */
  192.         $mothersDay = new Date($laughingDayDate);
  193.         $mothersDay->addSpan(new Date_Span('7, 0, 0, 0'));
  194.         $this->_addHoliday('mothersDay'$mothersDay'Mothers\' Day');
  195.  
  196.         /**
  197.          * End of World War 2 in Germany
  198.          */
  199.         $this->_addHoliday('endOfWWar2',
  200.                            $this->_year . '-05-08',
  201.                            'End of World War 2 in Germany');
  202.  
  203.         /**
  204.          * Fathers' Day
  205.          */
  206.         $this->_addHoliday('fathersDay'$ascensionDayDate'Fathers\' Day');
  207.  
  208.         /**
  209.          * Amnesty International Day
  210.          */
  211.         $this->_addHoliday('aiDay',
  212.                            $this->_year . '-05-28',
  213.                            'Amnesty International Day');
  214.  
  215.         /**
  216.          * International Children' Day
  217.          */
  218.         $this->_addHoliday('intChildrenDay',
  219.                            $this->_year . '-06-01',
  220.                            'International Children\'s Day');
  221.  
  222.         /**
  223.          * Day of organ donation
  224.          */
  225.         $organDonationDate = new Date($this->_year . '-06-01');
  226.         while ($organDonationDate->getDayOfWeek(!= 6{
  227.             $organDonationDate $organDonationDate->getNextDay();
  228.         }
  229.         $this->_addHoliday('organDonationDay',
  230.                            $organDonationDate,
  231.                            'Day of organ donation');
  232.  
  233.         /**
  234.          * Dormouse' Day
  235.          */
  236.         $this->_addHoliday('dormouseDay',
  237.                            $this->_year . '-06-27',
  238.                            'Dormouse\' Day');
  239.  
  240.         /**
  241.          * Christopher Street Day
  242.          */
  243.         $this->_addHoliday('christopherStreetDay',
  244.                            $this->_year . '-06-27',
  245.                            'Christopher Street Day');
  246.  
  247.         /**
  248.          * Hiroshima Commemoration Day
  249.          */
  250.         $this->_addHoliday('hiroshimaCommemorationDay',
  251.                            $this->_year . '-08-06',
  252.                            'Hiroshima Commemoration Day');
  253.  
  254.         /**
  255.          * Augsburg peace celebration
  256.          */
  257.         $this->_addHoliday('augsburgPeaceCelebration',
  258.                            $this->_year . '-08-08',
  259.                            'Augsburg peace celebration');
  260.  
  261.         /**
  262.          * International left-handeds' Day
  263.          */
  264.         $this->_addHoliday('leftHandedDay',
  265.                            $this->_year . '-08-13',
  266.                            'International left-handeds\' Day');
  267.  
  268.         /**
  269.          * Anti-War Day
  270.          */
  271.         $this->_addHoliday('antiWarDay',
  272.                            $this->_year . '-09-01',
  273.                            'Anti-War Day');
  274.  
  275.         /**
  276.          * Day of German Language
  277.          */
  278.         $germanLangDayDate = new Date($this->_year . '-09-01');
  279.         while ($germanLangDayDate->getDayOfWeek(!= 6{
  280.             $germanLangDayDate $germanLangDayDate->getNextDay();
  281.         }
  282.         $germanLangDayDate->addSpan(new Date_Span('7, 0, 0, 0'));
  283.         $this->_addHoliday('germanLanguageDay',
  284.                            $germanLangDayDate,
  285.                            'Day of German Language');
  286.  
  287.         /**
  288.          * International diabetes day
  289.          */
  290.         $this->_addHoliday('diabetesDay',
  291.                            $this->_year . '-11-14',
  292.                            'International diabetes day');
  293.  
  294.         /**
  295.          * German Unification Day
  296.          */
  297.         $this->_addHoliday('germanUnificationDay',
  298.                            $this->_year . '-10-03',
  299.                            'German Unification Day');
  300.  
  301.         /**
  302.          * Libraries' Day
  303.          */
  304.         $this->_addHoliday('librariesDay',
  305.                            $this->_year . '-10-24',
  306.                            'Libraries\' Day');
  307.  
  308.         /**
  309.          * World's Savings Day
  310.          */
  311.         $this->_addHoliday('savingsDay',
  312.                            $this->_year . '-10-30',
  313.                            'World\'s Savings Day');
  314.  
  315.         /**
  316.          * Halloween
  317.          */
  318.         $this->_addHoliday('halloween'$this->_year . '-10-31''Halloween');
  319.  
  320.         /**
  321.          * Stamp's Day
  322.          *
  323.          * year <= 1948: 7th of January
  324.          * year > 1948: last Sunday in October
  325.          */
  326.         $stampsDayDate = null;
  327.         if ($this->_year <= 1948{
  328.             $stampsDayDate = new Date($this->_year . '-01-07');
  329.             while ($stampsDayDate->getDayOfWeek(!= 0{
  330.                 $stampsDayDate $stampsDayDate->getNextDay();
  331.             }
  332.         else {
  333.             $stampsDayDate = new Date($this->_year . '-10-31');
  334.             while ($stampsDayDate->getDayOfWeek(!= 0{
  335.                 $stampsDayDate $stampsDayDate->getPrevDay();
  336.             }
  337.         }
  338.         $this->_addHoliday('stampsDay'$stampsDayDate'Stamp\'s Day');
  339.  
  340.         /**
  341.          * International Men's Day
  342.          */
  343.         $this->_addHoliday('mensDay',
  344.                            $this->_year . '-11-03',
  345.                            'International Men\'s Day');
  346.  
  347.         /**
  348.          * Fall of the Wall of Berlin
  349.          */
  350.         $this->_addHoliday('wallOfBerlin',
  351.                            $this->_year . '-11-09',
  352.                            'Fall of the Wall of Berlin 1989');
  353.  
  354.         /**
  355.          * Beginning of the Carnival
  356.          */
  357.         $this->_addHoliday('carnivalBeginning',
  358.                            $this->_year . '-11-11',
  359.                            'Beginning of the Carnival');
  360.  
  361.         /**
  362.          * People's Day of Mourning
  363.          */
  364.         $dayOfMourning = new Date;
  365.         $dayOfMourning->copy($advent1Date);
  366.         $dayOfMourning->subtractSpan(new Date_Span('14, 0, 0, 0'));
  367.         $this->_addHoliday('dayOfMourning',
  368.                            $dayOfMourning,
  369.                            'People\'s Day of Mourning');
  370.  
  371.         if (Date_Holidays::errorsOccurred()) {
  372.             return Date_Holidays::getErrorStack();
  373.         }
  374.         return true;
  375.     }
  376.  
  377.     /**
  378.      * Method that returns an array containing the ISO3166 codes that may possibly
  379.      * identify a driver.
  380.      *
  381.      * @static
  382.      * @access public
  383.      * @return array possible ISO3166 codes
  384.      */
  385.     function getISO3166Codes()
  386.     {
  387.         return array('de''deu');
  388.     }
  389. }
  390. ?>

Documentation generated on Thu, 10 Apr 2008 20:00:18 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.