节假日 您所在的位置:网站首页 Dayjs中文网 节假日

节假日

2024-04-18 21:20| 来源: 网络整理| 查看: 265

Day.js 本身并不支持节假日的判断,不过可以通过三方插件或类库实现,下面列举两个示例:

# chinese-workday # 安装

https://www.npmjs.com/package/chinese-workday (opens new window)

npm install chinese-workday # 使用 // const { isWorkday, isHoliday, getFestival } = require('chinese-workday'); const ww = require('chinese-workday'); const isWorkday = ww.isWorkday; const isHoliday = ww.isHoliday; const getFestival = ww.getFestival; const isAddtionalWorkday = ww.isAddtionalWorkday; isWorkday('2022-10-01') // => false isHoliday('2022-10-01') // => true isAddtionalWorkday('2022-01-29') // => true getFestival('2022-10-01') // => 国庆节 # chinese-calendar # 安装

https://www.npmjs.com/package/chinese-calendar (opens new window)

npm i chinese-calendar yarn add chinese-calendar # 使用

浏览器下(基于 webpack 构建)

import calendar from 'chinese-calendar' calendar.isHoliday('2020-10-08') // true calendar.getHolidayDetail('2020-10-07') // ['National Day', '国庆节', 3]

NodeJS 下

const calendar = require('chinese-calendar') calendar.isHoliday('2020-10-08') // true calendar.getHolidayDetail('2020-10-07') // ['National Day', '国庆节', 3] # 更多 npm:https://www.npmjs.com/search?q=%E8%8A%82%E5%81%87%E6%97%A5 (opens new window) github:https://github.com/search?q=%E8%8A%82%E5%81%87%E6%97%A5 (opens new window) Last Updated: 4/8/2023, 11:34:01 AM

← 时区



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有