calendaryjs-plugin-lunar 0.1.1 → 0.1.3

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,74 @@
1
+ <p align="center">
2
+ <img src="https://cdn.jsdelivr.net/npm/calendaryjs/assets/logo.svg" alt="calendaryjs" width="380" />
3
+ </p>
4
+
1
5
  # calendaryjs-plugin-lunar
2
6
 
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.
7
+ > **New to calendaryjs?** Start with the [core README](https://www.npmjs.com/package/calendaryjs) this plugin builds on its engine and builder.
4
8
 
5
- ## Features
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).
6
12
 
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
13
+ <p align="center">
14
+ <a href="https://www.npmjs.com/package/calendaryjs-plugin-lunar"><img alt="npm" src="https://img.shields.io/npm/v/calendaryjs-plugin-lunar?style=for-the-badge&color=f59e0b&labelColor=16120F" /></a>
15
+ <a href="https://socket.dev/npm/package/calendaryjs-plugin-lunar"><img alt="Socket" src="https://img.shields.io/badge/Socket-security-f59e0b?style=for-the-badge&labelColor=16120F" /></a>
16
+ <img alt="Zero dependencies" src="https://img.shields.io/badge/deps-zero-22c55e?style=for-the-badge&labelColor=16120F" />
17
+ </p>
11
18
 
12
- ## Installation
19
+ ## Install
13
20
 
14
21
  ```bash
15
- pnpm add calendaryjs calendaryjs-plugin-lunar
22
+ npm i calendaryjs calendaryjs-plugin-lunar
16
23
  ```
17
24
 
18
- ## Requirements
19
-
20
- - `calendaryjs` >= 0.1.0
25
+ ## Use it
21
26
 
22
- ## Quick Start
27
+ Register the plugin, then declare lunar events with the `lunar.date()` selector — the
28
+ engine converts them to solar dates automatically:
23
29
 
24
- ```typescript
30
+ ```ts
25
31
  import { calendary } from "calendaryjs";
32
+ import { every } from "calendaryjs/builder";
26
33
  import { lunar } from "calendaryjs-plugin-lunar";
27
34
 
28
- const cal = calendary();
29
- cal.use(lunar());
35
+ const cal = calendary().use(lunar());
30
36
 
31
37
  cal.addGroup({
32
38
  id: "lunar-holidays",
33
- name: "Lunar Holidays",
34
39
  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" },
40
+ every("year").on(lunar.date(1, 1)).title("Lunar New Year"),
41
+ every("year").on(lunar.date(8, 15)).title("Mid-Autumn Festival"),
38
42
  ],
39
43
  });
40
44
 
41
- // Get events - automatically converts lunar to solar dates
42
- const events = cal.getEventsInRange("2025-01-01", "2025-12-31");
45
+ cal.getEventsInRange("2025-01-01", "2025-12-31"); // solar dates
43
46
  ```
44
47
 
45
- ## Event Type
46
-
47
- ### `lunar`
48
-
49
- Events based on lunar calendar dates.
48
+ Prefer raw config? The selector compiles to a plain `lunar` event:
50
49
 
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
- }
50
+ ```ts
51
+ { type: "lunar", id: "tet", lunarMonth: 1, lunarDay: 1, title: "Lunar New Year" }
60
52
  ```
61
53
 
62
- ## Lunar Date Conversion
54
+ ## Convert dates
63
55
 
64
- ```typescript
56
+ ```ts
65
57
  import { lunarToSolar, solarToLunar } from "calendaryjs-plugin-lunar";
66
58
 
67
- // Lunar to Solar
68
- const solarDate = lunarToSolar({ year: 2025, month: 1, day: 1, isLeapMonth: false });
69
- // Returns: { year: 2025, month: 1, day: 29 }
59
+ lunarToSolar({ year: 2025, month: 1, day: 1, isLeapMonth: false });
60
+ // { year: 2025, month: 1, day: 29 }
70
61
 
71
- // Solar to Lunar
72
- const lunarDate = solarToLunar({ year: 2025, month: 1, day: 29 });
73
- // Returns: { year: 2025, month: 1, day: 1, isLeapMonth: false }
62
+ solarToLunar({ year: 2025, month: 1, day: 29 });
63
+ // { year: 2025, month: 1, day: 1, isLeapMonth: false }
74
64
  ```
75
65
 
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
- ```
66
+ ## Reference
103
67
 
104
- ## Related Packages
68
+ **Event type `lunar`** — `lunarMonth` (1–12) · `lunarDay` (1–30), plus every standard
69
+ [event property](https://www.npmjs.com/package/calendaryjs#event-properties).
105
70
 
106
- - [calendaryjs](https://www.npmjs.com/package/calendaryjs) - Core package
107
- - [calendaryjs-plugin-liturgical](https://www.npmjs.com/package/calendaryjs-plugin-liturgical) - Liturgical calendar
71
+ **Exports** — `lunar()` · `lunar.date(month, day)` · `lunarToSolar` · `solarToLunar` · `isValidLunarDate`.
108
72
 
109
73
  ## License
110
74
 
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.3"};
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.3"};
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.3",
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.4"
42
42
  },
43
43
  "files": [
44
44
  "dist"