Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
festival_chn
Advanced tools
Festival_chn
是一个简单易用的中国节日和法定节假日判断工具库,支持浏览器和 Node.js 环境。它提供了多种 API 来查询某一天是否是节日和法定节假日,获取假期名称等功能,以及查询指定日期范围内的假期信息和天数等。它无需依赖其它库和异步请求,数据源直接内置在库文件中。
npm install festival_chn
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Festival_chn Example</title>
</head>
<body>
<script src="./dist/festival.js"></script>
<script>
const getSwapHolidaysInRange = Festival.getSwapHolidaysInRange(20230101, 20230131)
console.log('getSwapHolidaysInRange ===>', getSwapHolidaysInRange)
</script>
</body>
</html>
const { Festival_chn } = require('festival_chn');
const festival = new Festival();
const dayInfo = festival.day(20220101);
console.log(dayInfo.name); // "元旦"
const festival = new Festival();
const dayInfo = festival.day(20220101);
console.log(dayInfo);
{
date: 20220101,
name: "元旦",
isHoliday: true,
isLegal: true,
isSwap: false
}
返回的结果对象包含以下字段:
字段名称 | 字段类型 | 说明 |
---|---|---|
date | Number | 八位数字组成的年月日 |
name | String | 节日名称 |
isHoliday | Boolean | 是否为假期节假日 |
isLegal | Boolean | 是否为法定节假日 |
isSwap | Boolean | 是否为调休日 |
const festival = new Festival();
const name = festival.name(20220101);
console.log(name); // "元旦"
const festival = new Festival();
const isHoliday = festival.isHoliday(20220101);
console.log(isHoliday); // true
const isLegal = festival.isLegal(20220101);
console.log(isLegal); // true
const isSwap = festival.isSwap(20220101);
console.log(isSwap); // false
const festival = new Festival();
const daysInRange = festival.getDaysInRange(20230101, 20230131);
console.log(daysInRange);
const festival = new Festival();
const legalHolidays = festival.getLegalHolidaysInRange(20230101, 20230131);
console.log(legalHolidays);
const festival = new Festival();
const count = festival.getHolidaysInRange(20230101, 20230131);
console.log(count);
const festival = new Festival();
const count = festival.countHolidaysInRange(20230101, 20230131);
console.log(count);
Festival_chn 内置了中国节日和法定节假日的数据源,其基本来源于互联网上公开的数据。如果你需要更新数据源,可以修改 chn文件夹下的三个文件。
由于中国国家法定节假日的调休规则相对复杂,如果需要进行严格的判断和计算,请慎重使用本库。例如,如何判断 2021 年端午节和中秋节的调休情况,需要考虑到国务院发布的调休政策和各省市的具体实施情况,需要一定的研究和验证。本库只能作为预估和参考之用,不保证其完全正确性和准确性,使用者应自行验证并承担风险。
FAQs
## 介绍 `festival_chn` 无任何依赖,无需异步请求,满足对日期的假期检测,判断是否为调休日等。
The npm package festival_chn receives a total of 0 weekly downloads. As such, festival_chn popularity was classified as not popular.
We found that festival_chn demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.