citco / carbon
这是nesbot/carbon的包装器,同时计算哪些天是英国的银行假日(仅限于英格兰和威尔士)。
3.0.0
2024-05-28 11:56 UTC
Requires
- php: ^8.1
- nesbot/carbon: 3.*
README
这是Carbon的包装器,同时也计算哪些天是英国的银行假日(仅限于英格兰和威尔士)。
安装
使用Composer
$ composer require citco/carbon
{ "require": { "citco/carbon": "*" } }
<?php require 'vendor/autoload.php'; use Citco\Carbon; echo "Today is ", (new Carbon)->isBankHoliday() ?: "not bank holiday";
不使用Composer
你为什么不用composer?从仓库下载Carbon.php并将其保存到项目的路径中。(您还需要下载nesbot/carbon)
<?php require 'path/to/nesbot/Carbon.php'; require 'path/to/citco/Carbon.php'; use Citco\Carbon; echo "Today is ", (new Carbon)->isBankHoliday() ?: "not bank holiday";
示例代码
这里有一些使用此类的示例
// Creates a new instance of the class $c = new Carbon(); // Today's date $c = new Carbon('2012-05-21'); // Date as string $c = Carbon::parse('First day of May 2011'); // Checks if the given date is bank holiday $boolean = $c->isBankHoliday('2016-05-21'); $boolean = $c->isBankHoliday(Carbon::parse('First day of 2000')); // Returns array of holidays for the given year $c->getBankHolidays(2015); $c->getBankHolidays(array(2010, 2012)); $c->getBankHolidays(Carbon::now()); // Returns New Year date of the given year $c->getNewYearBankHoliday(2012); // 2012-01-02 // Without any parameter will return date for the init year $c->getNewYearBankHoliday(); $c->getGoodFridayBankHoliday(); $c->getEasterMondayBankHoliday(); $c->getEarlyMayBankHoliday(); $c->getSpringBankHoliday(); $c->getSummerBankHoliday(); $c->getBoxingDayBankHoliday(); $c->getChristmasBankHoliday(); // Returns next/previous bank holiday $c->nextBankHoliday(); $c->previousBankHoliday(); $c->nextBankHoliday(Carbon::parse('Next year May 1st')); $c->previousBankHoliday(Carbon::parse('Next year May 1st')); // Returns N next/previous bank holidays $n = 20; $c->nextBankHolidays($n); $c->previousBankHolidays($n); $c->nextBankHolidays($n, Carbon::parse('Next year May 1st')); $c->previousBankHolidays($n, Carbon::parse('Next year May 1st')); // Returns the list of bank holidays between two dates $start = Carbon::now(); $end = Carbon::now()->subYear(1); $holidays = $start->bankHolidaysSince($end);
问题
错误报告和功能请求可以在Github Issue Tracker上提交。
要求
PHP 8.1或更高版本(对于较旧的PHP版本,请使用此包的1.x或2.x版本)
许可
Bank Holidays遵循MIT许可证 - 请参阅LICENSE文件以获取详细信息