ixnode/php-public-holiday

此PHP包可自动生成给定年份的假期,同时考虑联邦州和国家。它提供了一个易于使用的接口,用于根据特定地区检索公共假期,确保所有支持区域都能获得准确和最新的假期信息。

0.1.1 2024-07-18 22:03 UTC

This package is auto-updated.

Last update: 2024-09-18 22:15:59 UTC


README

Release PHP PHPStan PHPUnit PHPCS PHPMD Rector - Instant Upgrades and Automated Refactoring LICENSE

此PHP包可自动生成给定年份的假期,同时考虑联邦州和国家。它提供了一个易于使用的接口,用于根据特定地区检索公共假期,确保所有支持区域都能获得准确和最新的假期信息。

1. 使用方法

use Ixnode\PhpPublicHoliday\Holiday;

1.1 从萨克森州获取德国的公共假期

$year = 2024;
$country = \Ixnode\PhpPublicHoliday\Configuration\Country::DE;
$state = \Ixnode\PhpPublicHoliday\Configuration\Country\CountryDe::STATE_SN;

$holiday = new Holiday($year, $country, $state);

print_r($holiday->getHolidays());
// (array) [Ixnode\PhpPublicHoliday\HolidayItem Object, ...]
// - (DateTimeImmutable) ->getDate()
// - (string) ->getName()

2. 安装

composer require ixnode/php-public-holiday
vendor/bin/php-public-holiday -V
php-public-holiday 0.1.0 (2024-07-18 20:33:58) - Björn Hempel <bjoern@hempel.li>

3. 命令行工具

用于快速检查公共假期。

bin/console ph DE SN 2024

或在您的composer项目中

vendor/bin/php-public-holiday ph DE SN 2024
Country: DE
State:   SN
Year:    2024

- 2024-01-01: Neujahr
- 2024-03-29: Karfreitag
- 2024-03-31: Ostersonntag
- 2024-04-01: Ostermontag
- 2024-05-01: Tag der Arbeit
- 2024-05-09: Christi Himmelfahrt
- 2024-05-19: Pfingstsonntag
- 2024-05-20: Pfingstmontag
- 2024-10-03: Tag der deutschen Einheit
- 2024-12-25: Erster Weihnachtsfeiertag
- 2024-12-26: Zweiter Weihnachtsfeiertag

4. 库开发

git clone git@github.com:ixnode/php-public-holiday.git && cd php-public-holiday
composer install
composer test

5. 许可证

本库采用MIT许可证 - 有关详细信息,请参阅LICENSE文件。

6. 作者