承接 joaosalless/dates 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

joaosalless/dates

Composer 安装命令:

composer require joaosalless/dates

包简介

Date library for identification of holidays or commemorative dates (national, state, municipal), automatic calculation of working days and office hours.

README 文档

README

Software License

Collaborative Date library for identification of holidays and commemorative dates from countries, states and cities with automatic calculation of business days and office hours.

This library was inspired by the checkdomain/holiday project, completely rewritten to support holidays and commemorative dates from countries, states and cities with automatic calculation of business days and office hours without having to write a new class for each. Events are loaded from a CSV that may be updated from an collaborative API in the future.

Currently supported countries

  • 🇧🇷 BR Brazil
    • National holidays
    • Estate holidays
    • City holidays
    • Commemorative dates
    • Business days
    • Office hours

Your country, state or city is not supported?

joaosalless/dates is open source. If you use this library it would be great to get some support for currently not implemented countries which you are familiar with. Pull requests will be reviewed and merged fast.

Install

Via Composer

$ composer require joaosalless/dates

Usage

Holidays

$dates = new Joaosalless\Dates\Dates('BR');

// Get only national holidays
$dates->getHolidays('2019-09-07');

// Check if a given date is holiday only national holidays
$dates->isHoliday('2019-09-07');

// Get national and state holidays
$dates->getHolidays(
   '2019-09-07', // Date
   'SP'          // State code
);

// Check if a given date is holiday in national and state holidays
$dates->isHoliday(
   '2019-09-07', // Date
   'SP'          // State code
);

// Get national, state and city holidays
$dates->getHolidays(
   '2019-09-07', // Date
   'SP',         // State code
   '3550308'     // City code
);

// Check if a given date is holiday in national, state and city holidays
$dates->isHoliday(
   '2019-09-07', // Date
   'SP',         // State code
   '3550308'     // City code
);

Commemorative Dates

$dates = new Joaosalless\Dates\Dates('BR');

// Get only national commemorative dates
$dates->getCommemorativeDates('2019-09-07');

// Get national and state commemorative dates
$dates->getCommemorativeDates(
   '2019-09-07', // Date
   'SP'          // State code
);

// Get national, state and city commemorative dates
$dates->getCommemorativeDates(
   '2019-09-07', // Date
   'SP',         // State code
   '3550308'     // City code
);

Business days

Calculates business days from a start date and a specified number of days

// Configure business days and office hours
$config = [
    'week' => [
        'office_hours_start' => '09:00',
        'office_hours_end' => '18:00',
        'check_office_hours' => false,
        'days' => [
            'sun' => [
                'business_day' => false,
            ],
            'mon' => [
                'business_day' => true,
            ],
            'tue' => [
                'business_day' => true,
            ],
            'wed' => [
                'business_day' => false,
            ],
            'thu' => [
                'business_day' => true,
            ],
            'fri' => [
                'business_day' => true,
            ],
            'sat' => [
                'business_day' => true,
                'office_hours_start' => '09:00',
                'office_hours_end' => '14:00',
            ],
        ]
    ]
];

$dates = new Dates('BR', $config);

$dates->calculateBusinessDays(
    10,           // Number of days
    '2019-09-07', // Start date
    'SP',         // Check state holidays
    '3550308',    // Check city holidays
);

$dateTime = new DateTime('2019-07-31 08:23:00');

// Check if given DateTime instance is a business day
$dates->isBusinessDay($dateTime); // Returns bool

// Check if given datetime string is a business day
$dates->isBusinessDay('2019-07-31 08:23:00'); // Returns bool

// Returns \DateTime;

Office hours

Checks if given DateTime instance or datetime string is a office hours

$dates = new Joaosalless\Dates\Dates('BR');

$dateTime = new DateTime('2019-07-31 08:23:00');

// Check if given DateTime instance is a office hour
$dates->isOfficeHour($dateTime); // Returns bool

// Check if given string date is office hours
$dates->isOfficeHour('2019-07-31 08:23:00'); // Returns bool

Change log

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

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email joaosalless@gmail.com instead of using the issue tracker.

Credits

License

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

统计信息

  • 总下载量: 90
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固