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.14 2004/07/30 21:26:55 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.14 2004/07/30 21:26:55 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
  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'$dayOfWeek + 3 + 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'$dayOfWeek - 4 + 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.         * Day against Noise
  141.         */
  142.         $this->_addHoliday('againstNoiseDay'$this->_year . '-04-28''Day against Noise');
  143.         
  144.        /**
  145.         * Walpurgis Night
  146.         */
  147.         $this->_addHoliday('walpurgisNight'$this->_year . '-04-30''Walpurgis Night');
  148.         
  149.        /**
  150.         * Day of Work
  151.         */
  152.         $this->_addHoliday('dayOfWork'$this->_year . '-05-01''Day of Work');
  153.         
  154.        /**
  155.         * World's Laughing Day
  156.         */
  157.         $laughingDayDate    &new Date($this->_year . '-05-01');
  158.         while ($laughingDayDate->getDayOfWeek(!= 0{
  159.             $laughingDayDate    &$laughingDayDate->getNextDay();
  160.         }
  161.         $this->_addHoliday('laughingDay'$laughingDayDate'World\'s Laughing Day');
  162.         
  163.        /**
  164.         * Europe Day
  165.         */
  166.         $this->_addHoliday('europeDay'$this->_year . '-05-05''Europe Day');
  167.         
  168.        /**
  169.         * Mothers' Day
  170.         */
  171.         $mothersDay         &new Date($laughingDayDate);
  172.         $mothersDay->addSpan(new Date_Span('7, 0, 0, 0'));
  173.         $this->_addHoliday('mothersDay'$mothersDay'Mothers\' Day');
  174.         
  175.        /**
  176.         * End of World War 2 in Germany
  177.         */
  178.         $this->_addHoliday('endOfWWar2'$this->_year . '-05-09''End of World War 2 in Germany');
  179.         
  180.        /**
  181.         * Fathers' Day
  182.         */
  183.         $this->_addHoliday('fathersDay'$ascensionDayDate'Fathers\' Day');
  184.         
  185.        /**
  186.         * Amnesty International Day
  187.         */
  188.         $this->_addHoliday('aiDay'$this->_year . '-05-28''Amnesty International Day');
  189.         
  190.        /**
  191.         * International Children' Day
  192.         */
  193.         $this->_addHoliday('intChildrenDay'$this->_year . '-06-01''International Children\'s Day');
  194.         
  195.        /**
  196.         * Day of organ donation
  197.         */
  198.         $organDonationDate  &new Date($this->_year . '-06-01');
  199.         while ($organDonationDate->getDayOfWeek(!= 6{
  200.             $organDonationDate  &$organDonationDate->getNextDay();
  201.         }
  202.         $this->_addHoliday('organDonationDay'$organDonationDate'Day of organ donation');
  203.         
  204.        /**
  205.         * Dormouse' Day
  206.         */
  207.         $this->_addHoliday('dormouseDay'$this->_year . '-06-27''Dormouse\' Day');
  208.         
  209.        /**
  210.         * Christopher Street Day
  211.         */
  212.         $this->_addHoliday('christopherStreetDay'$this->_year . '-06-27''Christopher Street Day');
  213.         
  214.        /**
  215.         * Hiroshima Commemoration Day
  216.         */
  217.         $this->_addHoliday('hiroshimaCommemorationDay'$this->_year . '-08-06''Hiroshima Commemoration Day');
  218.         
  219.        /**
  220.         * Augsburg peace celebration
  221.         */
  222.         $this->_addHoliday('augsburgPeaceCelebration'$this->_year . '-08-08''Augsburg peace celebration');
  223.         
  224.        /**
  225.         * International left-handeds' Day
  226.         */
  227.         $this->_addHoliday('leftHandedDay'$this->_year . '-08-13''International left-handeds\' Day');
  228.         
  229.        /**
  230.         * Anti-War Day
  231.         */
  232.         $this->_addHoliday('antiWarDay'$this->_year . '-09-01''Anti-War Day');
  233.         
  234.        /**
  235.         * Day of German Language
  236.         */
  237.         $germanLangDayDate  &new Date($this->_year . '-09-01');
  238.         while ($germanLangDayDate->getDayOfWeek(!= 6{
  239.             $germanLangDayDate  &$germanLangDayDate->getNextDay();
  240.         }
  241.         $germanLangDayDate->addSpan(new Date_Span('7, 0, 0, 0'));
  242.         $this->_addHoliday('germanLanguageDay'$germanLangDayDate'Day of German Language');
  243.         
  244.        /**
  245.         * International diabetes day
  246.         */
  247.         $this->_addHoliday('diabetesDay'$this->_year . '-09-14''International diabetes day');
  248.         
  249.        /**
  250.         * German Unification Day
  251.         */
  252.         $this->_addHoliday('germanUnificationDay'$this->_year . '-10-03''German Unification Day');
  253.         
  254.        /**
  255.         * Libraries' Day
  256.         */
  257.         $this->_addHoliday('librariesDay'$this->_year . '-10-24''Libraries\' Day');
  258.         
  259.        /**
  260.         * World's Savings Day
  261.         */
  262.         $this->_addHoliday('savingsDay'$this->_year . '-10-30''World\'s Savings Day');
  263.         
  264.        /**
  265.         * Halloween
  266.         */
  267.         $this->_addHoliday('halloween'$this->_year . '-10-31''Halloween');
  268.         
  269.        /**
  270.         * Stamp's Day
  271.         */
  272.         $stampsDayDate      &new Date($this->_year . '-10-31');
  273.         while ($stampsDayDate->getDayOfWeek(!= 0{
  274.             $stampsDayDate  &$stampsDayDate->getPrevDay();
  275.         }
  276.         $this->_addHoliday('stampsDay'$stampsDayDate'Stamp\'s Day');
  277.         
  278.        /**
  279.         * International Men's Day
  280.         */
  281.         $this->_addHoliday('mensDay'$this->_year . '-11-03''International Men\'s Day');
  282.         
  283.        /**
  284.         * Fall of the Wall of Berlin
  285.         */
  286.         $this->_addHoliday('wallOfBerlin'$this->_year . '-11-09''Fall of the Wall of Berlin 1989');
  287.         
  288.        /**
  289.         * Beginning of the Carnival
  290.         */
  291.         $this->_addHoliday('carnivalBeginning'$this->_year . '-11-11''Beginning of the Carnival');
  292.         
  293.        /**
  294.         * People's Day of Mourning
  295.         */
  296.         $dayOfMourning      &$advent1Date;
  297.         $dayOfMourning->subtractSpan(new Date_Span('14, 0, 0, 0'));
  298.         $this->_addHoliday('dayOfMourning'$dayOfMourning'People\'s Day of Mourning');
  299.         
  300.         if (Date_Holidays::errorsOccurred()) {
  301.             return Date_Holidays::getErrorStack();
  302.         }
  303.         return true;
  304.     }
  305. }
  306. ?>

Documentation generated on Mon, 11 Mar 2019 13:54:58 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.