Giter Site home page Giter Site logo

statutory-holidays-cn's Introduction

statutory-holidays-cn

statutory holidays for china **法定节假日

默认只有18年的

安装

composer require darkwind/statutory-holidays-cn

栗子

use Holiday\Holiday;

//判断是否为假期
Holiday::isHoliday('20180501');
    [
         "result" => "yes",
         "info" => [
           "day" => "20180501",
           "holiday" => "劳动节",
           "holiday_remark" => "4月29日至5月1日放假调休,共3天。4月28日(星期六)上班",
           "begin" => "",
           "end" => "",
         ],
    ]

Holiday::isHoliday('20180502');
    [
         "result" => "no",
         "info" => [
           "day" => "20180502",
           "holiday" => "",
           "holiday_remark" => "",
           "begin" => "",
           "end" => "",
         ],
    ]


//判断是否为工作日
Holiday::isWorkday('20180501');
Holiday::isWorkday('20180502');
Holiday::isWorkday('20180505');

//2个日期间有多少个假日
Holiday::holidays('20180301', '20180601');
Holiday::holidays('20180421', '20180502');
[
     "date" => [
       [
         "day" => "20180421",
         "holiday" => "",
         "holiday_remark" => "",
         "begin" => "",
         "end" => "",
       ],
       [
         "day" => "20180422",
         "holiday" => "",
         "holiday_remark" => "",
         "begin" => "",
         "end" => "",
       ],
       [
         "day" => "20180429",
         "holiday" => "劳动节",
         "holiday_remark" => "4月29日至5月1日放假调休,共3天。4月28日(星期六)上班",
         "begin" => "",
         "end" => "",
       ],
       [
         "day" => "20180430",
         "holiday" => "劳动节",
         "holiday_remark" => "4月29日至5月1日放假调休,共3天。4月28日(星期六)上班",
         "begin" => "",
         "end" => "",
       ],
       [
         "day" => "20180501",
         "holiday" => "劳动节",
         "holiday_remark" => "4月29日至5月1日放假调休,共3天。4月28日(星期六)上班",
         "begin" => "",
         "end" => "",
       ],
     ],
     "count" => 5,
]

//追加星期信息
Holiday::isHolidayWithAppend('20180501');
[
     "result" => "no",
     "info" => [
       "day" => "20180502",
       "holiday" => "",
       "holiday_remark" => "",
       "begin" => "",
       "end" => "",
       "weekDay" => "6",
       "cn" => "周六",
       "en" => "Saturday",
     ],
]

扩展

暂时只支持返回数组,需要其他格式请继承并重载 src/Response.php
自定义节假日或增加其他年份假期,请自行修改config/custom.php

测试

cd tests
php test.php

statutory-holidays-cn's People

Contributors

iwiilbeback avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

statutory-holidays-cn's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.