diohz0r / holidays
为您的项目添加和检查节假日
dev-master
2018-09-18 02:21 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-18 18:08:22 UTC
README
这个库可以帮助您添加和检查日期是否为节假日或工作日。
安装
建议通过composer安装此库
$ composer require diohz0r/holidays
使用
使用非常简单,扩展类,添加您的区域节假日,并创建对象。示例
<?php use Holidays\AbstractHoliday; class Holiday extends AbstractHoliday { /** * @inheritdoc */ public function addRegionalHolidays($year) { //Fixed Days $dates = array( array('day'=>4,'month'=>6), array('day'=>12,'month'=>10), ); foreach ($dates as $date) { $this->addHoliday($date); } //Variable day $this->addVariableHoliday(4, 11, $year, 4); #Thanksgiving: November's 4th Thursday //In Venezuela Carnival and Easter are holidays so we call this method to add both $this->getCarnival(); } } $objHoliday = new Holiday(date("Y")); if($objHoliday->isValidDate("2014-06-04")){ //Add your logic for valid dates } else { //Add your logic for invalid dates }