diohz0r / holidays
add and check holidays for your project
dev-master
2018-09-18 02:21 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-04-18 17:13:59 UTC
README
This library helps you to add and check dates against holidays and worktime.
Install
Is recommended to install this via composer:
$ composer require diohz0r/holidays
Use
The use is very simple, extend the class add your regional holidays and create the object. Example:
<?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 }