Class holidays

Description

A class to handle a list of public holidays. It allows you to add holidays in various ways, and also to query whether a particular date-time falls on a holiday.

Located in /holiday-defs.php (line 36)


	
			
Variable Summary
Method Summary
 holidays holidays ([array $hols = ""])
 void add_holiday (string $holdesc, string $holdate)
 void add_holiday_relative (string $holdesc, string $monthname, string $dayabbrev, integer $n, [integer $year = ""])
 void add_holiday_ts (string $holdesc, string $holts)
 boolean is_holiday ([integer $timestamp = ""])
Variables
mixed $hols = array() (line 38)
mixed $matched_holiday_desc = "" (line 41)
Methods
Constructor holidays (line 49)

Constructor. Optionally pass in an associative array with the key of a unique holiday description, and value as the timestamp of the holiday itself.

holidays holidays ([array $hols = ""])
  • array $hols: Associative array 'Holiday desc' => timestamp
add_holiday (line 72)

Add a holiday date as a date-string in the usual kinds of form such as '25-12', or '25 December 2007' or '25/12/2007' etc. This is a friendly method for adding general holiday dates.

void add_holiday (string $holdesc, string $holdate)
  • string $holdesc: Unique descriptive identifier for the holiday
  • string $holdate: The holiday date as a string eg '25/12/2006'
add_holiday_relative (line 90)

Add a holiday which is calculated as being the Nth occurence of a given dayname, in a given month. This method is a common one for designating National holidays, eg. 'Queen's Birthday' as being the first Monday in June.

void add_holiday_relative (string $holdesc, string $monthname, string $dayabbrev, integer $n, [integer $year = ""])
  • string $holdesc: Unique descriptive identifier for the holiday
  • string $monthname: Name of month eg. 'Dec' or 'December'
  • string $dayabbrev: Dayname abbreviation eg. 'Mon', 'Tue'..
  • integer $n: Occurence in month eg. 1, 2, 3..
  • integer $year: Optional year (defaults to current year)
add_holiday_ts (line 61)

Add a holiday timestamp to the array. This is the internal method for adding raw holiday timestamps.

void add_holiday_ts (string $holdesc, string $holts)
  • string $holdesc: Unique descriptive identifier for the holiday
  • string $holts: The holiday timestamp to add
is_holiday (line 107)

Check if the given timestamp is the date of a public holiday. We

return true if it is, else false. Note: if the timestamp falls on a holiday, then the holiday description is left in the class var 'matched_holiday_desc' on exit. If the passed-in timestamp is not given, then the method assume 'now' as the timestamp.

  • return: True if the timestamp is on a public holiday
boolean is_holiday ([integer $timestamp = ""])
  • integer $timestamp: Unix timestamp of the date to check.

Documentation generated by phpDocumentor 1.3.0RC3