PHP Classes

PHP Holidays Library for Germany, Austria and Switzerland: Get the holiday dates of specific countries

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 46 This week: 1All time: 10,728 This week: 560Up
Version License PHP version Categories
stateinfo 1.0.0Freely Distributable5XML, PHP 5, Time and Date, Geography
Description 

Author

This class can be used to get the holiday dates of specific countries.

It can parse a XML file and extract the list of holiday dates for specific countries and their states like Germany, Austria and Switzerland.

The class can also return the dates of holidays that depend on the year like for instance the date of Easter.

Picture of Stefan Kientzler
  Performance   Level  
Name: Stefan Kientzler is available for providing paid consulting. Contact Stefan Kientzler .
Classes: 18 packages by
Country: Germany Germany
Age: 56
All time rank: 73147 in Germany Germany
Week rank: 17 Up1 in Germany Germany Up
Innovation award
Innovation award
Nominee: 11x

Winner: 6x

Example

<?php
use lib\StatesInfo\StatesInfo;

require_once
'lib/StatesInfo/StatesInfo.php';

   
$oSI = new StatesInfo('DE');
   
   
$aStates = $oSI->listStates();
    echo
'<h1>Liste der Bundesl&auml;nder mit Feiertagen 2020</h1>' . PHP_EOL;
    echo
'<ul>' . PHP_EOL;
    foreach (
$aStates as $strShort => $strState) {
        echo
'<li>' . $strState . ' (' . $strShort . ')</li>' . PHP_EOL;
       
$aList = $oSI->listOfficialHolidays($strShort, 2020);
        echo
'<ul>' . PHP_EOL;
        foreach (
$aList as $id => $aHoliday) {
            echo
'<li>' . date('d.m.Y', $aHoliday['date']) . ': ' . $aHoliday['name'];
            if (
$aHoliday['partial']) {
                echo
' <small> - nicht im gesamten Bundesland!</small> ';
                if (
$strShort == 'BY') {
                    echo
'<b>';
                    if (!
$oSI->checkHolidayByPostcode($id, 86152)) {
                       
// Augsburg
                       
echo 'KEIN ';
                    }
                    echo
'Feiertag in Augsburg, ';
                    if (!
$oSI->checkHolidayByPostcode($id, 91154)) {
                       
// Roth
                       
echo 'KEIN ';
                    }
                    echo
'Feiertag in Roth</b>';
                }
            }
            echo
'</li>' . PHP_EOL;
        }
        echo
'</ul>' . PHP_EOL;
    }
    echo
'</ul>' . PHP_EOL;
   
   
// sometimes you need to query records according to an given state like
    // SELECT * FROM adress WHERE <condition>
    // but either there is no field for the state or the field has been insufficiently
    // or incompletely maintained ...
   
echo '<h1>WHERE - condition f&uuml;r HH</h1>' . PHP_EOL;
    echo
$oSI->getWhereCondition('HH', 'postcode') . PHP_EOL;


    echo
'<h1>Bundesland f&uuml;r Postleitzahl 72145</h1>' . PHP_EOL;
    echo
$oSI->getStateFromPostcode(72145) . PHP_EOL;

    echo
'<h1>Feiertage 2021 in Sachsen</h1>' . PHP_EOL;
   
$aList = $oSI->listOfficialHolidays('SN', 2021);
    foreach (
$aList as $aHoliday) {
        echo
date('d.m.Y', $aHoliday['date']) . ': ' . $aHoliday['name'] . '<br/>' . PHP_EOL;
    }


Details

This class provides some information for federal states of - germany - austria - switzerland ('federal states' -> 'cantons') and the public holidays applicable to the individual federal states. For moving public holidays (not on a fixed date, e.g. Easter), a calculation of the date for any calendar year is included. Since there are sometimes several number ranges per state, the main issue of this class is the relationship between the postcode and the state to which the respective place belongs. This information is often required to determine state-specific regulations (e.g. public holidays, school holidays, laws ...) The class provides a list of all federal states and the corresponding abbreviation. Conversely, a corresponding SQL WHERE condition can be created in order to find all addresses in a database in a particular state. (usually the address data do not contain the correct state information) Since this information normally do not change, an XML file was chosen for data storage, which allows easily access with XPath. 1.Notes to the reverse search of federal state from postcode ------------------------------------------------------------ Since the backward search is based on areas from-to, it does not necessarily mean that the postcode that is being searched for actually exists - the validation of a postcode should be carried out via a database or an appropriate (web) service. Due to the fact that some postcodes in Austria and Switzerland include a cross-federal state area, it is possible that in this case a comma-separated list of the affected federal states (or abbreviations) will be returned as a result. 2. Notes about public holidays ------------------------------------------------------------- 2.a Germany In Germany there are a few public holidays that are only partially valid within a federal state - here you should then query directly via the postcode. 2.b Austria / Switzerland In the case, that a given postcode belongs to multiple states it does not make sense to query the valid public holidays using the postcode, since no clear state can be assigned.

  Files folder image Files  
File Role Description
Files folder imagelib (2 directories)
Accessible without login Plain text file readme.txt Doc. readme
Accessible without login Plain text file StatesInfoTestAT.php Example Testscript for Austria
Accessible without login Plain text file StatesInfoTestCH.php Example Testscript for Switzerland
Accessible without login Plain text file StatesInfoTestDE.php Example Testscript for Germany

  Files folder image Files  /  lib  
File Role Description
Files folder imageHelper (1 file)
Files folder imageStatesInfo (2 files)

  Files folder image Files  /  lib  /  Helper  
File Role Description
  Accessible without login Plain text file ExtDOMDocument.php Aux. Helper class for easier XML access

  Files folder image Files  /  lib  /  StatesInfo  
File Role Description
  Plain text file StatesInfo.php Class class to get infos for federal states
  Accessible without login Plain text file StatesInfoData.xml Data XML-Data file

 Version Control Unique User Downloads Download Rankings  
 0%
Total:46
This week:1
All time:10,728
This week:560Up