Package Exports
- cn-workday
- cn-workday/dist/cn-workday.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cn-workday) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cn-workday
获取中国工作日情况
Installation
$ npm install cn-workday
Or
$ yarn add cn-workday
Usage
import { isWorkday, getWorkdays, getWorkdaysBetween } from 'cn-workday';
isWorkday(); // 返回今天是否是工作日
isWorkday('2022-10-08'); // true
isWorkday(new Date('2022-10-08')); // true
getWorkdays(); // 返回本周的工作日数组
getWorkdays('2022-10-08'); // 返回 2022-10-08 所在周的工作日数组
getWorkdays('2022-10-08', 'Month'); // 返回 2022-10-08 所在月份的工作日数组
getWorkdays(['2025-02-23', '2025-02-22', '2025-02-21']) // 返回入参数组中的工作日数组
getWorkdaysBetween('2022-10-01', '2022-10-31'); // 返回2022-10-01与2022-10-31之间的工作日数组
node使用
const { isWorkday, getWorkdays, getWorkdaysBetween } = require('cn-workday');
isWorkday(); // 返回今天是否是工作日
getWorkdays(); // 返回本周的工作日数组
getWorkdays(['2025-02-23', '2025-02-22', '2025-02-21']) // 返回入参数组中的工作日数组
getWorkdaysBetween('2022-10-01', '2022-10-31'); // 返回2022-10-01与2022-10-31之间的工作日数组
Api
isWorkday
判断一个日期是否为工作日
- param: date string | Date 日期
- return: Boolean
getWorkDays
获取一个日期所在周|月的工作日数组或者获取一个数组里的工作日
- param1: date string | dateStr array | date array | Date | 'Week' | 'Month'
- param2: 'Week' | 'Month'
- return: Array [{ d: Date, dateStr: dateString, type: number }] type: 1(工作日)/2(周末补班)/3(周末)/4(节假日)
getWorkdaysBetween
获取两个日期之间的工作日数组
- param1: date string
- param2: date string
- return: [{ d: Date, dateStr: dateString, type: number }] type: 1(工作日)/2(周末补班)/3(周末)/4(节假日)