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

Source for file Sweden.php

Documentation is available at Sweden.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:   Anders Karlsson <anders.x.karlsson@tdcsong.se>            |
  17. // | Authors:   Carsten Lucke <luckec@php.net>                            |
  18. // +----------------------------------------------------------------------+
  19. //
  20. //    $Id: Sweden.php,v 1.4 2006/04/02 22:19:06 luckec Exp $
  21.  
  22. require_once 'Date/Holidays/Driver/Christian.php';
  23.  
  24. /**
  25.  * Driver class that calculates Swedish holidays
  26.  *
  27.  * @category    Date
  28.  * @package     Date_Holidays
  29.  * @subpackage  Driver
  30.  * @version     $Id: Sweden.php,v 1.4 2006/04/02 22:19:06 luckec Exp $
  31.  * @author      Anders Karlsson <anders.x.karlsson@tdcsong.se>
  32.  */
  33. {
  34.    /**
  35.     * Constructor
  36.     *
  37.     * Use the Date_Holidays::factory() method to construct an object of a certain driver
  38.     *
  39.     * @access   protected
  40.     */
  41.     function Date_Holidays_Driver_Sweden({}
  42.  
  43.    /**
  44.     * Build the internal arrays that contain data about the calculated holidays
  45.     *
  46.     * @access   protected
  47.     * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  48.     * @throws   object PEAR_ErrorStack
  49.     */
  50.     function _buildHolidays()
  51.     {
  52.        /**
  53.         * New Year's Day
  54.         */
  55.         $this->_addHoliday('newYearsDay'$this->_year . '-01-01''New Year\'s Day');
  56.  
  57.        /**
  58.         * Epiphanias
  59.         */
  60.         $this->_addHoliday('epiphany'$this->_year . '-01-06''Epiphany');
  61.  
  62.        /**
  63.         * Easter Sunday
  64.         */
  65.         $easterDate Date_Holidays_Driver_Sweden::calcEaster($this->_year);
  66.         $this->_addHoliday('easter'$easterDate'Easter Sunday');
  67.  
  68.        /**
  69.         * Good Friday / Black Friday
  70.         */
  71.         $goodFridayDate = new Date($easterDate);
  72.         $goodFridayDate->subtractSpan(new Date_Span('2, 0, 0, 0'));
  73.         $this->_addHoliday('goodFriday'$goodFridayDate'Good Friday');
  74.  
  75.        /**
  76.         * Easter Monday
  77.         */
  78.         $this->_addHoliday('easterMonday'$easterDate->getNextDay()'Easter Monday');
  79.  
  80.        /**
  81.         * May Day
  82.         */
  83.         $this->_addHoliday('mayDay'$this->_year . '-05-01''May Day');
  84.  
  85.        /**
  86.         * Pentecost (determines Whit Monday, Ascension Day and Feast of Corpus Christi)
  87.         */
  88.         $pentecostDate = new Date($easterDate);
  89.         $pentecostDate->addSpan(new Date_Span('49, 0, 0, 0'));
  90.         $this->_addHoliday('pentecost'$pentecostDate'Pentecost');
  91.  
  92.        /**
  93.         * Ascension Day
  94.         */
  95.         $ascensionDayDate = new Date($pentecostDate);
  96.         $ascensionDayDate->subtractSpan(new Date_Span('10, 0, 0, 0'));
  97.         $this->_addHoliday('ascensionDay'$ascensionDayDate'Ascension Day');
  98.  
  99.        /**
  100.         * Swedish National Day and the Swedish Flag's Day
  101.         */
  102.         $this->_addHoliday('swedenNationalDay'$this->_year . '-06-06'
  103.                 'Swedish National Day and the Swedish Flag\'s Day');
  104.  
  105.        /**
  106.         * Midsummer
  107.         * Saturday past 20th, June
  108.         */
  109.         $juneDate       = new Date($this->_year . '-06-20');
  110.         $dayOfWeek      $juneDate->getDayOfWeek();
  111.         $juneDate->addSpan(new Date_Span(sprintf('%d, 0, 0, 0'6 - $dayOfWeek)));
  112.         $midSummerDate  $juneDate;
  113.         $this->_addHoliday('midSummer'$midSummerDate'Midsummer Day');
  114.         
  115.         /**
  116.          * Midsummer Eve
  117.          * Day before Midsummer.
  118.          */
  119.         $this->_addHoliday('midSummerEve'$midSummerDate->getPrevDay()'Midsummer Eve')
  120.  
  121.        /**
  122.         * All Saints' Day
  123.         */
  124.         $saintspanDate  = new Date($this->_year . '-10-31');
  125.         $dayOfWeek      $saintspanDate->getDayOfWeek();
  126.         $saintspanDate->addSpan(new Date_Span(sprintf('%d, 0, 0, 0'6 - $dayOfWeek)));
  127.         $allSaintsDate  $saintspanDate;
  128.         $this->_addHoliday('allSaintsDay'$allSaintsDate'All Saints\' Day');
  129.  
  130.        /**
  131.         * Christmas Eve
  132.         */
  133.         $this->_addHoliday('xmasEve'$this->_year . '-12-24''Christmas Eve');
  134.  
  135.        /**
  136.         * Christmas day
  137.         */
  138.         $this->_addHoliday('xmasDay'$this->_year . '-12-25''Christmas Day');
  139.  
  140.        /**
  141.         * Boxing day
  142.         */
  143.         $this->_addHoliday('boxingDay'$this->_year . '-12-26''Boxing Day');
  144.  
  145.        /**
  146.         * New Year's Eve
  147.         */
  148.         $this->_addHoliday('newYearsEve'$this->_year . '-12-31''New Year\'s Eve');
  149.  
  150.         if (Date_Holidays::errorsOccurred()) {
  151.             return Date_Holidays::getErrorStack();
  152.         }
  153.         return true;
  154.     }
  155.  
  156.    /**
  157.     * Calculates the date for Easter. Actually this methods delegates the calculation to
  158.     * the {@link Date_Holidays_Driver_Christian#calcEaster()} method.
  159.     *
  160.     * @static
  161.     * @access   private
  162.     * @param    int     $year   year
  163.     * @return   object Date 
  164.     */
  165.     function calcEaster($year)
  166.     {
  167.         return Date_Holidays_Driver_Christian::calcEaster($year);
  168.     }
  169.     
  170.    /**
  171.     * Method that returns an array containing the ISO3166 codes that may possibly
  172.     * identify a driver.
  173.     * 
  174.     * @static
  175.     * @access public
  176.     * @return array possible ISO3166 codes
  177.     */
  178.     function getISO3166Codes({
  179.         return array('se''swe');
  180.     }
  181. }
  182. ?>

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