bzarzuela/deadline-calculator

Simplifies computation of TAT with overrides of operating hours and holidays

v0.4 2018-06-28 09:56 UTC

This package is not auto-updated.

Last update: 2024-04-28 03:41:26 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

A very common requirement in our projects is the ability for the CRM to compute for the deadline of a Ticket. There are a lot of factors that have to be considered when computing deadlines such as weekends, operating hours that vary, etc

By default, the package assumes a 24/7 operation. The recommended usage is to pre-configure the class and bind it to the Service Provider of your application.

Installation

You can install the package via composer:

composer require bzarzuela/deadline-calculator

Usage

$calculator = new Bzarzuela\DeadlineCalculator();
$calculator->startFrom('2018-06-28 12:20:00);
$calculator->tatInDays(3);
echo $calculator->deadline(); // 2018-07-01 12:20:00 

It supports bypassing weekends in the calculation.

$calculator->noWeekends();

TAT can also be set in hours

$calculator->tatInHours(24);

Operating Hours is supported for cases when TAT is measured in hours

$calculator->tatInHours(24)
    ->operatingHours('09:00:00', '17:00:00'); // 9am to 5pm working hours

You can also set or override operating hours on a per-day basis

$calculator->tatInHours(24)
    ->operatingHours('09:00:00', '17:00:00') // 9am to 5pm working hours
    ->saturday('09:00:00', '12:00:00') // Half day on Saturday
    ->noSunday(); // No work on Sundays

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email bryan@teleserv.ph instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.