calendaryjs-plugin-hijri 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,115 +1,70 @@
1
- # calendaryjs-plugin-hijri
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
- Islamic (Hijri) calendar plugin for [calendaryjs](https://www.npmjs.com/package/calendaryjs). Gregorian ↔ Hijri date conversion + Hijri recurring events. Uses the **tabular (civil) Islamic calendar** — arithmetic, deterministic, and round-trip safe.
5
+ # calendaryjs-plugin-hijri
4
6
 
5
- > The tabular variant is computed, not observed. A sighting- or announcement-based calendar (e.g. Umm al-Qurā) may differ by ±1 day.
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
- ## Features
9
+ Adds the **Islamic (Hijri) calendar** to calendaryjs: declare events by Hijri date, and
10
+ convert Gregorian ↔ Hijri. Uses the **tabular (civil)** Islamic calendar — arithmetic,
11
+ deterministic, round-trip safe.
8
12
 
9
- - **🌙 Hijri events** define events by Hijri date (`type: "hijri"`)
10
- - **🔄 Date conversion** Gregorian ↔ Hijri, exact inverses (round-trip safe)
11
- - **📅 Drift-aware** — a Hijri date can fall 0, 1, or 2 times in a Gregorian year; all occurrences are returned
12
- - **🗓 Leap years** — standard 30-year tabular cycle (11 leap years)
13
+ > The tabular variant is computed, not observed; a sighting-based calendar (e.g. Umm
14
+ > al-Qurā) may differ by ±1 day.
13
15
 
14
- ## Installation
16
+ ## Install
15
17
 
16
18
  ```bash
17
- pnpm add calendaryjs calendaryjs-plugin-hijri
19
+ npm i calendaryjs calendaryjs-plugin-hijri
18
20
  ```
19
21
 
20
- ## Requirements
22
+ ## Use it
21
23
 
22
- - `calendaryjs` >= 0.1.0
24
+ Register the plugin, then declare Hijri events with the `hijri.date()` selector — the
25
+ engine resolves them to Gregorian (a Hijri date can fall 0, 1 or 2 times in a Gregorian
26
+ year; all occurrences are returned):
23
27
 
24
- ## Quick Start
25
-
26
- ```typescript
28
+ ```ts
27
29
  import { calendary } from "calendaryjs";
30
+ import { every } from "calendaryjs/builder";
28
31
  import { hijri } from "calendaryjs-plugin-hijri";
29
32
 
30
- const cal = calendary();
31
- cal.use(hijri());
33
+ const cal = calendary().use(hijri());
32
34
 
33
35
  cal.addGroup({
34
36
  id: "islamic-holidays",
35
- name: "Islamic Holidays",
36
37
  events: [
37
- {
38
- type: "hijri",
39
- id: "islamic-new-year",
40
- hijriMonth: 1,
41
- hijriDay: 1,
42
- title: "Islamic New Year",
43
- },
44
- { type: "hijri", id: "eid-al-fitr", hijriMonth: 10, hijriDay: 1, title: "Eid al-Fitr" },
45
- { type: "hijri", id: "eid-al-adha", hijriMonth: 12, hijriDay: 10, title: "Eid al-Adha" },
38
+ every("year").on(hijri.date(1, 1)).title("Islamic New Year"),
39
+ every("year").on(hijri.date(10, 1)).title("Eid al-Fitr"),
40
+ every("year").on(hijri.date(12, 10)).title("Eid al-Adha"),
46
41
  ],
47
42
  });
48
43
 
49
- // Resolves Hijri dates to Gregorian automatically
50
- const events = cal.getEventsInRange("2025-01-01", "2025-12-31");
44
+ cal.getEventsInRange("2025-01-01", "2025-12-31"); // Gregorian dates
51
45
  ```
52
46
 
53
- ## Event Type
54
-
55
- ### `hijri`
47
+ Prefer raw config? The selector compiles to a plain `hijri` event:
56
48
 
57
- Events based on Hijri calendar dates.
58
-
59
- ```typescript
60
- {
61
- type: 'hijri';
62
- id: string;
63
- hijriMonth: number; // 1-12
64
- hijriDay: number; // 1-30
65
- title?: string;
66
- // ... other standard event properties
67
- }
49
+ ```ts
50
+ { type: "hijri", id: "eid", hijriMonth: 10, hijriDay: 1, title: "Eid al-Fitr" }
68
51
  ```
69
52
 
70
- Because a Hijri month/day drifts ~11 days earlier each Gregorian year, an event
71
- may occur **twice** (early January + late December) or **not at all** within a
72
- given Gregorian year. The engine returns every occurrence that lands in range.
73
-
74
- ## Date Conversion
53
+ ## Convert dates
75
54
 
76
- ```typescript
55
+ ```ts
77
56
  import { gregorianToHijri, hijriToGregorian } from "calendaryjs-plugin-hijri";
78
57
 
79
- // Gregorian Hijri
80
- gregorianToHijri({ year: 2024, month: 7, day: 8 });
81
- // → { year: 1446, month: 1, day: 1 }
82
-
83
- // Hijri → Gregorian
84
- hijriToGregorian({ year: 1446, month: 1, day: 1 });
85
- // → { year: 2024, month: 7, day: 8 }
58
+ gregorianToHijri({ year: 2025, month: 1, day: 1 }); // → { year, month, day }
59
+ hijriToGregorian({ year: 1446, month: 1, day: 1 }); // → { year, month, day }
86
60
  ```
87
61
 
88
- ### Calendar helpers
89
-
90
- ```typescript
91
- import { isHijriLeapYear, hijriMonthLength, isValidHijriDate } from "calendaryjs-plugin-hijri";
92
-
93
- isHijriLeapYear(1447); // → true (355-day year)
94
- hijriMonthLength(1446, 1); // → 30 (odd months are 30 days)
95
- isValidHijriDate({ year: 1446, month: 12, day: 30 }); // → false (not a leap year)
96
- ```
97
-
98
- ## Optional: enrich days with Hijri info
99
-
100
- ```typescript
101
- const cal = calendary().use(hijri({ enrichDays: true }));
102
- cal.addGroup({ id: "g", events: [] });
103
-
104
- const [day] = cal.getDays({ from: "2024-07-08", to: "2024-07-08" });
105
- day.hijri; // → { year: 1446, month: 1, day: 1 }
106
- ```
62
+ ## Reference
107
63
 
108
- ## Related Packages
64
+ **Event type `hijri`** — `hijriMonth` (1–12) · `hijriDay` (1–30), plus every standard
65
+ [event property](https://www.npmjs.com/package/calendaryjs#event-properties).
109
66
 
110
- - [calendaryjs](https://www.npmjs.com/package/calendaryjs) - Core package
111
- - [calendaryjs-plugin-lunar](https://www.npmjs.com/package/calendaryjs-plugin-lunar) - Lunisolar calendar
112
- - [calendaryjs-plugin-liturgical](https://www.npmjs.com/package/calendaryjs-plugin-liturgical) - Liturgical calendar
67
+ **Exports** — `hijri()` · `hijri.date(month, day)` · `gregorianToHijri` · `hijriToGregorian` · `isValidHijriDate` · `isHijriLeapYear` · `hijriMonthLength`.
113
68
 
114
69
  ## License
115
70
 
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "calendaryjs-plugin-hijri",
6
- version: "0.1.1"};
6
+ version: "0.1.2"};
7
7
 
8
8
  // src/converter.ts
9
9
  var ISLAMIC_EPOCH = 1948440;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "calendaryjs-plugin-hijri",
4
- version: "0.1.1"};
4
+ version: "0.1.2"};
5
5
 
6
6
  // src/converter.ts
7
7
  var ISLAMIC_EPOCH = 1948440;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "calendaryjs-plugin-hijri",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Islamic (Hijri) calendar plugin for calendaryjs — Gregorian ↔ Hijri date conversion (tabular/civil) and Hijri recurring events.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -39,7 +39,7 @@
39
39
  "moment-hijri": "^3.0.0",
40
40
  "typescript": "^5.3.2",
41
41
  "vitest": "^4.0.18",
42
- "calendaryjs": "0.2.1"
42
+ "calendaryjs": "0.2.2"
43
43
  },
44
44
  "files": [
45
45
  "dist"