portavice / public-holidays-calculator
A calculator for public holidays written in PHP
Installs: 6 239
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/portavice/public-holidays-calculator
Requires
- php: ^8.1
- ext-calendar: *
- nesbot/carbon: ^2.66.0|^3.8.6
Requires (Dev)
This package is auto-updated.
Last update: 2025-11-06 08:04:49 UTC
README
This package allows you to calculate with public holidays and working days in PHP based on an extension of the Carbon library.
Usage
Installation
To install this package with Composer:
composer require portavice/public-holidays-calculator
Use the Carbon extension
<?php use Carbon\Carbon; use Portavice\PublicHolidays\Carbon\Calculator; Calculator::register(); // Register Carbon macros Carbon::setPublicHolidays([ new FixedHoliday(1, 1), // New Year FlexibleHoliday::EasterMonday, ]); $jan01 = Carbon::create(2022, 1, 1); $jan01->isWorkingDay(); // false $dec27 = Carbon::create(2022, 12, 27); $dec->isWorkingDay(); // true $dec27->subWorkingDays(2); // 2022-12-22 $dec27->subWorkingDay(); // 2022-12-23 $dec27->addWorkingDay(); // 2022-12-28 $dec27->addWorkingDays(10); // 2023-01-10
Development
How to develop
- Run
composer installto install the dependencies for PHP. - Run
composer testto run all PHPUnit tests. - Run
composer csto check compliance with the code style andcomposer csfixto fix code style violations before every commit.
Code Style
PHP code MUST follow PSR-12 specification.
We use Laravel Pint for the PHP code style check.