2017 © Pedro Peláez
 

library carbon-business-days

A simple class for business days counting

image

code16/carbon-business-days

A simple class for business days counting

  • Thursday, May 24, 2018
  • by code16
  • Repository
  • 2 Watchers
  • 7 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 200 % Grown

The README.md

A simple business days calculator

This package aims to count business working days between two Carbon dates., (*1)

Usage

$date = new BusinessDays();

// Set holidays (2018-1-1 is a Monday)
$date->addHoliday(Carbon::createFromDate(2018, 1, 1));

// Should return 9
$days = $date->daysBetween(
    Carbon::createFromDate(2018, 1, 1),
    Carbon::createFromDate(2018, 1, 15)
);

// Set a closed period (whole 2nd week)
$date->addClosedPeriod(
    Carbon::createFromDate(2018, 1, 8),
    Carbon::createFromDate(2018, 1, 12)
);

// Should return 5
$days = $date->daysBetween(
    Carbon::createFromDate(2018, 1, 1),
    Carbon::createFromDate(2018, 1, 15)
);

Default for weekend days are saturdays and sundays, but it can be configured:, (*2)

$date->setWeekendDays([Carbon::SUNDAY, Carbon::MONDAY]);

You can also add or subtract days from a given date:, (*3)

$newDate = $date->addDaysTo(
    Carbon::createFromDate(2018, 5, 14), 
    10
);
$newDate = $date->subDaysFrom(
    Carbon::createFromDate(2018, 5, 14), 
    10
);

Installation

composer require code16/carbon-business-days

License

MIT, (*4)

The Versions

24/05 2018

dev-master

9999999-dev

A simple class for business days counting

  Sources   Download

MIT

The Requires

 

The Development Requires

by Philippe Lonchampt