gt-volk/working-time

此包已被废弃,不再维护。未建议替代包。

Laravel 的简单 rabbitmq 集成

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

安装

通过 Composer

$ composer require gt-volk/working-time

使用方法

通过传递常规计划和节假日列表创建一组营业时间。

$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'],
]);

检查是否为工作日。

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

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

检查工作时间。

// 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

检查节假日和周末。

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

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

返回下一个工作日和时间。

$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

返回工作日的分钟数长度。

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

将指定分钟数添加到时间,考虑周末、节假日和工作计划。

$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

返回指定时间间隔内的工时(分钟)。

$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

测试

$ composer test

贡献

有关详细信息,请参阅 CONTRIBUTING

安全

如果您发现任何与安全相关的问题,请通过电子邮件 alex@bushlanov.pro 联系,而不是使用问题跟踪器。

鸣谢

许可证

MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件