diff --git a/CHANGELOG.md b/CHANGELOG.md index 7895b9a..2427ef8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.7.0 + +Support year 2027 offline data. + # v1.6.0 Support year 2024 offline data. diff --git a/README.md b/README.md index ad21e6a..9644e0e 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ ChineseHolidays.ready(options) 支持在线更新[节假日数据](https://github.com/bastengao/chinese-holidays-data),如果无法联网则使用本地打包的数据。 +* [支持 2025 年](https://www.gov.cn/zhengce/content/202411/content_6986382.htm) * [支持 2024 年](https://www.gov.cn/zhengce/content/202310/content_6911527.htm) * [支持 2023 年](http://www.gov.cn/zhengce/content/2022-12/08/content_5730844.htm) * [支持 2022 年](http://www.gov.cn/zhengce/content/2021-10/25/content_5644835.htm) diff --git a/data/2025.json b/data/2025.json new file mode 100644 index 0000000..3bce3b8 --- /dev/null +++ b/data/2025.json @@ -0,0 +1,57 @@ +[ + { + "name": "元旦", + "range": ["2025-01-01"], + "type": "holiday" + }, + { + "name": "春节", + "range": ["2025-01-26"], + "type": "workingday" + }, + { + "name": "春节", + "range": ["2025-01-28", "2025-02-04"], + "type": "holiday" + }, + { + "name": "春节", + "range": ["2025-02-08"], + "type": "workingday" + }, + { + "name": "清明节", + "range": ["2025-04-04", "2025-04-06"], + "type": "holiday" + }, + { + "name": "劳动节", + "range": ["2025-04-27"], + "type": "workingday" + }, + { + "name": "劳动节", + "range": ["2025-05-01", "2025-05-05"], + "type": "holiday" + }, + { + "name": "端午节", + "range": ["2025-05-31", "2025-06-02"], + "type": "holiday" + }, + { + "name": "国庆节、中秋节", + "range": ["2025-09-28"], + "type": "workingday" + }, + { + "name": "国庆节、中秋节", + "range": ["2025-10-01", "2025-10-08"], + "type": "holiday" + }, + { + "name": "国庆节、中秋节", + "range": ["2025-10-11"], + "type": "workingday" + } +] diff --git a/package-lock.json b/package-lock.json index f6394a9..54d2a05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "chinese-holidays", - "version": "1.6.0", + "version": "1.7.0", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index a68f4de..e09328b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chinese-holidays", - "version": "1.6.0", + "version": "1.7.0", "description": "Chinese holidays", "main": "lib/index.js", "files": [ diff --git a/src/cache.js b/src/cache.js index 448bb3b..d014824 100644 --- a/src/cache.js +++ b/src/cache.js @@ -10,6 +10,8 @@ const DataEndpoint = 'http://chinese-holidays-data.basten.me/data'; const IndexUrl = `${DataEndpoint}/index.json`; const CacheDir = path.resolve(__dirname, '../cache'); const NewCacheDir = path.resolve(__dirname, '../cache_temp'); +const version = '1.7.0'; +const userAgent = `chinese-holidays-node/${version}`; // TODO: checkUpdateInterval 检查更新周期 @@ -38,7 +40,13 @@ const Cache = { console.log(`loading data from ${IndexUrl}`); } - request(IndexUrl, (error, response, body) => { + const options = { + url: IndexUrl, + headers: { + 'User-Agent': userAgent, + }, + }; + request(options, (error, response, body) => { if (error) { if (self.verbose) { console.log(`load failed: ${error}`); @@ -86,7 +94,12 @@ const Cache = { if (self.verbose) { console.log(`loading data from ${url}`); } - const p = rq({ uri: url }); + const p = rq({ + uri: url, + headers: { + 'User-Agent': userAgent, + }, + }); p.then((body) => { const filename = `${NewCacheDir}/${entry.year}.json`;