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

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