calendaryjs-plugin-lunar 0.1.0 → 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 +32 -74
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,110 +1,68 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
5
|
+
# calendaryjs-plugin-lunar
|
|
4
6
|
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
##
|
|
13
|
+
## Install
|
|
13
14
|
|
|
14
15
|
```bash
|
|
15
|
-
|
|
16
|
+
npm i calendaryjs calendaryjs-plugin-lunar
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
##
|
|
19
|
+
## Use it
|
|
19
20
|
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
### `lunar`
|
|
42
|
+
Prefer raw config? The selector compiles to a plain `lunar` event:
|
|
48
43
|
|
|
49
|
-
|
|
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
|
-
##
|
|
48
|
+
## Convert dates
|
|
63
49
|
|
|
64
|
-
```
|
|
50
|
+
```ts
|
|
65
51
|
import { lunarToSolar, solarToLunar } from "calendaryjs-plugin-lunar";
|
|
66
52
|
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
72
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
107
|
-
- [calendaryjs-plugin-liturgical](https://github.com/calendaryjs/calendaryjs/tree/main/packages/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
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "calendaryjs-plugin-lunar",
|
|
3
|
-
"version": "0.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.
|
|
41
|
+
"calendaryjs": "0.2.2"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
44
|
"dist"
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
},
|
|
58
58
|
"repository": {
|
|
59
59
|
"type": "git",
|
|
60
|
-
"url": "git+https://github.com/
|
|
60
|
+
"url": "git+https://github.com/vbilltran68/calendaryjs.git",
|
|
61
61
|
"directory": "packages/lunar"
|
|
62
62
|
},
|
|
63
|
-
"homepage": "https://
|
|
63
|
+
"homepage": "https://www.npmjs.com/package/calendaryjs-plugin-lunar",
|
|
64
64
|
"bugs": {
|
|
65
|
-
"url": "https://github.com/
|
|
65
|
+
"url": "https://github.com/vbilltran68/calendaryjs/issues"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"typecheck": "tsc --noEmit",
|