calendaryjs-plugin-lunar 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,110 +1,68 @@
1
- # calendaryjs-plugin-lunar
1
+ <p align="center">
2
+ <img src="https://cdn.jsdelivr.net/npm/calendaryjs/assets/logo.svg" alt="calendaryjs" width="380" />
3
+ </p>
2
4
 
3
- Lunar (lunisolar) calendar plugin for [calendaryjs](https://www.npmjs.com/package/calendaryjs). Solar ↔ lunar date conversion (1900–2100) + lunar recurring events. Uses the standard astronomical lunisolar table.
5
+ # calendaryjs-plugin-lunar
4
6
 
5
- ## Features
7
+ > **New to calendaryjs?** Start with the [core README](https://www.npmjs.com/package/calendaryjs) — this plugin builds on its engine and builder.
6
8
 
7
- - **🌙 Lunar events** define events by lunar date (`type: "lunar"`)
8
- - **🔄 Date conversion** — solar ↔ lunar, 1900–2100
9
- - **🌏 Lunisolar** — standard astronomical lunisolar table
10
- - **📅 Leap-month handling** — correct intercalary-month calculations
9
+ Adds the **lunar (lunisolar) calendar** to calendaryjs: declare events by lunar date,
10
+ and convert solar ↔ lunar (1900–2100) with the standard astronomical lunisolar table
11
+ (leap months handled).
11
12
 
12
- ## Installation
13
+ ## Install
13
14
 
14
15
  ```bash
15
- pnpm add calendaryjs calendaryjs-plugin-lunar
16
+ npm i calendaryjs calendaryjs-plugin-lunar
16
17
  ```
17
18
 
18
- ## Requirements
19
+ ## Use it
19
20
 
20
- - `calendaryjs` >= 0.1.0
21
+ Register the plugin, then declare lunar events with the `lunar.date()` selector — the
22
+ engine converts them to solar dates automatically:
21
23
 
22
- ## Quick Start
23
-
24
- ```typescript
24
+ ```ts
25
25
  import { calendary } from "calendaryjs";
26
+ import { every } from "calendaryjs/builder";
26
27
  import { lunar } from "calendaryjs-plugin-lunar";
27
28
 
28
- const cal = calendary();
29
- cal.use(lunar());
29
+ const cal = calendary().use(lunar());
30
30
 
31
31
  cal.addGroup({
32
32
  id: "lunar-holidays",
33
- name: "Lunar Holidays",
34
33
  events: [
35
- { type: "lunar", id: "lunar-new-year", lunarMonth: 1, lunarDay: 1, title: "Lunar New Year" },
36
- { type: "lunar", id: "lantern", lunarMonth: 1, lunarDay: 15, title: "Lantern Festival" },
37
- { type: "lunar", id: "mid-autumn", lunarMonth: 8, lunarDay: 15, title: "Mid-Autumn Festival" },
34
+ every("year").on(lunar.date(1, 1)).title("Lunar New Year"),
35
+ every("year").on(lunar.date(8, 15)).title("Mid-Autumn Festival"),
38
36
  ],
39
37
  });
40
38
 
41
- // Get events - automatically converts lunar to solar dates
42
- const events = cal.getEventsInRange("2025-01-01", "2025-12-31");
39
+ cal.getEventsInRange("2025-01-01", "2025-12-31"); // solar dates
43
40
  ```
44
41
 
45
- ## Event Type
46
-
47
- ### `lunar`
42
+ Prefer raw config? The selector compiles to a plain `lunar` event:
48
43
 
49
- Events based on lunar calendar dates.
50
-
51
- ```typescript
52
- {
53
- type: 'lunar';
54
- id: string;
55
- lunarMonth: number; // 1-12
56
- lunarDay: number; // 1-30
57
- title?: string;
58
- // ... other standard event properties
59
- }
44
+ ```ts
45
+ { type: "lunar", id: "tet", lunarMonth: 1, lunarDay: 1, title: "Lunar New Year" }
60
46
  ```
61
47
 
62
- ## Lunar Date Conversion
48
+ ## Convert dates
63
49
 
64
- ```typescript
50
+ ```ts
65
51
  import { lunarToSolar, solarToLunar } from "calendaryjs-plugin-lunar";
66
52
 
67
- // Lunar to Solar
68
- const solarDate = lunarToSolar({ year: 2025, month: 1, day: 1, isLeapMonth: false });
69
- // Returns: { year: 2025, month: 1, day: 29 }
53
+ lunarToSolar({ year: 2025, month: 1, day: 1, isLeapMonth: false });
54
+ // { year: 2025, month: 1, day: 29 }
70
55
 
71
- // Solar to Lunar
72
- const lunarDate = solarToLunar({ year: 2025, month: 1, day: 29 });
73
- // Returns: { year: 2025, month: 1, day: 1, isLeapMonth: false }
56
+ solarToLunar({ year: 2025, month: 1, day: 29 });
57
+ // { year: 2025, month: 1, day: 1, isLeapMonth: false }
74
58
  ```
75
59
 
76
- ## Example: lunar holidays
77
-
78
- ```typescript
79
- import { calendary } from "calendaryjs";
80
- import { lunar } from "calendaryjs-plugin-lunar";
81
-
82
- const cal = calendary();
83
- cal.use(lunar());
84
-
85
- cal.addGroup({
86
- id: "lunar-holidays",
87
- name: "Lunar Holidays",
88
- events: [
89
- { type: "lunar", id: "lunar-new-year", lunarMonth: 1, lunarDay: 1, title: "Lunar New Year" },
90
- { type: "lunar", id: "lantern", lunarMonth: 1, lunarDay: 15, title: "Lantern Festival" },
91
- { type: "lunar", id: "dragon-boat", lunarMonth: 5, lunarDay: 5, title: "Dragon Boat Festival" },
92
- { type: "lunar", id: "mid-autumn", lunarMonth: 8, lunarDay: 15, title: "Mid-Autumn Festival" },
93
- {
94
- type: "lunar",
95
- id: "double-ninth",
96
- lunarMonth: 9,
97
- lunarDay: 9,
98
- title: "Double Ninth Festival",
99
- },
100
- ],
101
- });
102
- ```
60
+ ## Reference
103
61
 
104
- ## Related Packages
62
+ **Event type `lunar`** — `lunarMonth` (1–12) · `lunarDay` (1–30), plus every standard
63
+ [event property](https://www.npmjs.com/package/calendaryjs#event-properties).
105
64
 
106
- - [calendaryjs](https://www.npmjs.com/package/calendaryjs) - Core package
107
- - [calendaryjs-plugin-liturgical](https://www.npmjs.com/package/calendaryjs-plugin-liturgical) - Liturgical calendar
65
+ **Exports** — `lunar()` · `lunar.date(month, day)` · `lunarToSolar` · `solarToLunar` · `isValidLunarDate`.
108
66
 
109
67
  ## License
110
68
 
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "calendaryjs-plugin-lunar",
6
- version: "0.1.1"};
6
+ version: "0.1.2"};
7
7
 
8
8
  // src/converter.ts
9
9
  var LUNAR_INFO = [
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "calendaryjs-plugin-lunar",
4
- version: "0.1.1"};
4
+ version: "0.1.2"};
5
5
 
6
6
  // src/converter.ts
7
7
  var LUNAR_INFO = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "calendaryjs-plugin-lunar",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Lunar (lunisolar) calendar plugin for calendaryjs — solar ↔ lunar date conversion (1900–2100) and lunar recurring events using the standard astronomical lunisolar table.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -38,7 +38,7 @@
38
38
  "lunar-javascript": "^1.7.7",
39
39
  "typescript": "^5.3.2",
40
40
  "vitest": "^4.0.18",
41
- "calendaryjs": "0.2.1"
41
+ "calendaryjs": "0.2.2"
42
42
  },
43
43
  "files": [
44
44
  "dist"