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

Class: Date_Holidays_Driver

Source Location: /Date_Holidays-0.17.1/Holidays/Driver.php

Class Overview


class that helps you to locate holidays for a year


Author(s):

Version:

  • $Id: Driver.php,v 1.20 2006/04/03 21:04:46 luckec Exp $

Variables

Methods


Child classes:

Date_Holidays_Driver_Example
Example how to create an own driver-class for Date_Holidays
Date_Holidays_Driver_Jewish
class that calculates Jewish holidays
Date_Holidays_Driver_USA
class that calculates observed U.S. holidays
Date_Holidays_Driver_Slovenia
Driver class that calculates Slovenian holidays
Date_Holidays_Driver_EnglandWales
Driver class that calculates Danish holidays
Date_Holidays_Driver_PHPdotNet
Driver-class that calculates the birthdates of the PHP.net people. :)
Date_Holidays_Driver_Ireland
Driver class that calculates Irish holidays deriving most calculations from 'Public holidays in Ireland' document on http://www.citizensinformation.ie/
Date_Holidays_Driver_Composite
Composite driver - you can use this one to combine two or more drivers
Date_Holidays_Driver_Christian
class that calculates Christian holidays
Date_Holidays_Driver_Discordian
A driver-class calculating discordian Holidays. See the 'Principia Discordia' or http://en.wikipedia.org/wiki/Discordian_calendar for details.
Date_Holidays_Driver_Austria
class that calculates Austrian holidays
Date_Holidays_Driver_Denmark
Driver class that calculates Danish holidays
Date_Holidays_Driver_Sweden
Driver class that calculates Swedish holidays
Date_Holidays_Driver_UNO
Driver-class that calculates UNO (United Nations Organization) holidays

Inherited Variables

Inherited Methods


Class Details

[line 102]
class that helps you to locate holidays for a year
  • Author: Carsten Lucke <luckec@tool-garage.de>
  • Version: $Id: Driver.php,v 1.20 2006/04/03 21:04:46 luckec Exp $
  • Abstract:


[ Top ]


Class Variables

$_dates = array()

[line 143]

dates of the available holidays
  • Access: protected

Type:   array


[ Top ]

$_holidays = array()

[line 151]

array of the available holidays indexed by date
  • Access: protected

Type:   array


[ Top ]

$_internalNames = array()

[line 135]

internal names for the available holidays
  • Access: protected

Type:   array


[ Top ]

$_locale =

[line 111]

locale setting for output
  • Access: protected

Type:   string


[ Top ]

$_titles = array()

[line 159]

localized names of the available holidays
  • Access: protected

Type:   array


[ Top ]

$_year =

[line 127]

object's current year
  • Access: protected

Type:   int


[ Top ]



Method Detail

Date_Holidays_Driver (Constructor)   [line 188]

Date_Holidays_Driver Date_Holidays_Driver( )

Constructor

Use the Date_Holidays::factory() method to construct an object of a certain driver

  • Access: protected

[ Top ]

addCompiledTranslationFile   [line 842]

boolean addCompiledTranslationFile( string $file, string $locale)

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 specified locale.

  • Return: true on success, otherwise a PEAR_ErrorStack object
  • Throws: object PEAR_Errorstack
  • Access: public

Parameters:

string   $file   —  filename of the compiled language file
string   $locale   —  locale-code of the translation

[ Top ]

addDriver   [line 253]

void addDriver( object Date_Holidays_Driver $driver)

Add a driver component
  • Abstract:
  • Access: public

Overridden in child classes as:

Date_Holidays_Driver_Composite::addDriver()
Add a driver component

Parameters:

object Date_Holidays_Driver   $driver   —  driver-object

[ Top ]

addTranslationFile   [line 802]

boolean addTranslationFile( string $file, string $locale)

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 locale.

  • Return: true on success, otherwise a PEAR_ErrorStack object
  • Throws: object PEAR_Errorstack
  • Access: public

Parameters:

string   $file   —  filename of the language file
string   $locale   —  locale-code of the translation

[ Top ]

getHoliday   [line 444]

object Date_Holidays_Holiday getHoliday( string $internalName, [string $locale = null])

Returns the specified holiday

Return format:

   array(
       'title' =>  'Easter Sunday'
       'date'  =>  '2004-04-11'
   )


Overridden in child classes as:

Date_Holidays_Driver_Composite::getHoliday()
Returns the specified holiday

Parameters:

string   $internalName   —  internal name of the holiday
string   $locale   —  locale setting that shall be used by this method

[ Top ]

getHolidayDate   [line 961]

object Date getHolidayDate( string $internalName)

Returns date of a holiday

Overridden in child classes as:

Date_Holidays_Driver_Composite::getHolidayDate()
Returns date of a holiday

Parameters:

string   $internalName   —  internal name for holiday

[ Top ]

getHolidayDates   [line 992]

array getHolidayDates( [Date_Holidays_Filter $filter = null])

Returns dates of all holidays or those accepted by the applied filter.

Structure of the returned array:

 array(
   'internalNameFoo' => object of type date,
   'internalNameBar' => object of type date
 )

  • Return: with holidays' dates on success, otherwise a PEAR_Error object
  • Throws: object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  • Access: public
  • Uses: Date_Holidays_Driver::getHolidayDate()

Overridden in child classes as:

Date_Holidays_Driver_Composite::getHolidayDates()
Returns dates of all holidays or those accepted by the specified filter.

Parameters:

Date_Holidays_Filter   $filter   —  filter-object (or an array !DEPRECATED!)

[ Top ]

getHolidayForDate   [line 530]

object object getHolidayForDate( mixed $date, [string $locale = null], [boolean $multiple = false])

Returns a
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

items.


Overridden in child classes as:

Date_Holidays_Driver_Composite::getHolidayForDate()
Returns the title of the holiday, if any was found, matching the specified date.

Parameters:

mixed   $date   —  date (timestamp | string | PEAR::Date object)
string   $locale   —  locale setting that shall be used by this method
boolean   $multiple   — 

[ Top ]

getHolidayProperties   [line 357]

array getHolidayProperties( string $internalName, [string $locale = null])

Returns the localized properties of a holiday. If no properties have been stored an empty array will be returned.
  • Return: array of properties on success, otherwise a PEAR_Error object
  • Throws: object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  • Access: public

Parameters:

string   $internalName   —  internal name for holiday
string   $locale   —  locale setting that shall be used by this method

[ Top ]

getHolidays   [line 401]

array getHolidays( [Date_Holidays_Filter $filter = null], [string $locale = null])

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.

Return format:

   array(
       'easter'        =>  object of type Date_Holidays_Holiday,
       'eastermonday'  =>  object of type Date_Holidays_Holiday,
       ...
   )

  • Return: numeric array containing objects of Date_Holidays_Holiday on success, otherwise a PEAR_Error object
  • See: Date_Holidays_Driver::getHoliday()
  • Throws: object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  • Access: public

Overridden in child classes as:

Date_Holidays_Driver_Composite::getHolidays()
Returns all holidays that were found

Parameters:

Date_Holidays_Filter   $filter   —  filter-object (or an array !DEPRECATED!)
string   $locale   —  locale setting that shall be used by this method

[ Top ]

getHolidaysForDatespan   [line 577]

array getHolidaysForDatespan( mixed $start, mixed $end, [Date_Holidays_Filter $filter = null], [string $locale = null])

Returns an array containing a number of
items.

If no items have been found the returned array will be empty.

  • Return: an array containing a number of
    items
  • Throws: object PEAR_Error DATE_HOLIDAYS_INVALID_DATE, DATE_HOLIDAYS_INVALID_DATE_FORMAT
  • Access: public

Parameters:

mixed   $start   —  date (timestamp | string | PEAR::Date object)
mixed   $end   —  date (timestamp | string | PEAR::Date object)
Date_Holidays_Filter   $filter   —  filter-object (or an array !DEPRECATED!)
string   $locale   —  locale setting that shall be used by this method

[ Top ]

getHolidayTitle   [line 323]

string getHolidayTitle( string $internalName, [string $locale = null])

Returns localized title for a holiday

Overridden in child classes as:

Date_Holidays_Driver_Composite::getHolidayTitle()
Returns localized title for a holiday

Parameters:

string   $internalName   —  internal name for holiday
string   $locale   —  locale setting that shall be used by this method

[ Top ]

getHolidayTitles   [line 291]

array getHolidayTitles( [Date_Holidays_Filter $filter = null], [string $locale = null])

