Browse Source

Merge pull request #2 from vsme/dev

rename
Yawei sun 1 year ago
parent
commit
fd0b28b81c
5 changed files with 49 additions and 36 deletions
  1. 23 16
      README.en.md
  2. 20 14
      README.md
  3. 2 2
      package-lock.json
  4. 3 3
      package.json
  5. 1 1
      vite.config.ts

+ 23 - 16
README.en.md

@@ -1,40 +1,46 @@
-# China Days
+# Chinese Days
 
-![NPM Version](https://img.shields.io/npm/v/china-days)
-![GitHub License](https://img.shields.io/github/license/vsme/china-days)
-[![README](https://img.shields.io/badge/README-中文-brightgreen.svg)](https://github.com/vsme/china-days/blob/main/README.md)
+![NPM Version](https://img.shields.io/npm/v/chinese-days)
+![GitHub License](https://img.shields.io/github/license/vsme/chinese-days)
+[![README](https://img.shields.io/badge/README-中文-brightgreen.svg)](https://github.com/vsme/chinese-days/blob/main/README.md)
 
 > Translated by ChatGPT-4, PRs are welcome.
 
 This project provides a set of functions for managing and querying Chinese holidays, adjusted workdays (in lieu days), regular workdays, and the 24 solar terms. By using these functions, users can easily check the status of a specified date, get holidays or workdays within a date range, and find specific workdays. Additionally, the project supports querying the dates of the 24 solar terms, helping users understand the timing of traditional Chinese solar terms.
 
-Supports the years 2004 to 2024, including the extended Spring Festival in 2020.
+Description:
+1. Holidays: Supports from 2004 to 2024, including the extended Spring Festival in 2020.
+2. Lunar Dates: Supports from 1900 to 2100.
 
 ## Quick Start
 
 Include directly in your browser:
 
 ```html
-<script src="https://cdn.jsdelivr.net/npm/china-days/dist/index.min.js"></script>
+<script src="https://cdn.jsdelivr.net/npm/chinese-days/dist/index.min.js"></script>
+<script>
+  const { isHoliday } = chineseDays
+  console.log(isHoliday('2024-01-01'))
+</script>
 ```
 
 Installation:
 
 ```sh
-npm i china-days
+npm i chinese-days
 ```
 
 Using ESM import:
 
 ```ts
-import chinaDays from 'china-days'
-console.log(chinaDays)
+import chineseDays from 'chinese-days'
+console.log(chineseDays)
 ```
 
 Using in Node.js:
 
 ```js
-const { isWorkday, isHoliday } = require('china-days');
+const { isWorkday, isHoliday } = require('chinese-days');
 console.log(isWorkday('2020-01-01'));
 console.log(isHoliday('2020-01-01'));
 ```
@@ -55,7 +61,7 @@ console.log(isHoliday('2023-01-01')); // true
 
 ### `isInLieu` Check if a date is an in lieu day
 
-In China's holiday arrangement, an in lieu day is a workday or a rest day adjusted for consecutive holidays or make-up workdays. For example, if a public holiday is connected to a weekend, a weekend day might be adjusted to a workday, or a workday might be adjusted to a rest day for a longer consecutive holiday.
+On a Chinese holiday arrangement, an in lieu day is a workday or a rest day adjusted for consecutive holidays or make-up workdays. For example, if a public holiday is connected to a weekend, a weekend day might be adjusted to a workday, or a workday might be adjusted to a rest day for a longer consecutive holiday.
 
 ```js
 // Check if 2024-05-02 is an in lieu day. Returns `true` if it is.
@@ -153,7 +159,7 @@ console.log(secondNextWorkday);
 ### Get dates of the 24 solar terms
 
 ```js
-import { getSolarTerms } from "china-days";
+import { getSolarTerms } from "chinese-days";
 
 /** Get an array of solar term dates within a range */
 const solarTerms = getSolarTerms("2024-05-01", "2024-05-20");
@@ -219,10 +225,10 @@ When dealing with a leap month in the lunar calendar, one lunar date may corresp
 
 ```js
 console.log(getSolarDateFromLunar('2001-03-05'))
-// return {date: '2001-03-29', leapMonthDate: undefined}
+// Output: {date: '2001-03-29', leapMonthDate: undefined}
 
 console.log(getSolarDateFromLunar('2001-04-05'))
-// return {date: '2001-04-27', leapMonthDate: '2001-05-27'}
+// Output: {date: '2001-04-27', leapMonthDate: '2001-05-27'}
 ```
 
 ## Contributing
@@ -234,6 +240,7 @@ console.log(getSolarDateFromLunar('2001-04-05'))
 5. Run the command `npm run generate` to automatically generate the [holiday constants file](src/holidays/constants.ts);
 6. Submit a PR.
 
-## Acknowledgments
+## Acknowledgements
 
-This project references the `Python` version of the [LKI/chinese-calendar](https://github.com/LKI/chinese-calendar) open-source project.
+1. Lunar calendar data is sourced from the [Bigkoo/Android-PickerView](https://github.com/Bigkoo/Android-PickerView) project.
+2. Chinese holiday data generation references the `Python` version of the [LKI/chinese-calendar](https://github.com/LKI/chinese-calendar) project.

+ 20 - 14
README.md

@@ -1,38 +1,44 @@
 # 中国节假日
 
-![NPM Version](https://img.shields.io/npm/v/china-days)
-![GitHub License](https://img.shields.io/github/license/vsme/china-days)
-[![README](https://img.shields.io/badge/README-English-brightgreen.svg)](https://github.com/vsme/china-days/blob/main/README.en.md)
+![NPM Version](https://img.shields.io/npm/v/chinese-days)
+![GitHub License](https://img.shields.io/github/license/vsme/chinese-days)
+[![README](https://img.shields.io/badge/README-English-brightgreen.svg)](https://github.com/vsme/chinese-days/blob/main/README.en.md)
 
 本项目提供了一系列用于管理和查询中国节假日、调休日、工作日及二十四节气的函数。通过使用这些函数,用户可以方便地检查指定日期的状态,获取日期范围内的节假日或工作日,并查找特定的工作日。此外,项目还支持查询二十四节气的日期,帮助用户了解中国传统节气的时间安排。
 
-支持 2004年 至 2024年,包括 2020年 的春节延长。
+说明:
+1. 节假日:支持 2004年 至 2024年,包括 2020年 的春节延长。
+2. 农历日:支持 1900年 至 2100年。
 
 ## 快速开始
 
 直接浏览器引入
 
 ```html
-<script src="https://cdn.jsdelivr.net/npm/china-days/dist/index.min.js"></script>
+<script src="https://cdn.jsdelivr.net/npm/chinese-days/dist/index.min.js"></script>
+<script>
+  const { isHoliday } = chineseDays
+  console.log(isHoliday('2024-01-01'))
+</script>
 ```
 
 安装
 
 ```sh
-npm i china-days
+npm i chinese-days
 ```
 
 使用 ESM 导入
 
 ```ts
-import chinaDays from 'china-days'
-console.log(chinaDays)
+import chineseDays from 'chinese-days'
+console.log(chineseDays)
 ```
 
 在 Node 中使用
 
 ```js
-const { isWorkday, isHoliday } = require('china-days');
+const { isWorkday, isHoliday } = require('chinese-days');
 console.log(isWorkday('2020-01-01'));
 console.log(isHoliday('2020-01-01'));
 ```
@@ -153,7 +159,7 @@ console.log(secondNextWorkday);
 ### 获取 24 节气的日期
 
 ```js
-import { getSolarTerms } from "china-days";
+import { getSolarTerms } from "chinese-days";
 
 /** 获取范围内 节气日期数组 */
 const solarTerms = getSolarTerms("2024-05-01", "2024-05-20");
@@ -186,7 +192,6 @@ console.log(getLunarDate('2097-08-07'))
 
 // 2057-9-28
 console.log(getLunarDate('2057-09-28'))
-// 输出:
 // {
 //   date: "2057-09-28",
 //   lunarYear: 2057,
@@ -219,10 +224,10 @@ console.log(getLunarDatesInRange('2001-05-21', '2001-05-26'))
 
 ```js
 console.log(getSolarDateFromLunar('2001-03-05'))
-// return {date: '2001-03-29', leapMonthDate: undefined}
+// {date: '2001-03-29', leapMonthDate: undefined}
 
 console.log(getSolarDateFromLunar('2001-04-05'))
-// return {date: '2001-04-27', leapMonthDate: '2001-05-27'}
+// {date: '2001-04-27', leapMonthDate: '2001-05-27'}
 ```
 
 ## 贡献代码
@@ -236,4 +241,5 @@ console.log(getSolarDateFromLunar('2001-04-05'))
 
 ## 致谢
 
-本项目参考了 `Python` 版本的 [LKI/chinese-calendar](https://github.com/LKI/chinese-calendar) 开源项目。
+1. 农历数据来自于 [Bigkoo/Android-PickerView](https://github.com/Bigkoo/Android-PickerView) 项目。
+2. 中国节假日数据生成参考了 `Python` 版本的 [LKI/chinese-calendar](https://github.com/LKI/chinese-calendar) 项目。

+ 2 - 2
package-lock.json

@@ -1,11 +1,11 @@
 {
-  "name": "china-days",
+  "name": "chinese-days",
   "version": "0.2.0",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
-      "name": "china-days",
+      "name": "chinese-days",
       "version": "0.2.0",
       "license": "MIT",
       "dependencies": {

+ 3 - 3
package.json

@@ -1,5 +1,5 @@
 {
-  "name": "china-days",
+  "name": "chinese-days",
   "version": "0.2.0",
   "description": "中国节假日、调休日、工作日、24节气查询,农历阳历互转,支持 TS、CommonJS、UMD 模块化使用。",
   "main": "dist/index.min.js",
@@ -8,7 +8,7 @@
   "type": "commonjs",
   "repository": {
     "type": "git",
-    "url": "https://github.com/vsme/china-days"
+    "url": "https://github.com/vsme/chinese-days"
   },
   "files": [
     "dist/*",
@@ -37,7 +37,7 @@
   "author": "Yaavi",
   "license": "MIT",
   "bugs": {
-    "url": "https://github.com/vsme/china-days/issues"
+    "url": "https://github.com/vsme/chinese-days/issues"
   },
   "dependencies": {
     "dayjs": "^1.11.11"

+ 1 - 1
vite.config.ts

@@ -8,7 +8,7 @@ export default defineConfig(() => ({
     sourcemap: false,
     lib: {
       entry: "./src/index.ts",
-      name: "chinaDays",
+      name: "ChineseDays",
       formats: ["umd", "es"],
       fileName: (format) => format == 'umd' ? 'index.min.js' : `index.${format}.js`,
     },