Source for file creating_drivers.php
Documentation is available at creating_drivers.php
* Example how to create an own driver-class for Date_Holidays
* To test this class, you have to copy it into the drivers-directory.
* The classname has to be something like Date_Holidays_Driver_*.
* Otherwise it won't be compatible to be used within PEAR's strict directory structure.
* @author Carsten Lucke <luckec@tool-garage.de>
* Use the Date_Holidays::factory() method to construct an object of a certain driver
* 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
* If your driver is extending another driver-class and is not a direct descendant of the Date_Holidays_Driver base-class
* you will want to build this classes' holidays before you start with your turn.
* So just call the _buildHolidays() method of that class.
* There are two methods to add a holiday. One for adding holidays in general and on that
* can be used to add static holidays (every year the same day).
* You always have to give the added holiday an unique internal name within your driver.
* This should describe the holiday as good as possible.
* Of course you need a date and a title (the default title should always be in English)
* You can add as many translations as you want for your driver's holidays.
* Although the default title is in English you should add another one with the correct locale setting.
* General method to add a holiday
$this->_addHoliday('jesusCircumcision', $this->_year . '-01-01', 'Circumcision of Jesus');
// if you are using helper methods to calculate movable holidays is your own decision
$fooDate = $this->_calcFirstMondayInJanuary ();
$this->_addHoliday('firstMondayInJan', $fooDate, 'First monday in January');
* Special method for adding static holidays:
'title' => 'New Year\'s Day'
'valentinesDay' => array (
'title' => 'Valentine\'s Day'
* @return object Date date of first monday in actual years january
function _calcFirstMondayInJanuary ()
$date = new Date ($this->_year . '-01-01');
while ($date->getDayOfWeek () != 1 ) {
$date = $date->getNextDay ();
Documentation generated on Mon, 11 Mar 2019 15:03:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|