-
Notifications
You must be signed in to change notification settings - Fork 0
Home
github-actions[bot] edited this page May 25, 2026
·
2 revisions
Zero-dependency Hijri calendar engine for JavaScript and TypeScript.
Two built-in calendars: Umm al-Qura (UAQ) and FCNA/ISNA. Additional calendars can be registered at runtime through the engine registry.
import { toHijri, toGregorian } from 'hijri-core';
// UAQ (default)
const hijri = toHijri(new Date(2025, 2, 1));
// { hy: 1446, hm: 9, hd: 1 }
const greg = toGregorian(1446, 9, 1);
// Date: 2025-03-01
// FCNA
const hijriFcna = toHijri(new Date('2025-03-01'), { calendar: 'fcna' });
const gregFcna = toGregorian(1446, 9, 1, { calendar: 'fcna' });import { registerCalendar, toHijri, type CalendarEngine } from 'hijri-core';
const myEngine: CalendarEngine = {
id: 'my-calendar',
toHijri: (date) => ({ hy: 1446, hm: 1, hd: 1 }),
toGregorian: (hy, hm, hd) => new Date(),
isValid: (hy, hm, hd) => hy > 0 && hm >= 1 && hm <= 12 && hd >= 1,
daysInMonth: (hy, hm) => 30,
};
registerCalendar('my-calendar', myEngine);
toHijri(new Date(), { calendar: 'my-calendar' });- Zero dependencies
- Dual CJS + ESM build
- Full TypeScript declarations
- Extensible calendar registry
- UAQ table covers 1318-1500 H (1900-2076 CE)
- FCNA engine works for any year using Meeus astronomical algorithms
Reference
API
- toHijri
- toGregorian
- isValidHijriDate
- daysInHijriMonth
- registerCalendar
- getCalendar
- listCalendars
- hDatesTable
- hmLong / hmMedium / hmShort
- hwLong / hwShort / hwNumeric
Guides
Examples
Contributing
Links