calendaryjs-plugin-hijri 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,115 +1,76 @@
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-hijri
2
6
 
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.
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
- > The tabular variant is computed, not observed. A sighting- or announcement-based calendar (e.g. Umm al-Qurā) may differ by ±1 day.
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.
6
12
 
7
- ## Features
13
+ > The tabular variant is computed, not observed; a sighting-based calendar (e.g. Umm
14
+ > al-Qurā) may differ by ±1 day.
8
15
 
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)
16
+ <p align="center">
17
+ <a href="https://www.npmjs.com/package/calendaryjs-plugin-hijri"><img alt="npm" src="https://img.shields.io/npm/v/calendaryjs-plugin-hijri?style=for-the-badge&color=f59e0b&labelColor=16120F" /></a>
18
+ <a href="https://socket.dev/npm/package/calendaryjs-plugin-hijri"><img alt="Socket" src="https://img.shields.io/badge/Socket-security-f59e0b?style=for-the-badge&labelColor=16120F" /></a>
19
+ <img alt="Zero dependencies" src="https://img.shields.io/badge/deps-zero-22c55e?style=for-the-badge&labelColor=16120F" />
20
+ </p>
13
21
 
14
- ## Installation
22
+ ## Install
15
23
 
16
24
  ```bash
17
- pnpm add calendaryjs calendaryjs-plugin-hijri
25
+ npm i calendaryjs calendaryjs-plugin-hijri
18
26
  ```
19
27
 
20
- ## Requirements
21
-
22
- - `calendaryjs` >= 0.1.0
28
+ ## Use it
23
29
 
24
- ## Quick Start
30
+ Register the plugin, then declare Hijri events with the `hijri.date()` selector — the
31
+ engine resolves them to Gregorian (a Hijri date can fall 0, 1 or 2 times in a Gregorian
32
+ year; all occurrences are returned):
25
33
 
26
- ```typescript
34
+ ```ts
27
35
  import { calendary } from "calendaryjs";
36
+ import { every } from "calendaryjs/builder";
28
37
  import { hijri } from "calendaryjs-plugin-hijri";
29
38
 
30
- const cal = calendary();
31
- cal.use(hijri());
39
+ const cal = calendary().use(hijri());
32
40
 
33
41
  cal.addGroup({
34
42
  id: "islamic-holidays",
35
- name: "Islamic Holidays",
36
43
  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" },
44
+ every("year").on(hijri.date(1, 1)).title("Islamic New Year"),
45
+ every("year").on(hijri.date(10, 1)).title("Eid al-Fitr"),
46
+ every("year").on(hijri.date(12, 10)).title("Eid al-Adha"),
46
47
  ],
47
48
  });
48
49
 
49
- // Resolves Hijri dates to Gregorian automatically
50
- const events = cal.getEventsInRange("2025-01-01", "2025-12-31");
50
+ cal.getEventsInRange("2025-01-01", "2025-12-31"); // Gregorian dates
51
51
  ```
52
52
 
53
- ## Event Type
54
-
55
- ### `hijri`
56
-
57
- Events based on Hijri calendar dates.
53
+ Prefer raw config? The selector compiles to a plain `hijri` event:
58
54
 
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
- }
55
+ ```ts
56
+ { type: "hijri", id: "eid", hijriMonth: 10, hijriDay: 1, title: "Eid al-Fitr" }
68
57
  ```
69
58
 
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.
59
+ ## Convert dates
73
60
 
74
- ## Date Conversion
75
-
76
- ```typescript
61
+ ```ts
77
62
  import { gregorianToHijri, hijriToGregorian } from "calendaryjs-plugin-hijri";
78
63
 
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 }
64
+ gregorianToHijri({ year: 2025, month: 1, day: 1 }); // → { year, month, day }
65
+ hijriToGregorian({ year: 1446, month: 1, day: 1 }); // → { year, month, day }
86
66
  ```
87
67
 
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
- ```
68
+ ## Reference
107
69
 
108
- ## Related Packages
70
+ **Event type `hijri`** — `hijriMonth` (1–12) · `hijriDay` (1–30), plus every standard
71
+ [event property](https://www.npmjs.com/package/calendaryjs#event-properties).
109
72
 
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
73
+ **Exports** — `hijri()` · `hijri.date(month, day)` · `gregorianToHijri` · `hijriToGregorian` · `isValidHijriDate` · `isHijriLeapYear` · `hijriMonthLength`.
113
74
 
114
75
  ## License
115
76
 
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.3"};
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.3"};
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.3",
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.4"
43
43
  },
44
44
  "files": [
45
45
  "dist"