cmelda/holidays

Holidays and Name's day by country

Maintainers

Package info

gitlab.com/cmelda/holidays

Issues

pkg:composer/cmelda/holidays

Fund package maintenance!

Ko-Fi

Statistics

Installs: 22

Dependents: 0

Suggesters: 0

Stars: 0

v1.6 2026-06-16 15:30 UTC

This package is auto-updated.

Last update: 2026-06-16 13:31:06 UTC


README

Latest Stable Version Total Downloads License PHP Version Require

Install

composer require cmelda/holidays

List of available countries

List

Map of supported countries

Map legend: green = public holidays and name's days, orange = public holidays only.

Map source: Blank map of Europe (without disputed regions).svg, Wikimedia Commons, CC BY-SA 4.0.

Usage

Public Holiday


$holidays = new \Cmelda\Holidays\Holidays('cze');

$date = new DateTimeImmutable();

$day = $holidays->getDay($date);

try {
    $publicHolidays = $day->getPublicHolidays();
} catch (\Cmelda\Holidays\Exceptions\NoPublicHolidayException $e) {
    // no public holiday
}

Name's day


$holidays = new \Cmelda\Holidays\Holidays('cze');

$date = new DateTimeImmutable();

$day = $holidays->getDay($date);

try {
    $names = $day->getNames();
} catch (\Cmelda\Holidays\Exceptions\NotImplementedException $e) {
    // name-day calendar is not implemented for this country
} catch (\Cmelda\Holidays\Exceptions\NoNameException $e) {
    // no name's day
}

Public holidays and name's days are maintained separately. A country can be supported for public holidays even when its name's day calendar is not available; in that case getPublicHolidays() works and getNames() throws NotImplementedException. NoNameException is used only when a name's day calendar is implemented, but the selected date has no name's day.

Name's day calendars are available only for countries that have a matching src/names/{iso}.json data file. The supported countries map uses green for countries with both public holidays and name's days, and orange for public holidays only.

Day


$date = new DateTimeImmutable();

$day = new \Cmelda\Holidays\Day($date);

try {
    $names = $day->getNames('cze');
} catch (\Cmelda\Holidays\Exceptions\NotImplementedException $e) {
    // name-day calendar is not implemented for this country
} catch (\Cmelda\Holidays\Exceptions\NoNameException $e) {
    // no name's day
}

try {
    $names = $day->getNames('svk');
} catch (\Cmelda\Holidays\Exceptions\NotImplementedException $e) {
    // name-day calendar is not implemented for this country
} catch (\Cmelda\Holidays\Exceptions\NoNameException $e) {
    // no name's day
}

Business day calculation


use Cmelda\Holidays\BusinessDayCalculator;

$calculator = new BusinessDayCalculator('cze');

$calculator->isWeekend(new DateTimeImmutable('2024-12-21')); // true
$calculator->isHoliday(new DateTimeImmutable('2024-12-24')); // true
$calculator->isWorkingDay(new DateTimeImmutable('2024-12-27')); // true

$nextWorkingDay = $calculator->nextWorkingDay(new DateTimeImmutable('2024-12-24'));
echo $nextWorkingDay->format('Y-m-d'); // 2024-12-27

$afterOneWorkingDay = $calculator->addWorkingDays(
    new DateTimeImmutable('2024-03-28'),
    1,
);
echo $afterOneWorkingDay->format('Y-m-d'); // 2024-04-02

$includingStartDay = $calculator->addWorkingDays(
    new DateTimeImmutable('2024-03-27'),
    1,
    true,
);
echo $includingStartDay->format('Y-m-d'); // 2024-03-27

If you need all calculations to use a specific timezone, pass it to the constructor:


use Cmelda\Holidays\BusinessDayCalculator;

$calculator = new BusinessDayCalculator(
    'cze',
    new DateTimeZone('Europe/Prague'),
);

License

Distributed under the MIT License. See LICENSE.txt for more information.

Donation

ko-fi