No description
Find a file
Aric Camarata 1308ee107f
Some checks failed
CI / Test (Node 20) (push) Failing after 43s
CI / Test (Node 22) (push) Failing after 35s
CI / Test (Node 24) (push) Failing after 37s
CI / Lint (push) Failing after 33s
CI / Typecheck (push) Failing after 32s
CI / Pack check (push) Failing after 29s
CI / Coverage (push) Failing after 3s
add opt-in anonymous telemetry (#1)
* add Forgejo CI mirror and telemetry disclosure

Mirrors .github/workflows/ci.yml to .forgejo/workflows/ for self-hosted
runner on git.ariccamarata.com. Adds failure-reporting hook stub (server
registration via nself sentry ci enable is a server-side step). Adds
telemetry disclosure section to README.

* add opt-in telemetry via @acamarata/telemetry (off by default)

* chore: update lockfile for @acamarata/telemetry devDep

* chore: fix prettier formatting on telemetry import
2026-06-30 15:56:48 -04:00
.forgejo/workflows add opt-in anonymous telemetry (#1) 2026-06-30 15:56:48 -04:00
.github chore: P1 polish and documentation updates 2026-05-30 18:40:33 -04:00
src add opt-in anonymous telemetry (#1) 2026-06-30 15:56:48 -04:00
.editorconfig refactor: code quality improvements across the board 2026-03-08 11:37:55 -04:00
.gitignore ci: fix coverage corepack order, eslint parser devDeps, pack-check d.mts 2026-05-31 08:48:36 -04:00
.npmrc chore: clear .npmrc to remove pnpm-only key that warns on npm publish 2026-02-25 15:09:08 -05:00
.nvmrc feat: initial release of moment-hijri-plus v1.0.0 2026-02-25 14:15:18 -05:00
CHANGELOG.md chore: bump to v1.0.4 2026-06-13 11:52:42 -04:00
eslint.config.mjs ci: fix coverage corepack order, eslint parser devDeps, pack-check d.mts 2026-05-31 08:48:36 -04:00
LICENSE feat: initial release of moment-hijri-plus v1.0.0 2026-02-25 14:15:18 -05:00
package.json add opt-in anonymous telemetry (#1) 2026-06-30 15:56:48 -04:00
pnpm-lock.yaml add opt-in anonymous telemetry (#1) 2026-06-30 15:56:48 -04:00
pnpm-workspace.yaml feat: initial release of moment-hijri-plus v1.0.0 2026-02-25 14:15:18 -05:00
README.md add opt-in anonymous telemetry (#1) 2026-06-30 15:56:48 -04:00
TELEMETRY.md add opt-in anonymous telemetry (#1) 2026-06-30 15:56:48 -04:00
test-cjs.cjs fix: convert the displayed calendar date in toHijri for hijri-core's UTC-day contract 2026-06-10 16:35:48 -04:00
test.mjs fix: convert the displayed calendar date in toHijri for hijri-core's UTC-day contract 2026-06-10 16:35:48 -04:00
tsconfig.json chore: adopt shared config packages (tsconfig, eslint, prettier) 2026-05-30 15:11:48 -04:00
tsup.config.ts ci: pin pnpm to version 10 in all CI jobs 2026-03-08 16:37:44 -04:00
typedoc.json docs: add TypeDoc API generation (typedoc@0.28.19 + typedoc-plugin-markdown@4.11.0) 2026-05-30 16:41:59 -04:00

moment-hijri-plus

npm version CI License: MIT

Moment.js plugin for Hijri calendar conversion and formatting. Delegates all calendar logic to hijri-core, a zero-dependency Hijri engine with pluggable calendar support (Umm al-Qura and FCNA/ISNA).

Installation

pnpm add moment moment-hijri-plus hijri-core

Both moment and hijri-core are peer dependencies.

Quick Start

import moment from 'moment';
import installHijri from 'moment-hijri-plus';

installHijri(moment);

const m = moment(new Date(2023, 2, 23)); // 23 March 2023
m.toHijri();            // { hy: 1444, hm: 9, hd: 1 }  (1 Ramadan 1444 AH)
m.formatHijri('iD iMMMM iYYYY AH'); // '1 Ramadan 1444 AH'

moment.fromHijri(1446, 1, 1); // moment for 7 July 2024

API Summary

Call installHijri(moment) once at startup to add these methods.

Method Returns Description
toHijri(options?) HijriDate | null Convert to Hijri date object
hijriYear(options?) number | null Hijri year
hijriMonth(options?) number | null Hijri month (1-12)
hijriDay(options?) number | null Hijri day
isValidHijri(options?) boolean True if date is within calendar range
formatHijri(fmt, options?) string Format with Hijri tokens; non-Hijri tokens pass through
moment.fromHijri(hy, hm, hd, options?) Moment Construct moment from Hijri date

Pass { calendar: 'fcna' } to switch from the default Umm al-Qura calendar to FCNA/ISNA.

Full API reference, format token table, and examples are in the project wiki.

Day boundaries and time zones

Conversions use the calendar date the moment instance displays, not the underlying UTC instant. A moment("2025-03-01") parsed in any local timezone returns the Hijri date for March 1st, 2025. A moment created with .utc() uses its UTC components.

Religious day-start at sunset is outside the scope of this package; it depends on location and madhab, and must be handled at the application layer.

Note on Moment.js

Moment.js is in maintenance mode. For new projects, dayjs-hijri-plus offers the same Hijri support on Day.js. This package targets existing codebases already using Moment.js.

License

MIT. Copyright (c) 2026 Aric Camarata.

Telemetry

This package supports optional, anonymous usage telemetry via @acamarata/telemetry. It is off by default. See TELEMETRY.md for what is collected and how to enable or disable it.