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

Source for file Turkey.php

Documentation is available at Turkey.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. /**
  4.  * Turkey.php
  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   Serkan Cetintopcu <sc@st.net.tr>
  21.  * @license  http://www.php.net/license/3_01.txt PHP License 3.0.1
  22.  * @version  CVS: $Id: Turkey.php,v 1.11 2008/03/17 11:37:49 kguest Exp $
  23.  * @link     http://pear.php.net/package/Date_Holidays
  24.  */
  25. //
  26.  
  27.  
  28. /**
  29.  * class that calculates observed Turkey holidays
  30.  *
  31.  * @category   Date
  32.  * @package    Date_Holidays
  33.  * @subpackage Driver
  34.  * @author     Serkan Cetintopcu <sc@st.net.tr>
  35.  * @license    http://www.php.net/license/3_01.txt PHP License 3.0.1
  36.  * @version    CVS: $Id: Turkey.php,v 1.11 2008/03/17 11:37:49 kguest Exp $
  37.  * @link       http://pear.php.net/package/Date_Holidays
  38.  */
  39. class Date_Holidays_Driver_Turkey extends Date_Holidays_Driver
  40. {
  41.     /**
  42.      * Constructor
  43.      *
  44.      * Use the Date_Holidays::factory() method to construct an object of a
  45.      * certain driver
  46.      *
  47.      * @access   protected
  48.      */
  49.     function Date_Holidays_Driver_Turkey()
  50.     {
  51.     }
  52.  
  53.     /**
  54.      * Build the internal arrays that contain data about the calculated holidays
  55.      *
  56.      * @access   protected
  57.      * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  58.      * @throws   object PEAR_ErrorStack
  59.      */
  60.     function _buildHolidays()
  61.     {
  62.  
  63.  
  64.         $newYearsDay $this->_calcNearestWorkDay('01''01');
  65.         $this->_addHoliday('newYearsDay'$newYearsDay'Yılbaşı');
  66.  
  67.  
  68.         $this->_addHoliday('egemenlikDay'$this->_year.'-04-23''Ulusal Egemenlik ve Çocuk Bayramı');
  69.                                 
  70.                                 
  71.                                 $this->_addHoliday('genclikDay'$this->_year.'-05-19''Atatürk\'ü Anma Gençlik ve Spor Bayramı');
  72.                                 
  73.                                 $this->_addHoliday('zaferDay'$this->_year.'-08-30''Zafer Bayramı');
  74.                                 
  75.                                 $this->_addHoliday('cumhuriyetDay'$this->_year.'-10-29''Cumhuriyet Bayramı');
  76.  
  77.  
  78.  
  79.         return true;
  80.     }
  81.  
  82.   
  83.     function _calcNearestWorkDay($month$day)
  84.     {
  85.         $month sprintf("%02d"$month);
  86.         $day   sprintf("%02d"$day);
  87.         $date  = new Date($this->_year '-' $month '-' $day);
  88.  
  89.         // When one of these holidays falls on a Saturday, the previous day is
  90.         // also a holiday
  91.         // When New Year's Day, Independence Day, or Christmas Day falls on a
  92.         // Sunday, the next day is also a holiday.
  93.         if ($date->getDayOfWeek(== 0 {
  94.             // bump it up one
  95.             $date $date->getNextDay();
  96.         }
  97.         if ($date->getDayOfWeek(== 6 {
  98.             // push it back one
  99.             $date $date->getPrevDay();
  100.         }
  101.  
  102.         return $date;
  103.     }
  104.  
  105.  
  106.     function getISO3166Codes()
  107.     {
  108.         return array('tr''tur');
  109.     }
  110. }
  111. ?>

Documentation generated on Sun, 25 Nov 2012 01:30:01 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.