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

Source for file Norway.php

Documentation is available at Norway.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. /**
  4.  * Driver class that calculates Norwegian holidays
  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   Vegard Fiksdal <fiksdal@sensorlink.no>
  21.  * @license  http://www.php.net/license/3_01.txt PHP License 3.0.1
  22.  * @version  CVS: $Id: Norway.php,v 1.4 2008/03/18 20:35:24 kguest Exp $
  23.  * @link     http://pear.php.net/package/Date_Holidays
  24.  */
  25.  
  26.  
  27. require_once 'Christian.php';
  28.  
  29. /**
  30.  * Driver class that calculates Norwegian holidays
  31.  *
  32.  * @category   Date
  33.  * @package    Date_Holidays
  34.  * @subpackage Driver
  35.  * @author     Vegard Fiksdal <fiksdal@sensorlink.no>
  36.  * @license    http://www.php.net/license/3_01.txt PHP License 3.0.1
  37.  * @version    CVS: $Id: Norway.php,v 1.4 2008/03/18 20:35:24 kguest Exp $
  38.  * @link       http://pear.php.net/package/Date_Holidays
  39.  *  Sensorlink AS (c) 2006
  40.  */
  41. {
  42.     /**
  43.      * Constructor
  44.      *
  45.      * Use the Date_Holidays::factory() method to construct an object of a certain
  46.      * driver
  47.      *
  48.      * @access   protected
  49.      */
  50.     function Date_Holidays_Driver_Norway ()
  51.     {
  52.     }
  53.  
  54.     /**
  55.      * Build the internal arrays that contain data about the calculated holidays
  56.      *
  57.      * @access   protected
  58.      * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  59.      * @throws   object PEAR_ErrorStack
  60.      */
  61.     function _buildHolidays()
  62.     {
  63.         /**
  64.          * New Year's Day
  65.          */
  66.         $this->_addHoliday('newYearsDay',
  67.                            $this->_year . '-01-01',
  68.                            'New Year\'s Day');
  69.  
  70.         /**
  71.          * Easter Sunday
  72.          */
  73.         $easterDate Date_Holidays_Driver_Norway::calcEaster($this->_year);
  74.         $this->_addHoliday('easter'$easterDate'Easter Sunday');
  75.  
  76.         /**
  77.          * Good Friday / Black Friday
  78.          */
  79.         $goodFridayDate = new Date($easterDate);
  80.         $goodFridayDate->subtractSpan(new Date_Span('2, 0, 0, 0'));
  81.         $this->_addHoliday('goodFriday'$goodFridayDate'Good Friday');
  82.  
  83.         /**
  84.          * Easter Monday
  85.          */
  86.         $this->_addHoliday('easterMonday',
  87.                            $easterDate->getNextDay(),
  88.                            'Easter Monday');
  89.  
  90.         /**
  91.          * May Day
  92.          */
  93.         $this->_addHoliday('mayDay'$this->_year . '-05-01''May Day');
  94.  
  95.         /**
  96.          * Pentecost (determines Whit Monday, Ascension Day and Feast of
  97.          * Corpus Christi)
  98.          */
  99.         $pentecostDate = new Date($easterDate);
  100.         $pentecostDate->addSpan(new Date_Span('49, 0, 0, 0'));
  101.         $this->_addHoliday('pentecost'$pentecostDate'Pentecost');
  102.  
  103.         /**
  104.          * Ascension Day
  105.          */
  106.         $ascensionDayDate = new Date($pentecostDate);
  107.         $ascensionDayDate->subtractSpan(new Date_Span('10, 0, 0, 0'));
  108.         $this->_addHoliday('ascensionDay'$ascensionDayDate'Ascension Day');
  109.  
  110.         /**
  111.          * Norwegian National Day
  112.          */
  113.         $this->_addHoliday('norwayNationalDay'$this->_year . '-05-17',
  114.                 'Norwegian National Day');
  115.  
  116.         /**
  117.          * Christmas Eve
  118.          */
  119.         $this->_addHoliday('christmasEve'$this->_year . '-12-24''Christmas Eve');
  120.  
  121.         /**
  122.          * Christmas day
  123.          */
  124.         $this->_addHoliday('christmasDay'$this->_year . '-12-25''Christmas Day');
  125.  
  126.         /**
  127.          * Boxing day
  128.          */
  129.         $this->_addHoliday('boxingDay'$this->_year . '-12-26''Boxing Day');
  130.  
  131.         /**
  132.          * New Year's Eve
  133.          */
  134.         $this->_addHoliday('newYearsEve',
  135.                            $this->_year . '-12-31',
  136.                            'New Year\'s Eve');
  137.  
  138.         if (Date_Holidays::errorsOccurred()) {
  139.             return Date_Holidays::getErrorStack();
  140.         }
  141.  
  142.         return true;
  143.     }
  144.  
  145.     /**
  146.      * Calculates the date for Easter. Actually this methods delegates the
  147.      * calculation to the {@link Date_Holidays_Driver_Christian#calcEaster()} method.
  148.      *
  149.      * @param int $year year
  150.      *
  151.      * @static
  152.      * @access private
  153.      * @return object Date 
  154.      */
  155.     function calcEaster($year)
  156.     {
  157.         return Date_Holidays_Driver_Christian::calcEaster($year);
  158.     }
  159.  
  160.     /**
  161.      * Method that returns an array containing the ISO3166 codes that may possibly
  162.      * identify a driver.
  163.      *
  164.      * @static
  165.      * @access public
  166.      * @return array possible ISO3166 codes
  167.      */
  168.     function getISO3166Codes()
  169.     {
  170.         return array('no''nor');
  171.     }
  172. }
  173. ?>

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