Giter Site home page Giter Site logo

cn-holiday's Introduction

CN-HOLIDAY

cn-holiday.js是一个基于国务院发布的每年的节假日的一个日期库,包含了对节假日(三倍工资),休息日(双倍工资)和工作日(包括国家规定调休)的查询api。

目前支持2011-2018年的节假日查询

Installation

NPM:

$ npm install cn-holiday --save

Getting Started

import ch from 'cn-holiday'

ch.isHoliday('2018-10-1')

API

isHoliday

判断一个日期是否为法定节假日

  • date string|timestamp|Date 日期
  • 返回:boolean
ch.isHoliday('2018-5-1')
// true

isWorkday

判断一个日期是否为工作日(包括法定调休)

  • date string|timestamp|Date 日期
  • 返回:boolean
ch.isWorkday('2018-4-28')
// true

isRestday

判断一个日期是否为法定休息日(除开正常双休)

  • date string|timestamp|Date 日期
  • 返回:boolean
ch.isRestday('2018-4-30')
// true

getHolidaysBetween

获取两个日期之间的所有法定节假日

  • date1 string|timestamp|Date 日期1
  • date2 string|timestamp|Date 日期2
  • 返回:Array
ch.getHolidaysBetween('2018-10-1', '2018-10-3')
// ['2018-10-01', '2018-10-02', '2018-10-03']

getWorkdaysBetween

获取两个日期之间的所有工作日

  • date1 string|timestamp|Date 日期1
  • date2 string|timestamp|Date 日期2
  • 返回:Array
ch.getWorkdaysBetween('2018-9-28', '2018-10-8')
// ['2018-09-28', '2018-09-29', '2018-09-30', '2018-10-08']

getWorkdaysCountBetween

获取两个日期之间的所有工作日数量

  • date1 string|timestamp|Date 日期1
  • date2 string|timestamp|Date 日期2
  • 返回:Number
ch.getWorkdaysBetween('2018-9-28', '2018-10-8')
// 4

License

MIT

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.