Returns localized titles of all holidays or those accepted by the filter
  • Return: array with localized holiday titles on success, otherwise a PEAR_Error object
  • Throws: object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  • Access: public
  • Uses: Date_Holidays_Driver::getHolidayTitle()

Overridden in child classes as:

Date_Holidays_Driver_Composite::getHolidayTitles()
Returns localized titles of all holidays or those specififed in $restrict array

Parameters:

string   $locale   —  locale setting that shall be used by this method
Date_Holidays_Filter   $filter   —  filter-object (or an array !DEPRECATED!)

[ Top ]

getInternalHolidayNames   [line 276]

array getInternalHolidayNames( )

Returns the internal names of holidays that were calculated
  • Access: public

[ Top ]

getISO3166Codes   [line 200]

array getISO3166Codes( )

Method that returns an array containing the ISO3166 codes that may possibly identify a driver.
  • Return: possible ISO3166 codes
  • Access: public

Overridden in child classes as:

Date_Holidays_Driver_USA::getISO3166Codes()
Method that returns an array containing the ISO3166 codes that may possibly identify a driver.
Date_Holidays_Driver_Slovenia::getISO3166Codes()
Method that returns an array containing the ISO3166 codes that may possibly identify a driver.
Date_Holidays_Driver_EnglandWales::getISO3166Codes()
Method that returns an array containing the ISO3166 codes that may possibly identify a driver.
Date_Holidays_Driver_Ireland::getISO3166Codes()
Method that returns an array containing the ISO3166 codes that may possibly identify a driver.
Date_Holidays_Driver_Germany::getISO3166Codes()
Method that returns an array containing the ISO3166 codes that may possibly identify a driver.
Date_Holidays_Driver_Austria::getISO3166Codes()
Method that returns an array containing the ISO3166 codes that may possibly identify a driver.
Date_Holidays_Driver_Denmark::getISO3166Codes()
Method that returns an array containing the ISO3166 codes that may possibly identify a driver.
Date_Holidays_Driver_Sweden::getISO3166Codes()
Method that returns an array containing the ISO3166 codes that may possibly identify a driver.

[ Top ]

getYear   [line 227]

int getYear( )

Returns the driver's current year
  • Return: current year
  • Access: public

Overridden in child classes as:

Date_Holidays_Driver_Composite::getYear()
Using this method doesn't affect anything. If you have been able to add your driver to this compound, you should also be able to directly execute this action.

[ Top ]

isHoliday   [line 480]

boolean isHoliday( mixed $date, [Date_Holidays_Filter $filter = null])

Determines whether a date represents a holiday or not
  • Return: true if date represents a holiday, otherwise false
  • Throws: object PEAR_Error DATE_HOLIDAYS_INVALID_DATE, DATE_HOLIDAYS_INVALID_DATE_FORMAT
  • Access: public

Overridden in child classes as:

Date_Holidays_Driver_Composite::isHoliday()
Determines whether a date represents a holiday or not.

Parameters:

mixed   $date   —  date (can be a timestamp, string or PEAR::Date object)
Date_Holidays_Filter   $filter   —  filter-object (or an array !DEPRECATED!)

[ Top ]

removeDriver   [line 266]

boolean removeDriver( object Date_Holidays_Driver $driver)

Remove a driver component
  • Return: true on success, otherwise a PEAR_Error object
  • Abstract:
  • Throws: object PEAR_Error DATE_HOLIDAYS_DRIVER_NOT_FOUND
  • Access: public

Overridden in child classes as:

Date_Holidays_Driver_Composite::removeDriver()
Remove a driver component

Parameters:

object Date_Holidays_Driver   $driver   —  driver-object

[ Top ]

setLocale   [line 1020]

void setLocale( string $locale)

Sets the driver's locale
  • Access: public

Overridden in child classes as:

Date_Holidays_Driver_Composite::setLocale()
Using this method doesn't affect anything. If you have bben able to add your driver to this compound, you should also be able to directly execute this action.

Parameters:

string   $locale   —  locale

[ Top ]

setYear   [line 215]

boolean setYear( int $year)

Sets the driver's current year

Calling this method forces the object to rebuild the holidays


Overridden in child classes as:

Date_Holidays_Driver_Composite::setYear()
This (re)sets the year of every driver-object in the compound.

