PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Date and Time » Date_Holidays » Manual

Holiday calculation package. This chapter describes how to use PEAR::Date_Holidays

Introduction

Introduction – What Date_Holidays can do

Introduction

Date_Holidays is a driver-based holiday calculation package. It helps you check whether a specific date is a holiday in a specific country or religion. Furthermore you can calculate the date of any holiday supported in the driver for the country, region or religion.

Currently the following drivers are supported:

If you have written a custom driver for Date_Holidays that could be included in the distribution, please contact the package maintainers or open a feature request and attach a patch in the bug tracking tool.

Date_Holidays supports I18N by storing the names of the different holidays in INI files for each language. These files will be stored in the data directory of your PEAR installation.

Example

Example – Example for the usage of Date_Holidays

Basic example

This example shows you, how to calculate the Easter date of 2005.

<?php
require_once "Date/Holidays.php";
$germany = &Date_Holidays::factory('Germany', 2004, 'en_EN');
if (Date_Holidays::isError($germany)) {
    die('Factory was unable to produce driver-object');
}
$easter = &$germany->getHoliday('easter', 'de_DE');
if (!Date_Holidays::isError($easter)) {
    print_r($easter->toArray());
}
?>

This will return an array in the following format:

Array
(
    [internalName] => easter
    [title] => Easter Sunday
    [date] => date Object
        (
            [year] => 2004
            [month] => 04
            [day] => 11
            [hour] => 0
            [minute] => 0
            [second] => 0
            [tz] => date_timezone Object
                (
                    [id] => UTC
                    [longname] => Coordinated Universal Time
                    [shortname] => UTC
                    [hasdst] =>
                    [dstlongname] => Coordinated Universal Time
                    [dstshortname] => UTC
                    [offset] => 0
                    [default] =>
                )

        )

)