andrejsstepanovs / business-days-calculator
Business day calculation
Installs: 57 924
Dependents: 0
Suggesters: 0
Security: 0
Stars: 24
Watchers: 4
Forks: 21
Open Issues: 6
Requires
- php: >=5.4.0
- phpunit/phpunit: 4.*
- satooshi/php-coveralls: 0.*@dev
This package is auto-updated.
Last update: 2024-11-17 05:57:08 UTC
README
Business Days Calculator
Install
- If you're using Composer to manage dependencies, you can use
composer require andrejsstepanovs/business-days-calculator
or add to your composer.json file:
"require": {
"andrejsstepanovs/business-days-calculator": "1.*",
}
Example
use \BusinessDays\Calculator; $holidays = [ new \DateTime('2000-12-31'), new \DateTime('2001-01-01') ]; $freeDays = [ new \DateTime('2000-12-28') ]; $freeWeekDays = [ Calculator::SATURDAY, Calculator::SUNDAY ]; $calculator = new Calculator(); $calculator->setStartDate(new \DateTime('2000-12-27')); $calculator->setFreeWeekDays($freeWeekDays); // repeat every week $calculator->setHolidays($holidays); // repeat every year $calculator->setFreeDays($freeDays); // don't repeat $calculator->addBusinessDays(3); // add X working days $result = $calculator->getDate(); // \DateTime echo $result->format('Y-m-d'); // 2001-01-03