mirror of
https://github.com/acamarata/dayjs-hijri-plus.git
synced 2026-06-30 18:54:26 +00:00
Day.js plugin adding Hijri calendar support via hijri-core. Adds toHijri(), fromHijri(), hijriYear/Month/Day(), isValidHijri(), and formatHijri() to all Day.js instances. Supports UAQ and FCNA calendars via ConversionOptions. Format token escaping wraps substituted values in Day.js bracket syntax to prevent re-interpretation as format tokens. 14 ESM + 8 CJS tests passing. Dual CJS/ESM build.
36 lines
937 B
Markdown
36 lines
937 B
Markdown
# dayjs-hijri-plus
|
|
|
|
A Day.js plugin for Hijri calendar conversion and formatting. All calendar logic is delegated to [hijri-core](https://github.com/acamarata/hijri-core), making this package a thin, well-typed adapter with no calendar arithmetic of its own.
|
|
|
|
## Install
|
|
|
|
```sh
|
|
pnpm add dayjs dayjs-hijri-plus hijri-core
|
|
```
|
|
|
|
## Quick Usage
|
|
|
|
```ts
|
|
import dayjs from 'dayjs';
|
|
import hijriPlugin from 'dayjs-hijri-plus';
|
|
|
|
dayjs.extend(hijriPlugin);
|
|
|
|
dayjs('2023-03-23').toHijri();
|
|
// => { hy: 1444, hm: 9, hd: 1 }
|
|
|
|
dayjs('2023-03-23').formatHijri('iD iMMMM iYYYY');
|
|
// => '1 Ramadan 1444'
|
|
|
|
dayjs.fromHijri(1444, 10, 1).format('YYYY-MM-DD');
|
|
// => '2023-04-21'
|
|
```
|
|
|
|
## Contents
|
|
|
|
- [API Reference](API-Reference) — all methods, parameters, return types
|
|
- [Architecture](Architecture) — design decisions, delegation model, format token resolution
|
|
|
|
---
|
|
|
|
Part of the [acamarata](https://github.com/acamarata) JavaScript library collection.
|