luxon-hijri/.wiki/Home.md
Aric Camarata 1ab6463184 feat: v2.0.0 — FCNA calendar, dual ESM/CJS build, weekday bug fix, full test suite
Core fixes:
- Fix critical weekday bug: iE/iEEE/iEEEE tokens used Hijri year as Gregorian,
  returning weekdays ~580 years wrong. Now converts via toGregorian() first.
- Fix era tokens iooo/ioooo: were returning Gregorian era, now always return "AH".
- Fix toGregorian timezone sensitivity: was using DateTime.local(), now DateTime.utc().
- Fix format token regex: word-boundary approach caused partial matches.

New: FCNA/ISNA calendar support:
- toHijri, toGregorian, isValidHijriDate now accept { calendar: 'fcna' } option.
- FCNA criterion: conjunction before 12:00 UTC → month starts D+1, else D+2.
- New moon times from Meeus Ch.49 full formula (accurate to within minutes, 1000–3000 CE).
- Works for all Hijri years, not just the 1318–1500 UAQ table range.
- Anchor: UAQ table for in-range years, Islamic epoch estimate for out-of-range.
- Exports: CalendarSystem, ConversionOptions types.

Build and infrastructure:
- pnpm replaces npm; tsup replaces tsc for dual CJS/ESM output.
- Exports map with types-first conditional exports for import/require.
- Binary search O(log 183) replaces linear O(n) scan in all three functions.
- Luxon upgraded from ^2.5.2 to ^3.5.0; TypeScript from ^4 to ^5.5.
- CI: Node 20/22/24 matrix, typecheck, and pack-check jobs.
- GitHub Wiki: four pages synced via Actions on push.
- Test suite: 81 ESM tests + 24 CJS tests, verified against ISNA 2023–2025 calendars.
- Exports hwLong, hwShort, hwNumeric weekday arrays.

Breaking changes:
- Dual ESM/CJS exports map (CJS consumers: no change via main field).
- HijriYearRecord replaces hDates interface name.
- Luxon peer dep bumped to ^3.5.0.
- Node >=20 required.
2026-02-25 13:25:11 -05:00

44 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# luxon-hijri
Hijri/Gregorian date conversion and formatting based on the Umm al-Qura calendar. Built on Luxon. Zero runtime dependencies beyond Luxon itself.
**Package:** [luxon-hijri on npm](https://www.npmjs.com/package/luxon-hijri)
**Repository:** [acamarata/luxon-hijri on GitHub](https://github.com/acamarata/luxon-hijri)
**License:** MIT
## Pages
- [API Reference](API-Reference) - Function signatures, parameters, return types, format tokens
- [Architecture](Architecture) - Umm al-Qura table structure, binary search, conversion algorithm
- [Hijri Calendar](Hijri-Calendar) - Islamic calendar background, Umm al-Qura system, epoch
## Quick Example
```javascript
import { toHijri, toGregorian, formatHijriDate } from 'luxon-hijri';
// Gregorian to Hijri
const h = toHijri(new Date(2023, 2, 23, 12));
// { hy: 1444, hm: 9, hd: 1 } → 1 Ramadan 1444
// Hijri to Gregorian
const g = toGregorian(1444, 9, 1);
// Date: 2023-03-23T00:00:00.000Z
// Format
formatHijriDate({ hy: 1444, hm: 9, hd: 1 }, 'iEEEE, iD iMMMM iYYYY ioooo');
// "Yawm al-Khamis, 1 Ramadan 1444 AH"
```
## Key Facts
- Two calendars: Umm al-Qura (default, table-based, 13181500 H) and FCNA/ISNA (astronomical, all years)
- FCNA criterion: conjunction before 12:00 UTC → month starts D+1, else D+2 (Meeus Ch.49 algorithm)
- Zero runtime dependencies beyond Luxon
- Synchronous — no async, no loading delay
- Dual CJS and ESM, full TypeScript definitions
- Weekday format bug from v1 is fixed in v2 (weekday tokens now use correct Gregorian conversion)
---
[API Reference](API-Reference) . [Architecture](Architecture) . [Hijri Calendar](Hijri-Calendar)