calendaryjs-plugin-hijri
v0.1.5
Published
Islamic (Hijri) calendar plugin for calendaryjs — Gregorian ↔ Hijri date conversion (tabular/civil) and Hijri recurring events.
Maintainers
Readme
calendaryjs-plugin-hijri
New to calendaryjs? Start with the core README — this plugin builds on its engine and builder.
Adds the Islamic (Hijri) calendar to calendaryjs: declare events by Hijri date, and convert Gregorian ↔ Hijri. Uses the tabular (civil) Islamic calendar — arithmetic, deterministic, round-trip safe.
The tabular variant is computed, not observed; a sighting-based calendar (e.g. Umm al-Qurā) may differ by ±1 day.
Install
npm i calendaryjs calendaryjs-plugin-hijriUse it
Register the plugin, then declare Hijri events with the hijri.date() selector — the
engine resolves them to Gregorian (a Hijri date can fall 0, 1 or 2 times in a Gregorian
year; all occurrences are returned):
import { calendary } from "calendaryjs";
import { every } from "calendaryjs/builder";
import { hijri } from "calendaryjs-plugin-hijri";
const cal = calendary().use(hijri());
cal.addGroup({
id: "islamic-holidays",
events: [
every("year").on(hijri.date(1, 1)).title("Islamic New Year"),
every("year").on(hijri.date(10, 1)).title("Eid al-Fitr"),
every("year").on(hijri.date(12, 10)).title("Eid al-Adha"),
],
});
cal.getEventsInRange("2025-01-01", "2025-12-31"); // → Gregorian datesPrefer raw config? The selector compiles to a plain hijri event:
{ type: "hijri", id: "eid", hijriMonth: 10, hijriDay: 1, title: "Eid al-Fitr" }Convert dates
import { gregorianToHijri, hijriToGregorian } from "calendaryjs-plugin-hijri";
gregorianToHijri({ year: 2025, month: 1, day: 1 }); // → { year, month, day }
hijriToGregorian({ year: 1446, month: 1, day: 1 }); // → { year, month, day }Reference
Event type hijri — hijriMonth (1–12) · hijriDay (1–30), plus every standard
event property.
Exports — hijri() · hijri.date(month, day) · gregorianToHijri · hijriToGregorian · isValidHijriDate · isHijriLeapYear · hijriMonthLength.
License
MIT. This plugin requires the calendaryjs core, which is licensed
PolyForm Noncommercial — so commercial use of the combined work requires a
commercial license for the core. See Commercial licensing.
