Source for file Driver.php
Documentation is available at Driver.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
* Copyright (c) 1997-2008 The PHP Group
* This source file is subject to version 2.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/2_02.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.
* Authors: Carsten Lucke <luckec@tool-garage.de>
* @author Carsten Lucke <luckec@tool-garage.de>
* @license http://www.php.net/license/3_01.txt PHP License 3.0.1
* @link http://pear.php.net/package/Date_Holidays
* DriverClass and associated defines.
* @author Carsten Lucke <luckec@tool-garage.de>
* @license http://www.php.net/license/3_01.txt PHP License 3.0.1
* @link http://pear.php.net/package/Date_Holidays
require_once 'PEAR/ErrorStack.php';
require_once 'Date/Holidays/Filter.php';
require_once 'Date/Holidays/Filter/Whitelist.php';
require_once 'Date/Holidays/Filter/Blacklist.php';
define('DATE_HOLIDAYS_INVALID_INTERNAL_NAME', 51 );
* title for a holiday is not available
define('DATE_HOLIDAYS_TITLE_UNAVAILABLE', 52 );
* date could not be converted into a PEAR::Date object
* date was neither a timestamp nor a string
* @deprecated will certainly be removed
define('DATE_HOLIDAYS_INVALID_DATE', 53 );
* string that represents a date has wrong format
* format must be YYYY-MM-DD
* @deprecated will certainly be removed
define('DATE_HOLIDAYS_INVALID_DATE_FORMAT', 54 );
* date for a holiday is not available
define('DATE_HOLIDAYS_DATE_UNAVAILABLE', 55 );
* language-file doesn't exist
define('DATE_HOLIDAYS_LANGUAGEFILE_NOT_FOUND', 56 );
* unable to read language-file
define('DATE_HOLIDAYS_UNABLE_TO_READ_TRANSLATIONDATA', 57 );
* Name of the static {@link Date_Holidays_Driver} method returning
* a array of possible ISO3166 codes that identify itself.
define('DATE_HOLIDAYS_DRIVER_IDENTIFY_ISO3166_METHOD', 'getISO3166Codes');
* class that helps you to locate holidays for a year
* @author Carsten Lucke <luckec@tool-garage.de>
* @license http://www.php.net/license/3_01.txt PHP License 3.0.1
* @link http://pear.php.net/package/Date_Holidays
* locale setting for output
* locales for which translations of holiday titles are available
var $_availableLocales = array ('C');
* internal names for the available holidays
* dates of the available holidays
* array of the available holidays indexed by date
* localized names of the available holidays
* Array of holiday-properties indexed by internal-names and
* furthermore by locales.
* $_holidayProperties = array(
* 'internalName1' => array(
* 'internalName2' => array(
var $_holidayProperties = array ();
* Use the Date_Holidays::factory() method to construct an object of a
* Method that returns an array containing the ISO3166 codes that may possibly
* @return array possible ISO3166 codes
* Sets the driver's current year
* Calling this method forces the object to rebuild the holidays
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_ErrorStack
* Returns the driver's current year
* @return int current year
* Build the internal arrays that contain data about the calculated holidays
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_ErrorStack
* @param object $driver Date_Holidays_Driver object
* Search for installed language files appropriate for the specified
* locale and add them to the driver
* @param string $locale locale setting to be used
* @return boolean true on success, otherwise false
$data_dir = "@DATA-DIR@";
if ($data_dir == '@'. 'DATA-DIR'. '@') {
"$data_dir/lang/Christian/");
//Christian driver is exceptional...
$stubdir = "$data_dir/Date_Holidays/lang/Christian/";
if (! is_dir($stubdir)) {
$stubdir = $data_dir . "/Date_Holidays/lang/";
"$data_dir/Date_Holidays_{ $this->_driverName}/lang/Christian/ ");
foreach ($stubdirs as $stubdir) {
if ($dh = opendir($stubdir)) {
while (($file = readdir($dh)) !== false) {
if (strlen($locale) == 5) {
if (((strncasecmp($file, $bestLocale, 5) == 0))
|| (strncasecmp($file, $locale, 5) == 0)
array_push($matches, $file);
if (strlen($locale) == 2) {
if (((strncasecmp($file, $bestLocale, 2) == 0))
|| (strncasecmp($file, $locale, 2) == 0)
array_push($matches, $file);
foreach ($matches as $am) {
if (strpos($am, ".ser") !== false) {
array_push ($forget, basename ($am, ".ser") . ".xml");
if (!in_array($am, $forget)) {
str_replace (".xml", "", $am)
* Remove a driver component
* @param object $driver Date_Holidays_Driver driver-object
* @return boolean true on success, otherwise a PEAR_Error object
* @throws object PEAR_Error DATE_HOLIDAYS_DRIVER_NOT_FOUND
function removeDriver($driver)
* Returns the internal names of holidays that were calculated
function getInternalHolidayNames()
* Returns localized titles of all holidays or those accepted by the filter
* @param Date_Holidays_Filter $filter filter-object (or an array !DEPRECATED!)
* @param string $locale locale setting that shall be used
* @return array $filter array with localized holiday titles on success,
* otherwise a PEAR_Error object
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
* @uses getHolidayTitle()
function getHolidayTitles($filter = null, $locale = null)
$filter = new Date_Holidays_Filter_Blacklist(array());
} elseif (is_array($filter)) {
$filter = new Date_Holidays_Filter_Whitelist($filter);
if ($filter->accept ($internalName)) {
if (Date_Holidays ::isError ($title)) {
$titles[$internalName] = $title;
* Returns localized title for a holiday
* @param string $internalName internal name for holiday
* @param string $locale locale setting to be used by this method
* @return string title on success, otherwise a PEAR_Error object
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
* @throws object PEAR_Error DATE_HOLIDAYS_TITLE_UNAVAILABLE
function getHolidayTitle($internalName, $locale = null)
$msg = 'Invalid internal name: ' . $internalName;
return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_INTERNAL_NAME,
if (! isset($this->_titles[$locale][$internalName])) {
if (Date_Holidays::staticGetProperty('DIE_ON_MISSING_LOCALE')) {
$err = DATE_HOLIDAYS_TITLE_UNAVAILABLE;
$msg = 'The internal name (' . $internalName . ') ' .
'for the holiday was correct but no ' .
'localized title could be found';
return Date_Holidays::raiseError($err, $msg);
if (isset($this->_titles[$locale][$internalName])) {
return $this->_titles[$locale][$internalName];
return $this->_titles['C'][$internalName];
* Returns the localized properties of a holiday. If no properties have
* been stored an empty array will be returned.
* @param string $internalName internal name for holiday
* @param string $locale locale setting that shall be used by this method
* @return array array of properties on success, otherwise
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
function getHolidayProperties($internalName, $locale = null)
$msg = 'Invalid internal name: ' . $internalName;
return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_INTERNAL_NAME,
if (isset($this->_holidayProperties[$internalName][$locale])) {
$properties = $this->_holidayProperties[$internalName][$locale];
* Returns all holidays that the driver knows.
* You can limit the holidays by passing a filter, then only those
* holidays accepted by the filter will be returned.
* 'easter' => object of type Date_Holidays_Holiday,
* 'eastermonday' => object of type Date_Holidays_Holiday,
* @param Date_Holidays_Filter $filter filter-object
* (or an array !DEPRECATED!)
* @param string $locale locale setting that shall be used
* @return array numeric array containing objects of
* Date_Holidays_Holiday on success, otherwise a
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
function getHolidays($filter = null, $locale = null)
$filter = new Date_Holidays_Filter_Blacklist(array());
} elseif (is_array($filter)) {
$filter = new Date_Holidays_Filter_Whitelist($filter);
if ($filter->accept ($internalName)) {
// no need to check for valid internal-name, will be
$holidays[$internalName] = $this->getHoliday($internalName,
* Returns the specified holiday
* 'title' => 'Easter Sunday'
* @param string $internalName internal name of the holiday
* @param string $locale locale setting that shall be used
* @return object Date_Holidays_Holiday holiday's information on
* success, otherwise a PEAR_Error
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
* @uses getHolidayTitle()
function getHoliday($internalName, $locale = null)
return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_INTERNAL_NAME,
'Invalid internal name: ' . $internalName);
if (Date_Holidays ::isError ($title)) {
if (Date_Holidays ::isError ($date)) {
if (Date_Holidays ::isError ($properties)) {
$holiday = new Date_Holidays_Holiday($internalName,
* Determines whether a date represents a holiday or not
* @param mixed $date a timestamp, string or PEAR::Date object
* @param Date_Holidays_Filter $filter filter-object (or an array !DEPRECATED!)
* @return boolean true if date represents a holiday, otherwise false
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_DATE_FORMAT
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_DATE
function isHoliday($date, $filter = null)
if (! is_a($date, 'Date')) {
$date = $this->_convertDate ($date);
if (Date_Holidays ::isError ($date)) {
//rebuild internal array of holidays if required.
$compare_year = $date->getYear ();
if ($this_year !== $compare_year) {
$filter = new Date_Holidays_Filter_Blacklist(array());
} elseif (is_array($filter)) {
$filter = new Date_Holidays_Filter_Whitelist($filter);
foreach (array_keys($this->_dates) as $internalName) {
if ($filter->accept ($internalName)) {
if (Date_Holidays_Driver::dateSloppyCompare($date,
$this->_dates[$internalName]) != 0 ) {
* Returns a <code>Date_Holidays_Holiday</code> object, if any was found,
* matching the specified date.
* Normally the method will return the object of the first holiday matching
* the date. If you want the method to continue searching holidays for the
* specified date, set the 4th param to true.
* If multiple holidays match your date, the return value will be an array
* containing a number of <code>Date_Holidays_Holiday</code> items.
* @param mixed $date date (timestamp | string | PEAR::Date object)
* @param string $locale locale setting that shall be used by this method
* @param boolean $multiple if true, continue searching holidays for
* @return object object of type Date_Holidays_Holiday on success
* (numeric array of those on multiple search),
* if no holiday was found, matching this date,
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_DATE_FORMAT
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_DATE
* @uses getHolidayTitle()
function getHolidayForDate($date, $locale = null, $multiple = false)
if (!is_a($date, 'Date')) {
$date = $this->_convertDate ($date);
if (Date_Holidays ::isError ($date)) {
if ($date->getYear () != $this->_year) {
if (array_key_exists($isodate, $this->_holidays)) {
//get only the first feast for this day
$internalName = $this->_holidays[$isodate][0 ];
$result = $this->getHoliday($internalName, $locale);
return Date_Holidays ::isError ($result) ? null : $result;
// array that collects data, if multiple searching is done
foreach ($this->_holidays[$isodate] as $internalName) {
$result = $this->getHoliday($internalName, $locale);
if (Date_Holidays ::isError ($result)) {
* Returns an array containing a number of
* <code>Date_Holidays_Holiday</code> items.
* If no items have been found the returned array will be empty.
* @param mixed $start date: timestamp, string or PEAR::Date
* @param mixed $end date: timestamp, string or PEAR::Date
* @param Date_Holidays_Filter $filter filter-object (or
* @param string $locale locale setting that shall be used
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_DATE_FORMAT
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_DATE
* @return array an array containing a number
* of <code>Date_Holidays_Holiday</code> items
function getHolidaysForDatespan($start, $end, $filter = null, $locale = null)
$filter = new Date_Holidays_Filter_Blacklist(array());
} elseif (is_array($filter)) {
$filter = new Date_Holidays_Filter_Whitelist($filter);
if (!is_a($start, 'Date')) {
$start = $this->_convertDate ($start);
if (Date_Holidays ::isError ($start)) {
if (!is_a($end, 'Date')) {
$end = $this->_convertDate ($end);
if (Date_Holidays ::isError ($end)) {
$isodateStart = mktime(0,
$internalNames = array();
foreach ($this->_holidays as $isoDateTS => $arHolidays) {
if ($isoDateTS >= $isodateStart && $isoDateTS <= $isodateEnd) {
$internalNames = array_merge($internalNames, $arHolidays);
foreach ($internalNames as $internalName) {
if ($filter->accept ($internalName)) {
$retval[] = $this->getHoliday($internalName, $locale);
* Converts timestamp or date-string into da PEAR::Date object
* @param mixed $date date
* @return object PEAR_Date
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_DATE_FORMAT
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_DATE
function _convertDate($date)
if (! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}/', $date)) {
return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_DATE_FORMAT,
'Date-string has wrong format (must be YYYY-MM-DD)');
$date = new Date(date('Y-m-d', $date));
return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_DATE,
'The date you specified is invalid');
* Adds all holidays in the array to the driver's internal list of holidays.
* 'newYearsDay' => array(
* 'title' => 'New Year\'s Day',
* 'translations' => array(
* 'en_EN' => 'New Year\'s Day'
* 'valentinesDay' => array(
* @param array $holidays static holidays' data
function _addStaticHolidays($holidays)
foreach ($holidays as $internalName => $holiday) {
// add the holiday's basic data
$this->_year . '-' . $holiday['date'],
* Adds a holiday to the driver's holidays
* @param string $internalName internal name - must not contain characters
* that aren't allowed as variable-names
* @param mixed $date date (timestamp | string | PEAR::Date object)
* @param string $title holiday title
function _addHoliday($internalName, $date, $title)
if (! is_a($date, 'Date')) {
$this->_dates[$internalName] = $date;
$this->_titles['C'][$internalName] = $title;
$isodate = mktime (0 , 0 , 0 ,
array_push($this->_holidays[$isodate], $internalName);
* Add a localized translation for a holiday's title. Overwrites existing data.
* @param string $internalName internal name of an existing holiday
* @param string $locale locale setting that shall be used by this method
* @param string $title title
* @return true on success, otherwise a PEAR_Error object
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
function _addTranslationForHoliday($internalName, $locale, $title)
$msg = 'Couldn\'t add translation (' . $locale . ') ' .
'for holiday with this internal name: ' . $internalName;
return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_INTERNAL_NAME,
if (! in_array($locale, $this->_availableLocales)) {
array_push($this->_availableLocales, $locale);
$this->_titles[$locale][$internalName] = $title;
* Adds a localized (regrading translation etc.) string-property for a holiday.
* Overwrites existing data.
* @param string $internalName internal-name
* @param string $locale locale-setting
* @param string $propId property-identifier
* @param mixed $propVal property-value
* @return boolean true on success, false otherwise
* @throws PEAR_ErrorStack if internal-name does not exist
function _addStringPropertyForHoliday($internalName, $locale, $propId, $propVal)
$msg = 'Couldn\'t add property (locale: ' . $locale . ') '.
'for holiday with this internal name: ' . $internalName;
return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_INTERNAL_NAME,
if (!isset($this->_holidayProperties[$internalName]) ||
!is_array ($this->_holidayProperties[$internalName])) {
$this->_holidayProperties[$internalName] = array ();
if (! isset($this->_holidayProperties[$internalName][$locale]) ||
!is_array ($this->_holidayProperties[$internalName][$locale])) {
$this->_holidayProperties[$internalName][$locale] = array ();
$this->_holidayProperties[$internalName][$locale][$propId] = $propVal;
* Adds a arbitrary number of localized string-properties for the
* @param string $internalName internal-name
* @param string $locale locale-setting
* @param array $properties associative array: array(propId1 => val1,...)
* @return boolean true on success, false otherwise
* @throws PEAR_ErrorStack if internal-name does not exist
function _addStringPropertiesForHoliday($internalName, $locale, $properties)
foreach ($properties as $propId => $propValue) {
* Add a language-file's content
* The language-file's content will be parsed and translations,
* properties, etc. for holidays will be made available with the specified
* @param string $file filename of the language file
* @param string $locale locale-code of the translation
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_Errorstack
function addTranslationFile($file, $locale)
if (! file_exists($file)) {
Date_Holidays::raiseError(DATE_HOLIDAYS_LANGUAGEFILE_NOT_FOUND,
'Language-file not found: ' . $file);
return Date_Holidays::getErrorStack();
// unserialize the document
$document = simplexml_load_file($file);
$content['holidays'] = array();
$content['holidays']['holiday'] = array();
$nodes = $document->xpath ('//holiday');
foreach ($nodes as $node) {
$content['holidays']['holiday'][] = (array)$node;
* Add a compiled language-file's content
* The language-file's content will be unserialized and translations,
* properties, etc. for holidays will be made available with the
* @param string $file filename of the compiled language file
* @param string $locale locale-code of the translation
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_Errorstack
function addCompiledTranslationFile($file, $locale)
if (! file_exists($file)) {
Date_Holidays::raiseError(DATE_HOLIDAYS_LANGUAGEFILE_NOT_FOUND,
'Language-file not found: ' . $file);
return Date_Holidays::getErrorStack();
$content = file_get_contents($file);
if ($content === false) {
$data = unserialize($content);
$e = DATE_HOLIDAYS_UNABLE_TO_READ_TRANSLATIONDATA;
$msg = "Unable to read translation-data - file maybe damaged: $file";
return Date_Holidays::raiseError($e, $msg);
* Add a language-file's content. Translations, properties, etc. for
* holidays will be made available with the specified locale.
* @param array $data translated data
* @param string $locale locale-code of the translation
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_Errorstack
function _addTranslationData($data, $locale)
foreach ($data['holidays']['holiday'] as $holiday) {
$holiday['translation']);
if (isset ($holiday['properties']) && is_array ($holiday['properties'])) {
foreach ($holiday['properties'] as $propId => $propVal) {
if (Date_Holidays::errorsOccurred()) {
return Date_Holidays::getErrorStack();
* Remove a holiday from internal storage
* This method should be used within driver classes to unset holidays that
* were inherited from parent-drivers
* @param $string $internalName internal name
* @return boolean true on success, otherwise a PEAR_Error object
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
function _removeHoliday($internalName)
$msg = "Couldn't remove holiday with this internal name: $internalName";
return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_INTERNAL_NAME,
if (isset($this->_dates[$internalName])) {
unset($this->_dates[$internalName]);
$locales = array_keys($this->_titles);
foreach ($locales as $locale) {
if (isset($this->_titles[$locale][$internalName])) {
unset($this->_titles[$locale][$internalName]);
* Finds the best internally available locale for the specified one
* @param string $locale locale
* @return string best locale available
function _findBestLocale($locale)
/* exact locale is available */
if (in_array($locale, $this->_availableLocales)) {
/* first two letter are equal */
foreach ($this->_availableLocales as $aLocale) {
if (strncasecmp($aLocale, $locale, 2) == 0) {
/* no appropriate locale available, will use driver's internal locale */
* Returns date of a holiday
* @param string $internalName internal name for holiday
* @return object Date date of holiday as PEAR::Date object
* on success, otherwise a PEAR_Error object
* @throws object PEAR_Error DATE_HOLIDAYS_DATE_UNAVAILABLE
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
function getHolidayDate($internalName)
$msg = 'Invalid internal name: ' . $internalName;
return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_INTERNAL_NAME,
if (! isset($this->_dates[$internalName])) {
$msg = 'Date for holiday with internal name ' .
$internalName . ' is not available';
return Date_Holidays::raiseError(DATE_HOLIDAYS_DATE_UNAVAILABLE, $msg);
return $this->_dates[$internalName];
* Returns dates of all holidays or those accepted by the applied filter.
* Structure of the returned array:
* 'internalNameFoo' => object of type date,
* 'internalNameBar' => object of type date
* @param Date_Holidays_Filter $filter filter-object (or an array !DEPRECATED!)
* @return array with holidays' dates on success, otherwise a PEAR_Error object
* @throws object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
function getHolidayDates($filter = null)
$filter = new Date_Holidays_Filter_Blacklist(array());
} elseif (is_array($filter)) {
$filter = new Date_Holidays_Filter_Whitelist($filter);
if ($filter->accept ($internalName)) {
if (Date_Holidays ::isError ($date)) {
* Sets the driver's locale
* @param string $locale locale
function setLocale($locale)
//if possible, load the translation files for this locale
* Sloppily compares two date objects (only year, month and day are compared).
* Does not take the date's timezone into account.
* @param Date $d1 a date object
* @param Date $d2 another date object
* @return int 0 if the dates are equal,
function dateSloppyCompare($d1, $d2)
$d1->setTZ (new Date_TimeZone ('UTC'));
$d2->setTZ (new Date_TimeZone ('UTC'));
$days1 = Date_Calc ::dateToDays ($d1->day , $d1->month , $d1->year );
$days2 = Date_Calc ::dateToDays ($d2->day , $d2->month , $d2->year );
if ($days1 < $days2) return -1;
if ($days1 > $days2) return 1;
* Find the date of the first monday in the specified year of the current year.
* @param integer $month month
* @return object Date date of first monday in specified month.
function _calcFirstMonday($month)
$month = sprintf("%02d", $month);
$date = new Date($this->_year . "-$month-01");
while ($date->getDayOfWeek () != 1 ) {
$date = $date->getNextDay ();
* Find the date of the last monday in the specified year of the current year.
* @param integer $month month
* @return object Date date of last monday in specified month.
function _calcLastMonday($month)
//work backwards from the first day of the next month.
$month = sprintf("%02d", $month);
$nm = ((int) $month ) + 1;
$nm = sprintf("%02d", $nm);
$date = new Date($this->_year . "-$nm-01");
$date = $date->getPrevDay ();
while ($date->getDayOfWeek () != 1 ) {
$date = $date->getPrevDay ();
* Calculate Nth monday in a month
* @param int $month month
* @param int $position position
* @return object Date date
function _calcNthMondayInMonth($month, $position)
} elseif ($position == 2) {
} elseif ($position == 3) {
} elseif ($position == 4) {
} elseif ($position == 5) {
$month = sprintf("%02d", $month);
$date = new Date($this->_year . '-' . $month . '-' . $startday);
while ($date->getDayOfWeek () != 1 ) {
$date = $date->getNextDay ();
* Calculate Nth day of the week in a month
* @param int $position position
* @param int $weekday day of the week starting from 1 == sunday
* @param int $month month
* @return object Date date
function _calcNthWeekDayInMonth($position, $weekday, $month)
} elseif ($position == 2) {
} elseif ($position == 3) {
} elseif ($position == 4) {
} elseif ($position == 5) {
$month = sprintf("%02d", $month);
$date = new Date($this->_year . '-' . $month . '-' . $startday);
while ($date->getDayOfWeek () != $weekday) {
$date = $date->getNextDay ();
* Converts the date to the specified no of days from the given date
* To subtract days use a negative value for the '$pn_days' parameter
* @param Date $date Date object
* @param int $pn_days days to add
function _addDays($date, $pn_days)
$new_date = new Date($date);
list($new_date->year , $new_date->month , $new_date->day ) =
Date_Calc ::daysToDate (Date_Calc ::dateToDays ($date->day ,
if (isset ($new_date->on_standardyear )) {
$new_date->on_standardyear = $new_date->year;
$new_date->on_standardmonth = $new_date->month;
$new_date->on_standardday = $new_date->day;
Documentation generated on Tue, 22 Jan 2013 01:00:08 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.
|