Parameters:

int   $year   —  year

[ Top ]

_addHoliday   [line 694]

void _addHoliday( string $internalName, mixed $date, string $title)

Adds a holiday to the driver's holidays

Parameters:

string   $internalName   —  internal name - must not contain characters that aren't allowed as variable-names
mixed   $date   —  date (timestamp | string | PEAR::Date object)
string   $title   —  holiday title

[ Top ]

_addStaticHolidays   [line 678]

void _addStaticHolidays( array $holidays)

Adds all holidays in the array to the driver's internal list of holidays.

Format of the array:

   array(
       'newYearsDay'   => array(
           'date'          => '01-01',
           'title'         => 'New Year\'s Day',
           'translations'  => array(
               'de_DE' =>  'Neujahr',
               'en_EN' =>  'New Year\'s Day'
           )
       ),
       'valentinesDay' => array(
           ...
       )
   );


Parameters:

array   $holidays   —  static holidays' data

[ Top ]

_addStringPropertiesForHoliday   [line 780]

boolean _addStringPropertiesForHoliday( string $internalName, string $locale, array $properties)

Adds a arbitrary number of localized string-properties for the specified holiday.
  • Return: true on success, false otherwise
  • Throws: PEAR_ErrorStack if internal-name does not exist
  • Access: public

Parameters:

string   $internalName   —  internal-name
string   $locale   —  locale-setting
array   $properties   —  associative array: array(propId1 => value1, propid2 => value2, ...)

[ Top ]

_addStringPropertyForHoliday   [line 747]

boolean _addStringPropertyForHoliday( string $internalName, string $locale, string $propId, mixed $propVal)

Adds a localized (regrading translation etc.) string-property for a holiday.

Overwrites existing data.

  • Return: true on success, false otherwise
  • Throws: PEAR_ErrorStack if internal-name does not exist
  • Access: public

Parameters:

string   $internalName   —  internal-name
string   $locale   —  locale-setting
string   $propId   —  property-identifier
mixed   $propVal   —  property-value

[ Top ]

_addTranslationData   [line 872]

boolean _addTranslationData( array $data, string $locale)

Add a language-file's content. Translations, properties, etc. for holidays will be made available with the specified locale.
  • Return: true on success, otherwise a PEAR_ErrorStack object
  • Throws: object PEAR_Errorstack
  • Access: public

Parameters:

array   $data   —  translated data
string   $locale   —  locale-code of the translation

[ Top ]

_addTranslationForHoliday   [line 720]

true _addTranslationForHoliday( string $internalName, string $locale, string $title)

Add a localized translation for a holiday's title. Overwrites existing data.
  • Return: on success, otherwise a PEAR_Error object
  • Throws: object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  • Access: protected

Parameters:

string   $internalName   —  internal name of an existing holiday
string   $locale   —  locale setting that shall be used by this method
string   $title   —  title

[ Top ]

_buildHolidays   [line 240]

boolean _buildHolidays( )

Build the internal arrays that contain data about the calculated holidays
  • Return: true on success, otherwise a PEAR_ErrorStack object
  • Abstract:
  • Throws: object PEAR_ErrorStack
  • Access: protected
  • Usedby: Date_Holidays_Driver::setYear()

Overridden in child classes as:

Date_Holidays_Driver_Example::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_Jewish::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_USA::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_Slovenia::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_EnglandWales::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_PHPdotNet::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_Ireland::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_Christian::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_Germany::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_Discordian::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_Austria::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_Denmark::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_Sweden::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays
Date_Holidays_Driver_UNO::_buildHolidays()
Build the internal arrays that contain data about the calculated holidays

[ Top ]

_findBestLocale   [line 935]

string _findBestLocale( string $locale)

Finds the best internally available locale for the specified one
  • Return: best locale available
  • Access: protected

Parameters:

string   $locale   —  locale

[ Top ]

_removeHoliday   [line 905]

boolean _removeHoliday( $string $internalName)

Remove a holiday from internal storage

This method should be used within driver classes to unset holidays that were inherited from parent-drivers

  • Return: true on success, otherwise a PEAR_Error object
  • Throws: object PEAR_Error DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  • Access: protected

Parameters:

$string   $internalName   —  internal name

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:03:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.