moment-hijri-plus/.wiki/Home.md
Aric Camarata 295dbf8680 feat: initial release of moment-hijri-plus v1.0.0
Moment.js plugin adding Hijri calendar support via hijri-core. Adds
toHijri(), fromHijri(), hijriYear/Month/Day(), isValidHijri(), and
formatHijri() to all Moment instances via fn prototype and module
augmentation. Format token escaping wraps substituted values in
moment bracket syntax [...] to prevent re-interpretation. UTC-midnight
date shift corrected by using getUTC* components + moment([y, m, d])
construction. 14 ESM + 8 CJS tests passing. Dual CJS/ESM build.
2026-02-25 14:15:18 -05:00

1.5 KiB

moment-hijri-plus

A Moment.js plugin for Hijri calendar conversion and formatting. All calendar arithmetic is handled by hijri-core, keeping this package thin and focused.

What it does

  • Converts any moment to a Hijri date object ({ hy, hm, hd })
  • Formats moments using Hijri-specific tokens mixed freely with standard Moment format tokens
  • Constructs moments from Hijri dates via moment.fromHijri()
  • Supports Umm al-Qura (UAQ) and FCNA/ISNA calendars

Pages

  • API Reference — complete method signatures and examples
  • Architecture — design rationale, token system, calendar delegation

Quick start

pnpm add moment moment-hijri-plus hijri-core
import moment from 'moment';
import installHijri from 'moment-hijri-plus';

installHijri(moment);

moment(new Date(2023, 2, 23)).toHijri();
// => { hy: 1444, hm: 9, hd: 1 }  (1 Ramadan 1444 AH)

moment(new Date(2023, 2, 23)).formatHijri('iD iMMMM iYYYY AH');
// => '1 Ramadan 1444 AH'

moment.fromHijri(1446, 1, 1).format('YYYY-MM-DD');
// => '2024-07-07'

Home · API Reference · Architecture