rotous / holidays-nl
用于查找荷兰假日日期的包
v1.0.0
2021-02-19 10:51 UTC
Requires
- php: >=5.3
This package is auto-updated.
Last update: 2024-09-25 23:50:19 UTC
README
HolidaysNL 包是一个 PHP 包,可用于查找荷兰从公元 0 年至 3000 年(这是一个非常随机的数字)的假日日期
可以检索的假日包括以下
- 新年
- 复活节(第一天和第二天)
- 女王/国王节
- 升天节
- 圣灵降临节(第一天和第二天)
- 圣诞节(第一天和第二天)
安装
可以使用 composer 安装此包
composer require rotous/holidays-nl
用法
<?php // Make sure you use the correct path to the autoload file! require_once 'vendor/autoload.php'; $api = new \rotous\holidays\HolidaysNL(); $holidays = $api->getHolidays(1972); /* array(9) { [0]=> string(10) "01-01-1972" [1]=> string(10) "02-04-1972" [2]=> string(10) "03-04-1972" [3]=> string(10) "01-05-1972" [4]=> string(10) "11-05-1972" [5]=> string(10) "21-05-1972" [6]=> string(10) "22-05-1972" [7]=> string(10) "25-12-1972" [8]=> string(10) "26-12-1972" } */ $api->isHoliday('01-05-1972'); // true $api->getEaster(1972); // "02-04-1972" $api->getSecondEasterDay(1972); // "03-04-1972"
所有公共函数都有一个基于 DateTime 的对应函数
$holidays = $api->getHolidaysDateTime(1972); /* array(9) { [0]=> object(DateTime)#4 (3) { ["date"]=> string(26) "1972-01-01 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [1]=> object(DateTime)#5 (3) { ["date"]=> string(26) "1972-04-02 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [2]=> object(DateTime)#6 (3) { ["date"]=> string(26) "1972-04-03 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [3]=> object(DateTime)#12 (3) { ["date"]=> string(26) "1972-05-01 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [4]=> object(DateTime)#7 (3) { ["date"]=> string(26) "1972-05-11 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [5]=> object(DateTime)#8 (3) { ["date"]=> string(26) "1972-05-21 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [6]=> object(DateTime)#9 (3) { ["date"]=> string(26) "1972-05-22 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [7]=> object(DateTime)#10 (3) { ["date"]=> string(26) "1972-12-25 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Berlin" } [8]=> object(DateTime)#11 (3) { ["date"]=> string(26) "1972-12-26 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Berlin" } } */ $api->isHolidayDateTime(new \DateTime('1972-05-01')); // true $api->getEasterDateTime(1972); /* object(DateTime)#4 (3) { ["date"]=> string(26) "1972-04-02 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } */ $api->getSecondEasterDayDateTime(1972); /* object(DateTime)#4 (3) { ["date"]=> string(26) "1972-04-03 12:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } */
完整的 API 文档可以在 https://rotous.github.io/holidaysNL/ 找到