Socket
Socket
Sign inDemoInstall

legal-holidays-cn

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

legal-holidays-cn

Judge whether a data is a legal holiday in China


Version published
Maintainers
1
Created
Source

Introduction

判断某个日期是否为国家法定节假日及详细信息(目前支持 2023、2022 年)。默认查询 2023 年,如需查询 2022 年数据,api 传入参数'2022'

Installation

npm install legal-holidays-cn --save

yarn add legal-holidays-cn -S

use

import { isHoliday } from "legal-holidays-cn";

API

判断某日期是否为法定节假日,返回布尔值

isHoliday('20231001') // true
isHoliday('20221001','2022') // true

获取 2023 年所有法定节假日 日期数组

getHolidaysByYears()
// ["20221231","20230101","20230102",...,"20231006"]
getHolidaysByYears('2022')
// ["20220101","20220102","20220103",...,"20221007"]

获取 2023 年所有法定节假日日期详细数组

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}

Keywords

FAQs

Package last updated on 09 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc