判断某个日期是否为国家法定节假日及详细信息(目前支持 2023、2022 年)。默认查询 2023 年,如需查询 2022 年数据,api 传入参数'2022'
npm install legal-holidays-cn --save
yarn add legal-holidays-cn -S
import { isHoliday } from "legal-holidays-cn";
isHoliday('20231001') // true
isHoliday('20221001','2022') // true
getHolidaysByYears()
// ["20221231","20230101","20230102",...,"20231006"]
getHolidaysByYears('2022')
// ["20220101","20220102","20220103",...,"20221007"]
getHolidaysDetailByYears()
// [{desc: '元旦', date: ['20221231', '20230101', '20230102'], days: 3}, {…}, {…}, {…}, {…}, {…}, {…}]
getHolidaysDetailByYears('2022')
// [{desc: '元旦', date: ['20220101', '20220102', '20220103'], days: 3}, {…}, {…}, {…}, {…}, {…}, {…}]
getHolidayInfo("20230501")
// {isHoliday: true, desc: '劳动节', date: Array(5), days: 5}
getHolidayInfo("20220501",'2022')
// {isHoliday: true, desc: '劳动节', date: Array(5), days: 5}