Yaavi 1 year ago
parent
commit
bb73694d7b

+ 5 - 0
CHANGELOG.md

@@ -1,5 +1,10 @@
 # CHANGELOG
 # CHANGELOG
 
 
+## [1.2.1](https://github.com/vsme/chinese-days) (2024-05-23)
+
+- 优化代码
+- 将导出内容作为命名导出
+
 ## [1.2.0](https://github.com/vsme/chinese-days) (2024-05-23)
 ## [1.2.0](https://github.com/vsme/chinese-days) (2024-05-23)
 
 
 ### 特性
 ### 特性

+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
 {
   "name": "chinese-days",
   "name": "chinese-days",
-  "version": "1.2.0",
+  "version": "1.2.1",
   "lockfileVersion": 3,
   "lockfileVersion": 3,
   "requires": true,
   "requires": true,
   "packages": {
   "packages": {
     "": {
     "": {
       "name": "chinese-days",
       "name": "chinese-days",
-      "version": "1.2.0",
+      "version": "1.2.1",
       "license": "MIT",
       "license": "MIT",
       "devDependencies": {
       "devDependencies": {
         "@types/jest": "^29.5.12",
         "@types/jest": "^29.5.12",

+ 3 - 2
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "chinese-days",
   "name": "chinese-days",
-  "version": "1.2.0",
+  "version": "1.2.1",
   "description": "中国节假日、调休日、工作日、24节气查询,农历阳历互转,支持 TS、CommonJS、UMD 模块化使用。",
   "description": "中国节假日、调休日、工作日、24节气查询,农历阳历互转,支持 TS、CommonJS、UMD 模块化使用。",
   "main": "dist/index.min.js",
   "main": "dist/index.min.js",
   "module": "dist/index.es.js",
   "module": "dist/index.es.js",
@@ -15,7 +15,8 @@
     "src/*",
     "src/*",
     "LICENSE",
     "LICENSE",
     "package.json",
     "package.json",
-    "README.md"
+    "README.md",
+    "README.en.md"
   ],
   ],
   "scripts": {
   "scripts": {
     "dev": "vite",
     "dev": "vite",

+ 25 - 13
src/holidays/arrangement.ts

@@ -33,7 +33,8 @@ class Arrangement {
   public workdays: Record<string, Holiday> = {};
   public workdays: Record<string, Holiday> = {};
   public inLieuDays: Record<string, Holiday> = {};
   public inLieuDays: Record<string, Holiday> = {};
 
 
-  yearAt(year: number) {
+  /** year at */
+  y(year: number) {
     this.dayDetails.year = year;
     this.dayDetails.year = year;
     return this;
     return this;
   }
   }
@@ -96,39 +97,50 @@ class Arrangement {
     return this;
     return this;
   }
   }
 
 
-  work(month: number, day: number) {
+  /** work day */
+  w(month: number, day: number) {
     return this.save(month, day, DayType.Workday);
     return this.save(month, day, DayType.Workday);
   }
   }
-  rest(month: number, day: number) {
+  /** rest */
+  r(month: number, day: number) {
     return this.save(month, day, DayType.Holiday);
     return this.save(month, day, DayType.Holiday);
   }
   }
-  inLieu(month: number, day: number) {
+  /** in-lieu */
+  i(month: number, day: number) {
     return this.save(month, day, DayType.InLieu);
     return this.save(month, day, DayType.InLieu);
   }
   }
 
 
-  // Special holiday marker
-  nyd() {
+  /** New Year's Day 元旦 */
+  ny() {
     return this.mark(Holiday.NY);
     return this.mark(Holiday.NY);
   }
   }
-  sf() {
+  /** Spring Festival 春节 */
+  s() {
     return this.mark(Holiday.S);
     return this.mark(Holiday.S);
   }
   }
-  tsd() {
+  /** Tomb-sweeping Day 清明 */
+  t() {
     return this.mark(Holiday.T);
     return this.mark(Holiday.T);
   }
   }
-  ld() {
+  
+  /** Labour Day 五一 */
+  l() {
     return this.mark(Holiday.L);
     return this.mark(Holiday.L);
   }
   }
-  dbf() {
+  /** Dragon Boat Festival 端午 */
+  d() {
     return this.mark(Holiday.D);
     return this.mark(Holiday.D);
   }
   }
-  nd() {
+  /** National Day 国庆节 */
+  n() {
     return this.mark(Holiday.N);
     return this.mark(Holiday.N);
   }
   }
-  maf() {
+  /** Mid-autumn Festival 中秋 */
+  m() {
     return this.mark(Holiday.M);
     return this.mark(Holiday.M);
   }
   }
-  afd() {
+  /** Anti-Fascist 70th Day 中国人民抗日战争暨世界反法西斯战争胜利70周年纪念日 */
+  a() {
     return this.mark(Holiday.A);
     return this.mark(Holiday.A);
   }
   }
 }
 }

+ 161 - 161
src/holidays/generate.ts

@@ -13,14 +13,14 @@ export default () => {
    * 六、中秋节:9月15日至17日放假调休,共3天。9月14日(星期六)上班。
    * 六、中秋节:9月15日至17日放假调休,共3天。9月14日(星期六)上班。
    * 七、国庆节:10月1日至7日放假调休,共7天。9月29日(星期日)、10月12日(星期六)上班。
    * 七、国庆节:10月1日至7日放假调休,共7天。9月29日(星期日)、10月12日(星期六)上班。
    */
    */
-  arrangement.yearAt(2024)
-    .nyd().rest(1, 1)
-    .sf().rest(2, 10).to(2, 17).work(2, 4).work(2, 18).inLieu(2, 15).to(2, 16)
-    .tsd().rest(4, 4).to(4, 6).work(4, 7).inLieu(4, 5)
-    .ld().rest(5, 1).to(5, 5).work(4, 28).work(5, 11).inLieu(5, 2).to(5, 3)
-    .dbf().rest(6, 10)
-    .maf().rest(9, 15).to(9, 17).work(9, 14).inLieu(9, 16)
-    .nd().rest(10, 1).to(10, 7).work(9, 29).work(10, 12).inLieu(10, 4).inLieu(10, 7)
+  arrangement.y(2024)
+    .ny().r(1, 1)
+    .s().r(2, 10).to(2, 17).w(2, 4).w(2, 18).i(2, 15).to(2, 16)
+    .t().r(4, 4).to(4, 6).w(4, 7).i(4, 5)
+    .l().r(5, 1).to(5, 5).w(4, 28).w(5, 11).i(5, 2).to(5, 3)
+    .d().r(6, 10)
+    .m().r(9, 15).to(9, 17).w(9, 14).i(9, 16)
+    .n().r(10, 1).to(10, 7).w(9, 29).w(10, 12).i(10, 4).i(10, 7)
   
   
   /**
   /**
   * 2023
   * 2023
@@ -32,14 +32,14 @@ export default () => {
   * 五、端午节:6月22日至24日放假调休,共3天。6月25日(星期日)上班。
   * 五、端午节:6月22日至24日放假调休,共3天。6月25日(星期日)上班。
   * 六、中秋节、国庆节:9月29日至10月6日放假调休,共8天。10月7日(星期六)、10月8日(星期日)上班。
   * 六、中秋节、国庆节:9月29日至10月6日放假调休,共8天。10月7日(星期六)、10月8日(星期日)上班。
   */
   */
-  arrangement.yearAt(2023)
-    .nyd().rest(1, 1).to(1, 2)
-    .sf().rest(1, 21).to(1, 27).work(1, 28).to(1, 29).inLieu(1, 26).to(1, 27)
-    .tsd().rest(4, 5)
-    .ld().rest(4, 29).to(5, 3).work(4, 23).work(5, 6).inLieu(5, 2).to(5, 3)
-    .dbf().rest(6, 22).to(6, 24).work(6, 25).inLieu(6, 23)
-    .maf().rest(9, 29)
-    .nd().rest(9, 30).to(10, 6).work(10, 7).to(10, 8).inLieu(10, 5).to(10, 6)
+  arrangement.y(2023)
+    .ny().r(1, 1).to(1, 2)
+    .s().r(1, 21).to(1, 27).w(1, 28).to(1, 29).i(1, 26).to(1, 27)
+    .t().r(4, 5)
+    .l().r(4, 29).to(5, 3).w(4, 23).w(5, 6).i(5, 2).to(5, 3)
+    .d().r(6, 22).to(6, 24).w(6, 25).i(6, 23)
+    .m().r(9, 29)
+    .n().r(9, 30).to(10, 6).w(10, 7).to(10, 8).i(10, 5).to(10, 6)
   
   
   /**
   /**
   * 2022
   * 2022
@@ -52,15 +52,15 @@ export default () => {
   * 六、中秋节:9月10日至12日放假,共3天。
   * 六、中秋节:9月10日至12日放假,共3天。
   * 七、国庆节:10月1日至7日放假调休,共7天。10月8日(星期六)、10月9日(星期日)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。10月8日(星期六)、10月9日(星期日)上班。
   */
   */
-  arrangement.yearAt(2022)
-    .nyd().rest(1, 1).to(1, 3)
-    .sf().rest(1, 31).to(2, 6).work(1, 29).work(1, 30).inLieu(2, 3).to(2, 4)
-    .tsd().rest(4, 3).to(4, 5).work(4, 2).inLieu(4, 4)
-    .ld().rest(4, 30).to(5, 4).work(4, 24).work(5, 7).inLieu(5, 3).to(5, 4)
-    .dbf().rest(6, 3).to(6, 5)
-    .maf().rest(9, 10).to(9, 12)
-    .nd().rest(10, 1).to(10, 7).work(10, 8).work(10, 9).inLieu(10, 6).to(10, 7)
-    .nyd().rest(12, 31)
+  arrangement.y(2022)
+    .ny().r(1, 1).to(1, 3)
+    .s().r(1, 31).to(2, 6).w(1, 29).w(1, 30).i(2, 3).to(2, 4)
+    .t().r(4, 3).to(4, 5).w(4, 2).i(4, 4)
+    .l().r(4, 30).to(5, 4).w(4, 24).w(5, 7).i(5, 3).to(5, 4)
+    .d().r(6, 3).to(6, 5)
+    .m().r(9, 10).to(9, 12)
+    .n().r(10, 1).to(10, 7).w(10, 8).w(10, 9).i(10, 6).to(10, 7)
+    .ny().r(12, 31)
   
   
   /**
   /**
   * 2021
   * 2021
@@ -73,14 +73,14 @@ export default () => {
   * 六、中秋节:9月19日至21日放假调休,共3天。9月18日(星期六)上班。
   * 六、中秋节:9月19日至21日放假调休,共3天。9月18日(星期六)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。9月26日(星期日)、10月9日(星期六)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。9月26日(星期日)、10月9日(星期六)上班。
   */
   */
-  arrangement.yearAt(2021)
-    .nyd().rest(1, 1).to(1, 3)
-    .sf().rest(2, 11).to(2, 17).work(2, 7).work(2, 20).inLieu(2, 16).to(2, 17)
-    .tsd().rest(4, 3).to(4, 5)
-    .ld().rest(5, 1).to(5, 5).work(4, 25).work(5, 8).inLieu(5, 4).to(5, 5)
-    .dbf().rest(6, 12).to(6, 14)
-    .maf().rest(9, 19).to(9, 21).work(9, 18).inLieu(9, 20)
-    .nd().rest(10, 1).to(10, 7).work(9, 26).work(10, 9).inLieu(10, 6).to(10, 7)
+  arrangement.y(2021)
+    .ny().r(1, 1).to(1, 3)
+    .s().r(2, 11).to(2, 17).w(2, 7).w(2, 20).i(2, 16).to(2, 17)
+    .t().r(4, 3).to(4, 5)
+    .l().r(5, 1).to(5, 5).w(4, 25).w(5, 8).i(5, 4).to(5, 5)
+    .d().r(6, 12).to(6, 14)
+    .m().r(9, 19).to(9, 21).w(9, 18).i(9, 20)
+    .n().r(10, 1).to(10, 7).w(9, 26).w(10, 9).i(10, 6).to(10, 7)
   
   
   /**
   /**
   * 2020
   * 2020
@@ -95,13 +95,13 @@ export default () => {
   * http://www.gov.cn/zhengce/content/2020-01/27/content_5472352.htm
   * http://www.gov.cn/zhengce/content/2020-01/27/content_5472352.htm
   * 延长2020年春节假期至2月2日(农历正月初九,星期日),2月3日(星期一)起正常上班。
   * 延长2020年春节假期至2月2日(农历正月初九,星期日),2月3日(星期一)起正常上班。
   */
   */
-  arrangement.yearAt(2020)
-    .nyd().rest(1, 1)
-    .sf().rest(1, 24).to(2, 2).work(1, 19).inLieu(1, 29)
-    .tsd().rest(4, 4).to(4, 6)
-    .ld().rest(5, 1).to(5, 5).work(4, 26).work(5, 9).inLieu(5, 4).to(5, 5)
-    .dbf().rest(6, 25).to(6, 27).work(6, 28).inLieu(6, 26)
-    .nd().rest(10, 1).to(10, 8).work(9, 27).work(10, 10).inLieu(10, 7).to(10, 8)
+  arrangement.y(2020)
+    .ny().r(1, 1)
+    .s().r(1, 24).to(2, 2).w(1, 19).i(1, 29)
+    .t().r(4, 4).to(4, 6)
+    .l().r(5, 1).to(5, 5).w(4, 26).w(5, 9).i(5, 4).to(5, 5)
+    .d().r(6, 25).to(6, 27).w(6, 28).i(6, 26)
+    .n().r(10, 1).to(10, 8).w(9, 27).w(10, 10).i(10, 7).to(10, 8)
   
   
   /**
   /**
   * 2019
   * 2019
@@ -117,14 +117,14 @@ export default () => {
   * 经国务院批准,现将调整2019年劳动节放假安排通知如下。
   * 经国务院批准,现将调整2019年劳动节放假安排通知如下。
   * 2019年5月1日至4日放假调休,共4天。4月28日(星期日)、5月5日(星期日)上班。
   * 2019年5月1日至4日放假调休,共4天。4月28日(星期日)、5月5日(星期日)上班。
   */
   */
-  arrangement.yearAt(2019)
-    .nyd().rest(1, 1)
-    .sf().rest(2, 4).to(2, 10).work(2, 2).to(2, 3).inLieu(2, 4).inLieu(2, 8)
-    .tsd().rest(4, 5).to(4, 7)
-    .ld().rest(5, 1).to(5, 4).work(4, 28).work(5, 5).inLieu(5, 2).inLieu(5, 3)
-    .dbf().rest(6, 7).to(6, 9)
-    .maf().rest(9, 13).to(9, 15)
-    .nd().rest(10, 1).to(10, 7).work(9, 29).work(10, 12).inLieu(10, 4).inLieu(10, 7)
+  arrangement.y(2019)
+    .ny().r(1, 1)
+    .s().r(2, 4).to(2, 10).w(2, 2).to(2, 3).i(2, 4).i(2, 8)
+    .t().r(4, 5).to(4, 7)
+    .l().r(5, 1).to(5, 4).w(4, 28).w(5, 5).i(5, 2).i(5, 3)
+    .d().r(6, 7).to(6, 9)
+    .m().r(9, 13).to(9, 15)
+    .n().r(10, 1).to(10, 7).w(9, 29).w(10, 12).i(10, 4).i(10, 7)
   
   
   /**
   /**
   * 2018
   * 2018
@@ -137,15 +137,15 @@ export default () => {
   * 六、中秋节:9月24日放假,与周末连休。
   * 六、中秋节:9月24日放假,与周末连休。
   * 七、国庆节:10月1日至7日放假调休,共7天。9月29日(星期六)、9月30日(星期日)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。9月29日(星期六)、9月30日(星期日)上班。
   */
   */
-  arrangement.yearAt(2018)
-    .nyd().rest(1, 1)
-    .sf().rest(2, 15).to(2, 21).work(2, 11).work(2, 24).inLieu(2, 19).to(2, 21)
-    .tsd().rest(4, 5).to(4, 7).work(4, 8).inLieu(4, 6)
-    .ld().rest(4, 29).to(5, 1).work(4, 28).inLieu(4, 30)
-    .dbf().rest(6, 18)
-    .nd().rest(10, 1).to(10, 7).work(9, 29).to(9, 30).inLieu(10, 4).to(10, 5)
-    .maf().rest(9, 24)
-    .nyd().rest(12, 30).to(12, 31).work(12, 29).inLieu(12, 31)
+  arrangement.y(2018)
+    .ny().r(1, 1)
+    .s().r(2, 15).to(2, 21).w(2, 11).w(2, 24).i(2, 19).to(2, 21)
+    .t().r(4, 5).to(4, 7).w(4, 8).i(4, 6)
+    .l().r(4, 29).to(5, 1).w(4, 28).i(4, 30)
+    .d().r(6, 18)
+    .n().r(10, 1).to(10, 7).w(9, 29).to(9, 30).i(10, 4).to(10, 5)
+    .m().r(9, 24)
+    .ny().r(12, 30).to(12, 31).w(12, 29).i(12, 31)
   
   
   /**
   /**
   * 2017
   * 2017
@@ -157,14 +157,14 @@ export default () => {
   * 五、端午节:5月28日至30日放假调休,共3天。5月27日(星期六)上班。
   * 五、端午节:5月28日至30日放假调休,共3天。5月27日(星期六)上班。
   * 六、中秋节、国庆节:10月1日至8日放假调休,共8天。9月30日(星期六)上班。
   * 六、中秋节、国庆节:10月1日至8日放假调休,共8天。9月30日(星期六)上班。
   */
   */
-  arrangement.yearAt(2017)
-    .nyd().rest(1, 1).to(1, 2)
-    .sf().rest(1, 27).to(2, 2).work(1, 22).work(2, 4).inLieu(2, 1).to(2, 2)
-    .tsd().rest(4, 2).to(4, 4).work(4, 1).inLieu(4, 3)
-    .ld().rest(5, 1)
-    .dbf().rest(5, 28).to(5, 30).work(5, 27).inLieu(5, 29)
-    .nd().rest(10, 1).to(10, 8).work(9, 30).inLieu(10, 6)
-    .maf().rest(10, 4)  // 国庆中秋相连,经查证10月4日为中秋
+  arrangement.y(2017)
+    .ny().r(1, 1).to(1, 2)
+    .s().r(1, 27).to(2, 2).w(1, 22).w(2, 4).i(2, 1).to(2, 2)
+    .t().r(4, 2).to(4, 4).w(4, 1).i(4, 3)
+    .l().r(5, 1)
+    .d().r(5, 28).to(5, 30).w(5, 27).i(5, 29)
+    .n().r(10, 1).to(10, 8).w(9, 30).i(10, 6)
+    .m().r(10, 4)  // 国庆中秋相连,经查证10月4日为中秋
   
   
   /**
   /**
   * 2016
   * 2016
@@ -177,14 +177,14 @@ export default () => {
   * 六、中秋节:9月15日至17日放假调休,共3天。9月18日(星期日)上班。
   * 六、中秋节:9月15日至17日放假调休,共3天。9月18日(星期日)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。10月8日(星期六)、10月9日(星期日)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。10月8日(星期六)、10月9日(星期日)上班。
   */
   */
-  arrangement.yearAt(2016)
-    .nyd().rest(1, 1)
-    .sf().rest(2, 7).to(2, 13).work(2, 6).work(2, 14).inLieu(2, 11).to(2, 12)
-    .tsd().rest(4, 4)
-    .ld().rest(5, 1).to(5, 2)
-    .dbf().rest(6, 9).to(6, 11).work(6, 12).inLieu(6, 10)
-    .maf().rest(9, 15).to(9, 17).work(9, 18).inLieu(9, 16)
-    .nd().rest(10, 1).to(10, 7).work(10, 8).to(10, 9).inLieu(10, 6).to(10, 7)
+  arrangement.y(2016)
+    .ny().r(1, 1)
+    .s().r(2, 7).to(2, 13).w(2, 6).w(2, 14).i(2, 11).to(2, 12)
+    .t().r(4, 4)
+    .l().r(5, 1).to(5, 2)
+    .d().r(6, 9).to(6, 11).w(6, 12).i(6, 10)
+    .m().r(9, 15).to(9, 17).w(9, 18).i(9, 16)
+    .n().r(10, 1).to(10, 7).w(10, 8).to(10, 9).i(10, 6).to(10, 7)
   
   
   /**
   /**
   * 2015
   * 2015
@@ -202,15 +202,15 @@ export default () => {
   *   额外的放假安排如下:
   *   额外的放假安排如下:
   *   9月3日至5日调休放假,共3天。其中9月3日(星期四)放假,9月4日(星期五)调休,9月6日(星期日)上班。
   *   9月3日至5日调休放假,共3天。其中9月3日(星期四)放假,9月4日(星期五)调休,9月6日(星期日)上班。
   */
   */
-  arrangement.yearAt(2015)
-    .nyd().rest(1, 1).to(1, 3).work(1, 4).inLieu(1, 2)
-    .sf().rest(2, 18).to(2, 24).work(2, 15).work(2, 28).inLieu(2, 23).to(2, 24)
-    .tsd().rest(4, 5).to(4, 6)
-    .ld().rest(5, 1)
-    .dbf().rest(6, 20).rest(6, 22)
-    .maf().rest(9, 27)
-    .nd().rest(10, 1).to(10, 7).work(10, 10).inLieu(10, 7)
-    .afd().rest(9, 3).to(9, 4).work(9, 6).inLieu(9, 4)
+  arrangement.y(2015)
+    .ny().r(1, 1).to(1, 3).w(1, 4).i(1, 2)
+    .s().r(2, 18).to(2, 24).w(2, 15).w(2, 28).i(2, 23).to(2, 24)
+    .t().r(4, 5).to(4, 6)
+    .l().r(5, 1)
+    .d().r(6, 20).r(6, 22)
+    .m().r(9, 27)
+    .n().r(10, 1).to(10, 7).w(10, 10).i(10, 7)
+    .a().r(9, 3).to(9, 4).w(9, 6).i(9, 4)
   
   
   /**
   /**
   * 2014
   * 2014
@@ -223,14 +223,14 @@ export default () => {
   * 六、中秋节:9月8日放假,与周末连休。
   * 六、中秋节:9月8日放假,与周末连休。
   * 七、国庆节:10月1日至7日放假调休,共7天。9月28日(星期日)、10月11日(星期六)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。9月28日(星期日)、10月11日(星期六)上班。
   */
   */
-  arrangement.yearAt(2014)
-    .nyd().rest(1, 1)
-    .sf().rest(1, 31).to(2, 6).work(1, 26).work(2, 8).inLieu(2, 5).to(2, 6)
-    .tsd().rest(4, 5).to(4, 7)
-    .ld().rest(5, 1).to(5, 3).work(5, 4).inLieu(5, 2)
-    .dbf().rest(6, 2)
-    .maf().rest(9, 8)
-    .nd().rest(10, 1).to(10, 7).work(9, 28).work(10, 11).inLieu(10, 6).to(10, 7)
+  arrangement.y(2014)
+    .ny().r(1, 1)
+    .s().r(1, 31).to(2, 6).w(1, 26).w(2, 8).i(2, 5).to(2, 6)
+    .t().r(4, 5).to(4, 7)
+    .l().r(5, 1).to(5, 3).w(5, 4).i(5, 2)
+    .d().r(6, 2)
+    .m().r(9, 8)
+    .n().r(10, 1).to(10, 7).w(9, 28).w(10, 11).i(10, 6).to(10, 7)
   
   
   /**
   /**
   * 2013
   * 2013
@@ -243,14 +243,14 @@ export default () => {
   * 六、中秋节:9月19日至21日放假调休,共3天。9月22日(星期日)上班。
   * 六、中秋节:9月19日至21日放假调休,共3天。9月22日(星期日)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。9月29日(星期日)、10月12日(星期六)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。9月29日(星期日)、10月12日(星期六)上班。
   */
   */
-  arrangement.yearAt(2013)
-    .nyd().rest(1, 1).to(1, 3).work(1, 5).to(1, 6).inLieu(1, 2).to(1, 3)
-    .sf().rest(2, 9).to(2, 15).work(2, 16).to(2, 17).inLieu(2, 14).to(2, 15)
-    .tsd().rest(4, 4).to(4, 6).work(4, 7).inLieu(4, 5)
-    .ld().rest(4, 29).to(5, 1).work(4, 27).to(4, 28).inLieu(4, 29).to(4, 30)
-    .dbf().rest(6, 10).to(6, 12).work(6, 8).to(6, 9).inLieu(6, 10).to(6, 11)
-    .maf().rest(9, 19).to(9, 21).work(9, 22).inLieu(9, 20)
-    .nd().rest(10, 1).to(10, 7).work(9, 29).work(10, 12).inLieu(10, 4).inLieu(10, 7)
+  arrangement.y(2013)
+    .ny().r(1, 1).to(1, 3).w(1, 5).to(1, 6).i(1, 2).to(1, 3)
+    .s().r(2, 9).to(2, 15).w(2, 16).to(2, 17).i(2, 14).to(2, 15)
+    .t().r(4, 4).to(4, 6).w(4, 7).i(4, 5)
+    .l().r(4, 29).to(5, 1).w(4, 27).to(4, 28).i(4, 29).to(4, 30)
+    .d().r(6, 10).to(6, 12).w(6, 8).to(6, 9).i(6, 10).to(6, 11)
+    .m().r(9, 19).to(9, 21).w(9, 22).i(9, 20)
+    .n().r(10, 1).to(10, 7).w(9, 29).w(10, 12).i(10, 4).i(10, 7)
   
   
   /**
   /**
   * 2012
   * 2012
@@ -264,14 +264,14 @@ export default () => {
   * 
   * 
   *   注意:今年元旦特殊处理,去年上班 Σ( ° △ °|||)︴
   *   注意:今年元旦特殊处理,去年上班 Σ( ° △ °|||)︴
   */
   */
-  arrangement.yearAt(2012)
-    .nyd().rest(1, 1).to(1, 3).inLieu(1, 3)
-    .sf().rest(1, 22).to(1, 28).work(1, 21).work(1, 29).inLieu(1, 26).to(1, 27)
-    .tsd().rest(4, 2).to(4, 4).work(3, 31).work(4, 1).inLieu(4, 2).to(4, 3)
-    .ld().rest(4, 29).to(5, 1).work(4, 28).inLieu(4, 30)
-    .dbf().rest(6, 22).rest(6, 24)
-    .maf().rest(9, 30)
-    .nd().rest(10, 1).to(10, 7).work(9, 29).inLieu(10, 5)
+  arrangement.y(2012)
+    .ny().r(1, 1).to(1, 3).i(1, 3)
+    .s().r(1, 22).to(1, 28).w(1, 21).w(1, 29).i(1, 26).to(1, 27)
+    .t().r(4, 2).to(4, 4).w(3, 31).w(4, 1).i(4, 2).to(4, 3)
+    .l().r(4, 29).to(5, 1).w(4, 28).i(4, 30)
+    .d().r(6, 22).r(6, 24)
+    .m().r(9, 30)
+    .n().r(10, 1).to(10, 7).w(9, 29).i(10, 5)
   
   
   /**
   /**
   * 2011
   * 2011
@@ -286,15 +286,15 @@ export default () => {
   * 
   * 
   *  注意:明年元旦特殊处理,放到今年上班了 Σ( ° △ °|||)︴
   *  注意:明年元旦特殊处理,放到今年上班了 Σ( ° △ °|||)︴
   */
   */
-  arrangement.yearAt(2011)
-    .nyd().rest(1, 1).to(1, 3)
-    .sf().rest(2, 2).to(2, 8).work(1, 30).work(2, 12).inLieu(2, 7).to(2, 8)
-    .tsd().rest(4, 3).to(4, 5).work(4, 2).inLieu(4, 4)
-    .ld().rest(4, 30).to(5, 2)
-    .dbf().rest(6, 4).rest(6, 6)
-    .maf().rest(9, 10).to(9, 12)
-    .nd().rest(10, 1).to(10, 7).work(10, 8).to(10, 9).inLieu(10, 6).to(10, 7)
-    .nyd().work(12, 31)
+  arrangement.y(2011)
+    .ny().r(1, 1).to(1, 3)
+    .s().r(2, 2).to(2, 8).w(1, 30).w(2, 12).i(2, 7).to(2, 8)
+    .t().r(4, 3).to(4, 5).w(4, 2).i(4, 4)
+    .l().r(4, 30).to(5, 2)
+    .d().r(6, 4).r(6, 6)
+    .m().r(9, 10).to(9, 12)
+    .n().r(10, 1).to(10, 7).w(10, 8).to(10, 9).i(10, 6).to(10, 7)
+    .ny().w(12, 31)
   
   
   /**
   /**
   * 2010
   * 2010
@@ -307,14 +307,14 @@ export default () => {
   * 六、中秋节:9月22日至24日放假调休,共3天。9月19日(星期日)、25日(星期六)上班。
   * 六、中秋节:9月22日至24日放假调休,共3天。9月19日(星期日)、25日(星期六)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。9月26日(星期日)、10月9日(星期六)上班。
   * 七、国庆节:10月1日至7日放假调休,共7天。9月26日(星期日)、10月9日(星期六)上班。
   */
   */
-  arrangement.yearAt(2010)
-    .nyd().rest(1, 1).to(1, 3)
-    .sf().rest(2, 13).to(2, 19).work(2, 20).to(2, 21).inLieu(2, 18).to(2, 19)
-    .tsd().rest(4, 3).to(4, 5)
-    .ld().rest(5, 1).to(5, 3)
-    .dbf().rest(6, 14).to(6, 16).work(6, 12).to(6, 13).inLieu(6, 14).to(6, 15)
-    .maf().rest(9, 22).to(9, 24).work(9, 19).work(9, 25).inLieu(9, 23).to(9, 24)
-    .nd().rest(10, 1).to(10, 7).work(9, 26).work(10, 9).inLieu(10, 6).to(10, 7)
+  arrangement.y(2010)
+    .ny().r(1, 1).to(1, 3)
+    .s().r(2, 13).to(2, 19).w(2, 20).to(2, 21).i(2, 18).to(2, 19)
+    .t().r(4, 3).to(4, 5)
+    .l().r(5, 1).to(5, 3)
+    .d().r(6, 14).to(6, 16).w(6, 12).to(6, 13).i(6, 14).to(6, 15)
+    .m().r(9, 22).to(9, 24).w(9, 19).w(9, 25).i(9, 23).to(9, 24)
+    .n().r(10, 1).to(10, 7).w(9, 26).w(10, 9).i(10, 6).to(10, 7)
   
   
   /**
   /**
   * 2009
   * 2009
@@ -340,14 +340,14 @@ export default () => {
   * 月10日(星期六)公休日调至10月7日(星期三)、10月8日(星期四)。
   * 月10日(星期六)公休日调至10月7日(星期三)、10月8日(星期四)。
   * 9月27日(星期日)、10月10日(星期六)上班。
   * 9月27日(星期日)、10月10日(星期六)上班。
   */
   */
-  arrangement.yearAt(2009)
-    .nyd().rest(1, 1).to(1, 3).work(1, 4).inLieu(1, 2)
-    .sf().rest(1, 25).to(1, 31).work(1, 24).work(2, 1).inLieu(1, 29).to(1, 30)
-    .tsd().rest(4, 4).to(4, 6)
-    .ld().rest(5, 1).to(5, 3)
-    .dbf().rest(5, 28).to(5, 30).work(5, 31).inLieu(5, 29)
-    .nd().rest(10, 1).to(10, 8).work(9, 27).work(10, 10).inLieu(10, 7).to(10, 8)
-    .maf().rest(10, 3)  // 国庆中秋相连,经查证10月3日为中秋
+  arrangement.y(2009)
+    .ny().r(1, 1).to(1, 3).w(1, 4).i(1, 2)
+    .s().r(1, 25).to(1, 31).w(1, 24).w(2, 1).i(1, 29).to(1, 30)
+    .t().r(4, 4).to(4, 6)
+    .l().r(5, 1).to(5, 3)
+    .d().r(5, 28).to(5, 30).w(5, 31).i(5, 29)
+    .n().r(10, 1).to(10, 8).w(9, 27).w(10, 10).i(10, 7).to(10, 8)
+    .m().r(10, 3)  // 国庆中秋相连,经查证10月3日为中秋
   
   
   /**
   /**
   * 2008
   * 2008
@@ -370,14 +370,14 @@ export default () => {
   * 
   * 
   *   注意:今年元旦假期,去年年尾要上班。
   *   注意:今年元旦假期,去年年尾要上班。
   */
   */
-  arrangement.yearAt(2008)
-    .nyd().rest(1, 1)
-    .sf().rest(2, 6).to(2, 12).work(2, 2).to(2, 3).inLieu(2, 11).to(2, 12)
-    .tsd().rest(4, 4).to(4, 6)
-    .ld().rest(5, 1).to(5, 3).work(5, 4).inLieu(5, 2)
-    .dbf().rest(6, 7).to(6, 9)
-    .maf().rest(9, 13).to(9, 15)
-    .nd().rest(9, 29).to(10, 5).work(9, 27).to(9, 28).inLieu(9, 29).to(9, 30)
+  arrangement.y(2008)
+    .ny().r(1, 1)
+    .s().r(2, 6).to(2, 12).w(2, 2).to(2, 3).i(2, 11).to(2, 12)
+    .t().r(4, 4).to(4, 6)
+    .l().r(5, 1).to(5, 3).w(5, 4).i(5, 2)
+    .d().r(6, 7).to(6, 9)
+    .m().r(9, 13).to(9, 15)
+    .n().r(9, 29).to(10, 5).w(9, 27).to(9, 28).i(9, 29).to(9, 30)
   
   
   /**
   /**
   * 2007
   * 2007
@@ -393,12 +393,12 @@ export default () => {
   * 
   * 
   *   注意:明年元旦假期,今年年尾会放假。今年元旦假期,去年年尾要上班。
   *   注意:明年元旦假期,今年年尾会放假。今年元旦假期,去年年尾要上班。
   */
   */
-  arrangement.yearAt(2007)
-    .nyd().rest(1, 1).to(1, 3).inLieu(1, 2).to(1, 3)
-    .sf().rest(2, 18).to(2, 24).work(2, 17).work(2, 25).inLieu(2, 22).to(2, 23)
-    .ld().rest(5, 1).to(5, 7).work(4, 28).to(4, 29).inLieu(5, 4).inLieu(5, 7)
-    .nd().rest(10, 1).to(10, 7).work(9, 29).to(9, 30).inLieu(10, 4).to(10, 5)
-    .nyd().rest(12, 30).to(12, 31).work(12, 29).inLieu(12, 31)
+  arrangement.y(2007)
+    .ny().r(1, 1).to(1, 3).i(1, 2).to(1, 3)
+    .s().r(2, 18).to(2, 24).w(2, 17).w(2, 25).i(2, 22).to(2, 23)
+    .l().r(5, 1).to(5, 7).w(4, 28).to(4, 29).i(5, 4).i(5, 7)
+    .n().r(10, 1).to(10, 7).w(9, 29).to(9, 30).i(10, 4).to(10, 5)
+    .ny().r(12, 30).to(12, 31).w(12, 29).i(12, 31)
   
   
   /**
   /**
   * 2006
   * 2006
@@ -414,12 +414,12 @@ export default () => {
   * 
   * 
   *   注意:明年元旦假期,今年年尾要上班。今年元旦假期,去年年尾要上班。
   *   注意:明年元旦假期,今年年尾要上班。今年元旦假期,去年年尾要上班。
   */
   */
-  arrangement.yearAt(2006)
-    .nyd().rest(1, 1).to(1, 3)
-    .sf().rest(1, 29).to(2, 4).work(1, 28).work(2, 5).inLieu(2, 2).to(2, 3)
-    .ld().rest(5, 1).to(5, 7).work(4, 29).to(4, 30).inLieu(5, 4).to(5, 5)
-    .nd().rest(10, 1).to(10, 7).work(9, 30).work(10, 8).inLieu(10, 5).to(10, 6)
-    .nyd().work(12, 30).to(12, 31)
+  arrangement.y(2006)
+    .ny().r(1, 1).to(1, 3)
+    .s().r(1, 29).to(2, 4).w(1, 28).w(2, 5).i(2, 2).to(2, 3)
+    .l().r(5, 1).to(5, 7).w(4, 29).to(4, 30).i(5, 4).to(5, 5)
+    .n().r(10, 1).to(10, 7).w(9, 30).w(10, 8).i(10, 5).to(10, 6)
+    .ny().w(12, 30).to(12, 31)
   
   
   /**
   /**
   * 2005
   * 2005
@@ -434,11 +434,11 @@ export default () => {
   * 四、“十一”:10月1日~7日放假,共7天。其中,1日、2日、3日为法定假日,将10月1日(星期六)、2日(星期日)两个公休日
   * 四、“十一”:10月1日~7日放假,共7天。其中,1日、2日、3日为法定假日,将10月1日(星期六)、2日(星期日)两个公休日
   * 调至10月4日(星期二)、5日(星期三),10月8日(星期六)、9日(星期日)两个公休日调至10月6日(星期四)、7日(星期五),10月8日、9日上班。
   * 调至10月4日(星期二)、5日(星期三),10月8日(星期六)、9日(星期日)两个公休日调至10月6日(星期四)、7日(星期五),10月8日、9日上班。
   */
   */
-  arrangement.yearAt(2005)
-    .nyd().rest(1, 1).to(1, 3)
-    .sf().rest(2, 9).to(2, 15).work(2, 5).to(2, 6).inLieu(2, 14).to(2, 15)
-    .ld().rest(5, 1).to(5, 7).work(4, 30).work(5, 8).inLieu(5, 5).to(5, 6)
-    .nd().rest(10, 1).to(10, 7).work(10, 8).to(10, 9).inLieu(10, 6).to(10, 7)
+  arrangement.y(2005)
+    .ny().r(1, 1).to(1, 3)
+    .s().r(2, 9).to(2, 15).w(2, 5).to(2, 6).i(2, 14).to(2, 15)
+    .l().r(5, 1).to(5, 7).w(4, 30).w(5, 8).i(5, 5).to(5, 6)
+    .n().r(10, 1).to(10, 7).w(10, 8).to(10, 9).i(10, 6).to(10, 7)
   
   
   /**
   /**
   * 2004
   * 2004
@@ -457,11 +457,11 @@ export default () => {
   *    其中,1日、2日、3日为法定假日,将10月2日(星期六)、3日(星期日)两个公休日调至10月4日(星期一)、5日(星期二),
   *    其中,1日、2日、3日为法定假日,将10月2日(星期六)、3日(星期日)两个公休日调至10月4日(星期一)、5日(星期二),
   *    10月9日(星期六)、10日(星期日)两个公休日调至10月6日(星期三)、7日(星期四),10月9日、10日上班。
   *    10月9日(星期六)、10日(星期日)两个公休日调至10月6日(星期三)、7日(星期四),10月9日、10日上班。
   */
   */
-  arrangement.yearAt(2004)
-    .nyd().rest(1, 1)
-    .sf().rest(1, 22).to(1, 28).work(1, 17).to(1, 18).inLieu(1, 27).to(1, 28)
-    .ld().rest(5, 1).to(5, 7).work(5, 8).to(5, 9).inLieu(5, 6).to(5, 7)
-    .nd().rest(10, 1).to(10, 7).work(10, 9).to(10, 10).inLieu(10, 6).to(10, 7)
+  arrangement.y(2004)
+    .ny().r(1, 1)
+    .s().r(1, 22).to(1, 28).w(1, 17).to(1, 18).i(1, 27).to(1, 28)
+    .l().r(5, 1).to(5, 7).w(5, 8).to(5, 9).i(5, 6).to(5, 7)
+    .n().r(10, 1).to(10, 7).w(10, 9).to(10, 10).i(10, 6).to(10, 7)
   
   
   /**
   /**
   * 注:2003年及以前的安排就很凌乱了(其实06/07两年也是叫“部分节假日安排”)
   * 注:2003年及以前的安排就很凌乱了(其实06/07两年也是叫“部分节假日安排”)

+ 14 - 9
test/holidays/arrangement.test.ts

@@ -9,35 +9,40 @@ describe('Arrangement class', () => {
   });
   });
 
 
   it('should set year correctly', () => {
   it('should set year correctly', () => {
-    arrangement.yearAt(2024);
+    arrangement.y(2024);
     expect((arrangement as any).dayDetails.year).toBe(2024);
     expect((arrangement as any).dayDetails.year).toBe(2024);
   });
   });
 
 
   it('should mark holiday correctly', () => {
   it('should mark holiday correctly', () => {
-    arrangement.nyd();
+    arrangement.ny();
     expect((arrangement as any).dayDetails.holiday).toBe(Holiday.NY);
     expect((arrangement as any).dayDetails.holiday).toBe(Holiday.NY);
   });
   });
 
 
+  it('should mark holiday correctly', () => {
+    arrangement.n();
+    expect((arrangement as any).dayDetails.holiday).toBe(Holiday.N);
+  });
+
   it('should save holiday correctly', () => {
   it('should save holiday correctly', () => {
-    arrangement.yearAt(2024).nyd().rest(1, 1);
+    arrangement.y(2024).ny().r(1, 1);
     const date = dayjs('2024-01-01').format('YYYY-MM-DD');
     const date = dayjs('2024-01-01').format('YYYY-MM-DD');
     expect(arrangement.holidays[date]).toBe(Holiday.NY);
     expect(arrangement.holidays[date]).toBe(Holiday.NY);
   });
   });
 
 
   it('should save workday correctly', () => {
   it('should save workday correctly', () => {
-    arrangement.yearAt(2024).sf().work(2, 4);
+    arrangement.y(2024).s().w(2, 4);
     const date = dayjs('2024-02-04').format('YYYY-MM-DD');
     const date = dayjs('2024-02-04').format('YYYY-MM-DD');
     expect(arrangement.workdays[date]).toBe(Holiday.S);
     expect(arrangement.workdays[date]).toBe(Holiday.S);
   });
   });
 
 
   it('should save in-lieu day correctly', () => {
   it('should save in-lieu day correctly', () => {
-    arrangement.yearAt(2024).maf().inLieu(9, 16);
+    arrangement.y(2024).m().i(9, 16);
     const date = dayjs('2024-09-16').format('YYYY-MM-DD');
     const date = dayjs('2024-09-16').format('YYYY-MM-DD');
     expect(arrangement.inLieuDays[date]).toBe(Holiday.M);
     expect(arrangement.inLieuDays[date]).toBe(Holiday.M);
   });
   });
 
 
   it('should save holiday range correctly', () => {
   it('should save holiday range correctly', () => {
-    arrangement.yearAt(2024).sf().rest(2, 10).to(2, 12);
+    arrangement.y(2024).s().r(2, 10).to(2, 12);
     const dates = ['2024-02-10', '2024-02-11', '2024-02-12'].map(date =>
     const dates = ['2024-02-10', '2024-02-11', '2024-02-12'].map(date =>
       dayjs(date).format('YYYY-MM-DD')
       dayjs(date).format('YYYY-MM-DD')
     );
     );
@@ -47,19 +52,19 @@ describe('Arrangement class', () => {
   });
   });
 
 
   it('should throw error if year is not set before saving holiday', () => {
   it('should throw error if year is not set before saving holiday', () => {
-    expect(() => arrangement.nyd().rest(1, 1)).toThrow(
+    expect(() => arrangement.ny().r(1, 1)).toThrow(
       'should set year before saving holiday'
       'should set year before saving holiday'
     );
     );
   });
   });
 
 
   it('should throw error if holiday is not set before saving holiday', () => {
   it('should throw error if holiday is not set before saving holiday', () => {
-    expect(() => arrangement.yearAt(2024).rest(1, 1)).toThrow(
+    expect(() => arrangement.y(2024).r(1, 1)).toThrow(
       'should set holiday before saving holiday'
       'should set holiday before saving holiday'
     );
     );
   });
   });
 
 
   it('should throw error if end date is before start date in holiday range', () => {
   it('should throw error if end date is before start date in holiday range', () => {
-    arrangement.yearAt(2024).sf().rest(2, 10);
+    arrangement.y(2024).s().r(2, 10);
     expect(() => arrangement.to(2, 9)).toThrow('end date should be after start date');
     expect(() => arrangement.to(2, 9)).toThrow('end date should be after start date');
   });
   });
 
 

+ 8 - 8
test/holidays/index.test.ts

@@ -77,14 +77,14 @@ describe('Arrangement Class', () => {
   });
   });
 
 
   test('should correctly handle 2023 holidays', () => {
   test('should correctly handle 2023 holidays', () => {
-    arrangement.yearAt(2024)
-    .nyd().rest(1, 1)
-    .sf().rest(2, 10).to(2, 17).work(2, 4).work(2, 18).inLieu(2, 15).to(2, 16)
-    .tsd().rest(4, 4).to(4, 6).work(4, 7).inLieu(4, 5)
-    .ld().rest(5, 1).to(5, 5).work(4, 28).work(5, 11).inLieu(5, 2).to(5, 3)
-    .dbf().rest(6, 10)
-    .maf().rest(9, 15).to(9, 17).work(9, 14).inLieu(9, 16)
-    .nd().rest(10, 1).to(10, 7).work(9, 29).work(10, 12).inLieu(10, 4).inLieu(10, 7)
+    arrangement.y(2024)
+    .ny().r(1, 1)
+    .s().r(2, 10).to(2, 17).w(2, 4).w(2, 18).i(2, 15).to(2, 16)
+    .t().r(4, 4).to(4, 6).w(4, 7).i(4, 5)
+    .l().r(5, 1).to(5, 5).w(4, 28).w(5, 11).i(5, 2).to(5, 3)
+    .d().r(6, 10)
+    .m().r(9, 15).to(9, 17).w(9, 14).i(9, 16)
+    .n().r(10, 1).to(10, 7).w(9, 29).w(10, 12).i(10, 4).i(10, 7)
 
 
     expect(arrangement.holidays).toHaveProperty('2024-05-01');
     expect(arrangement.holidays).toHaveProperty('2024-05-01');
     expect(arrangement.holidays).toHaveProperty('2024-05-02');
     expect(arrangement.holidays).toHaveProperty('2024-05-02');

+ 5 - 0
vite.config.ts

@@ -13,6 +13,11 @@ export default defineConfig(() => ({
       fileName: (format) =>
       fileName: (format) =>
         format == "umd" ? "index.min.js" : `index.${format}.js`,
         format == "umd" ? "index.min.js" : `index.${format}.js`,
     },
     },
+    rollupOptions: {
+      output: {
+        exports: 'named'
+      }
+    },
   },
   },
   plugins: [
   plugins: [
     dts({
     dts({