Permalink
Browse files

Files for Turkey driver.

  • Loading branch information...
1 parent 0217f64 commit 064cd4711748b27faa2374555baf0ca60f523429 @kenguest kenguest committed Nov 25, 2012
Showing with 425 additions and 0 deletions.
  1. +111 −0 Date/Holidays/Driver/Turkey.php
  2. +72 −0 package_turkey.xml
  3. +242 −0 tests/Date_Holidays_Driver_Turkey_TestSuite.php
@@ -0,0 +1,111 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4: */
+/**
+ * Turkey.php
+ *
+ * PHP Version 4
+ *
+ * Copyright (c) 1997-2008 The PHP Group
+ *
+ * This source file is subject to version 3.0 of the PHP license,
+ * that is bundled with this package in the file LICENSE, and is
+ * available at through the world-wide-web at
+ * http://www.php.net/license/3_01.txt.
+ * If you did not receive a copy of the PHP license and are unable to
+ * obtain it through the world-wide-web, please send a note to
+ * license@php.net so we can mail you a copy immediately.
+ *
+ * @category Date
+ * @package Date_Holidays
+ * @author Serkan Cetintopcu <sc@st.net.tr>
+ * @license http://www.php.net/license/3_01.txt PHP License 3.0.1
+ * @version CVS: $Id: Turkey.php,v 1.11 2008/03/17 11:37:49 kguest Exp $
+ * @link http://pear.php.net/package/Date_Holidays
+ */
+//
+
+
+/**
+ * class that calculates observed Turkey holidays
+ *
+ * @category Date
+ * @package Date_Holidays
+ * @subpackage Driver
+ * @author Serkan Cetintopcu <sc@st.net.tr>
+ * @license http://www.php.net/license/3_01.txt PHP License 3.0.1
+ * @version CVS: $Id: Turkey.php,v 1.11 2008/03/17 11:37:49 kguest Exp $
+ * @link http://pear.php.net/package/Date_Holidays
+ */
+class Date_Holidays_Driver_Turkey extends Date_Holidays_Driver
+{
+ /**
+ * Constructor
+ *
+ * Use the Date_Holidays::factory() method to construct an object of a
+ * certain driver
+ *
+ * @access protected
+ */
+ function Date_Holidays_Driver_Turkey()
+ {
+ }
+
+ /**
+ * Build the internal arrays that contain data about the calculated holidays
+ *
+ * @access protected
+ * @return boolean true on success, otherwise a PEAR_ErrorStack object
+ * @throws object PEAR_ErrorStack
+ */
+ function _buildHolidays()
+ {
+
+
+ $newYearsDay = $this->_calcNearestWorkDay('01', '01');
+ $this->_addHoliday('newYearsDay', $newYearsDay, 'Yılbaşı');
+
+
+ $this->_addHoliday('egemenlikDay', $this->_year.'-04-23', 'Ulusal Egemenlik ve Çocuk Bayramı');
+
+
+ $this->_addHoliday('genclikDay', $this->_year.'-05-19', 'Atatürk\'ü Anma Gençlik ve Spor Bayramı');
+
+ $this->_addHoliday('zaferDay', $this->_year.'-08-30', 'Zafer Bayramı');
+
+ $this->_addHoliday('cumhuriyetDay', $this->_year.'-10-29', 'Cumhuriyet Bayramı');
+
+
+
+ return true;
+ }
+
+
+ function _calcNearestWorkDay($month, $day)
+ {
+ $month = sprintf("%02d", $month);
+ $day = sprintf("%02d", $day);
+ $date = new Date($this->_year . '-' . $month . '-' . $day);
+
+ // When one of these holidays falls on a Saturday, the previous day is
+ // also a holiday
+ // When New Year's Day, Independence Day, or Christmas Day falls on a
+ // Sunday, the next day is also a holiday.
+ if ($date->getDayOfWeek() == 0 ) {
+ // bump it up one
+ $date = $date->getNextDay();
+ }
+ if ($date->getDayOfWeek() == 6 ) {
+ // push it back one
+ $date = $date->getPrevDay();
+ }
+
+ return $date;
+ }
+
+
+ function getISO3166Codes()
+ {
+ return array('tr', 'tur');
+ }
+}
+?>
View
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.9.4" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Date_Holidays_Turkey</name>
+ <channel>pear.php.net</channel>
+ <summary>Driver based class to calculate holidays in Turkey.</summary>
+ <description>Date_Holidays helps you calculate the dates and titles of holidays and other special celebrations. This is the driver for calculating holidays in Turkey.</description>
+ <lead>
+ <name>Serkan Cetintopcu</name>
+ <user>alastyr</user>
+ <email>serkan.cetintopcu@alastyr.com</email>
+ <active>yes</active>
+ </lead>
+ <lead>
+ <name>Ken Guest</name>
+ <user>kguest</user>
+ <email>ken@linux.ie</email>
+ <active>yes</active>
+ </lead>
+ <date>2012-11-25</date>
+ <time>00:11:16</time>
+ <version>
+ <release>0.1.1</release>
+ <api>0.1.0</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <license uri="http://www.opensource.org/licenses/bsd-license.html">BSD License</license>
+ <notes>
+Slight changes to testsuite so it works when installed rather than in developers environment.
+ </notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <file baseinstalldir="/" md5sum="232bac820854ec8a716dfc2e07e54e58" name="Date/Holidays/Driver/Turkey.php" role="php" />
+ <file baseinstalldir="/" md5sum="b4154ce4ddef81bfe24b92e662e29ddb" name="tests/Date_Holidays_Driver_Turkey_TestSuite.php" role="test" />
+ </dir>
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>4.0.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.0b1</min>
+ </pearinstaller>
+ <package>
+ <name>Date_Holidays</name>
+ <channel>pear.php.net</channel>
+ <min>0.21.1</min>
+ </package>
+ </required>
+ </dependencies>
+ <phprelease />
+ <changelog>
+ <release>
+ <version>
+ <release>0.1.0</release>
+ <api>0.1.0</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2008-05-07</date>
+ <license uri="http://www.opensource.org/licenses/bsd-license.html">BSD License</license>
+ <notes>
+initial pear release
+ </notes>
+ </release>
+ </changelog>
+</package>
Oops, something went wrong.

0 comments on commit 064cd47

Please sign in to comment.