gt-volk/working-time

This package is abandoned and no longer maintained. No replacement package was suggested.

Simple rabbitmq integration for Laravel

dev-master 2022-04-04 16:21 UTC

This package is auto-updated.

Last update: 2022-04-04 16:28:01 UTC


README

Latest Version on Packagist Software License Build Status Quality Score Code Coverage StyleCI Total Downloads

Install

Via Composer

$ composer require gt-volk/working-time

Usage

A set of opening hours is created by passing in a regular schedule, and a list of holidays.

$workingTime = new WorkingTime([
    'workingDays' => [
        '1' => '09:00-18:00', // monday
        '2' => '09:00-18:00', // tuesday
        '3' => '09:00-18:00', // wednesday
        '4' => '09:00-18:00', // thursday
        '5' => '09:00-17:00', // friday
        '6' => '09:00-18:00', // saturday
        '0' => '09:00-18:00', // sunday
    ],
    'weekends' => ['6', '0'],
    'holidays' => ['01-01', '01-02', '01-03'],
]);

Checks whether the working day.

// Wednesday working day
$workingTime->isWorkingDate('2016-10-26'); // true

// Holiday non-working day
$workingTime->isWorkingDate('2017-01-01'); // false

Checks is the time of working.

// It is not working time
$workingTime->isWorkingTime('2016-10-26 18:30'); // false

// It is working time
$workingTime->isWorkingTime('2016-10-26 16:00'); // true

Checks a day holiday and the weekend.

// Holiday
$workingTime->isHoliday('2017-01-01'); // true

// Weekend
$workingTime->isWeekend('2016-10-29'); // true

Returns the following working day and time.

$workingTime->nextWorkingDay('2016-10-26'); // 2016-10-27
$workingTime->nextWorkingDay('2017-01-01'); // 2017-01-04

$workingTime->nextWorkingTime('2016-10-28 17:50'); // 2016-10-31 09:00
$workingTime->nextWorkingTime('2016-10-28 7:30'); // 2016-10-28 09:00
// If the time in the operating boundaries of the empty string is returned.
$workingTime->nextWorkingTime('2016-10-27 17:50'); // empty string

It returns the length of the working day in minutes.

$workingTime->getJobMinutesInDay('2016-10-27'); // 540 minutes
$workingTime->getJobMinutesInDay('2016-10-28'); // 480 (shot day)

Adds the specified number of minutes to time, taking into account weekends, holidays and work schedules.

$workingTime->modify(60, '2016-10-31 13:00'); // 2016-10-31 14:00 work time
$workingTime->modify(60, '2016-12-31 19:00'); // 2017-01-04 10:00 the working day is over so the move on the morning after the holidays
$workingTime->modify(180, '2016-11-01 7:00'); // 2016-11-01 12:00 Time has not yet come, measured from 9 am

Returns the working time in minutes in the specified time interval.

$workingTime->calculatingWorkingTime('2018-12-05 07:00:00', '2018-12-05 07:30:00'); // 0 minutes
$workingTime->calculatingWorkingTime('2016-11-07 10:00:00', '2016-11-07 14:00:00'); // 240 minutes
$workingTime->calculatingWorkingTime('2018-12-13 15:30:00', '2018-12-18 09:30:00'); // 1200 minutes

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email alex@bushlanov.pro instead of using the issue tracker.

Credits

License

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