webmasterskaya/生产日历

俄罗斯联邦生产日历

2.0.2 2021-09-15 15:35 UTC

This package is auto-updated.

Last update: 2024-09-23 22:04:36 UTC


README

根据俄罗斯联邦2013-2022年生产日历,列出工作日、节假日、休息日和非工作日
数据由网站 http://www.consultant.ru/ 提供

开始使用

要开始使用,请将包添加到您的项目中 composer require webmasterskaya\ProductionCalendar

然后加载所需类

use webmasterskaya\ProductionCalendar\Calendar;
use webmasterskaya\ProductionCalendar\Updater;

所有数据的数组可以在 json 文件中找到 - holidays.json

Calendar 类方法的说明

检查具体日期

是否为工作日

Calendar::isWorking($date, $weekend = [6, 0]); //bool

是否为节假日

该方法检查的不是实际节日,而是节日+周末

Calendar::isHoliday($date = null); //bool

是否为前节日

通常,前节日的工作日会缩短一小时。前节日可能会落在周末上,该周末被视为工作日,因此 isWorking 将返回 true,而 isHoliday 将返回 false

Calendar::isPreHoliday($date); //bool

是否为非工作日

2020年出现了新的“非工作日”定义。非工作日是根据俄罗斯总统2020年3月25日第206号、4月2日第239号、4月28日第294号、5月29日第345号、2021年4月23日第242号令设定的。

Calendar::isNoWorking($date); //bool

按日期搜索

找到指定日期之后的最近工作日。

Calendar::find($date = null)->working()->format($format = null); //string

找到指定日期之后的最近周末。

Calendar::find($date = null)->holiday()->format($format = null); //string

找到指定日期之后的最近前节日。

Calendar::find($date = null)->preHoliday()->format($format = null); //string

找到指定日期之后的最近非工作日。

Calendar::find($date = null)->noWorking()->format($format = null); //string

获取日期列表

获取一年中所有工作日的列表

Calendar::getWorkingsByYear($year); //array

获取一年中所有周末的列表

Calendar::getHolidaysByYear($year); //array

获取一年中所有前节日的列表

Calendar::getPreHolidaysByYear($year); //array

获取一年中所有非工作日的列表

Calendar::getNoWorkingByYear($year); //array

获取指定日期范围内的所有周末列表

Calendar::getHolidaysListByInterval($date_from, $date_to, $format = null); //array

Updater 类方法的说明

更新指定年份的数据

Updater::update($year = null); //void

从2013年开始更新所有数据,直到当前

Updater::updateAll(); //void

数据更新

要更新数据,需要执行 cli 脚本 parser.php

php -f parser.php # обновит данные за текущий год
php -f parser.php 2020 # обновит данные за указанный год
php -f parser.php all # обновит все данные за промежуток с 2013 по текущий год