From 546ec2d302f403902898598250835bfaac297f08 Mon Sep 17 00:00:00 2001 From: Aric Camarata Date: Sat, 30 May 2026 18:38:38 -0400 Subject: [PATCH] chore: E6 polish wiki + CI + TypeDoc integration (P1) --- .github/wiki/_Sidebar.md | 11 ++ .github/wiki/api/variables/default.md | 2 +- .github/wiki/examples/basic-usage.md | 44 ++++--- .github/wiki/examples/formatting.md | 51 ++++---- .github/wiki/guides/advanced.md | 45 ++++--- .github/wiki/guides/quickstart.md | 41 +++--- .github/workflows/ci.yml | 21 +++ README.md | 182 ++------------------------ src/index.ts | 140 ++++++++++++++++++-- 9 files changed, 266 insertions(+), 271 deletions(-) diff --git a/.github/wiki/_Sidebar.md b/.github/wiki/_Sidebar.md index 0e9d49e..5320d2b 100644 --- a/.github/wiki/_Sidebar.md +++ b/.github/wiki/_Sidebar.md @@ -13,6 +13,17 @@ - [Architecture](Architecture) - [Benchmarks](benchmarks/index) +**API Pages** +- [plugin (default)](api/plugin) +- [toHijri](api/toHijri) +- [isValidHijri](api/isValidHijri) +- [hijriYear](api/hijriYear) +- [hijriMonth](api/hijriMonth) +- [hijriDay](api/hijriDay) +- [formatHijri](api/formatHijri) +- [fromHijri](api/fromHijri) +- [registerCalendar](api/registerCalendar) + **Community** - [Contributing](CONTRIBUTING) - [Code of Conduct](CODE_OF_CONDUCT) diff --git a/.github/wiki/api/variables/default.md b/.github/wiki/api/variables/default.md index 3ee7687..d6c85c0 100644 --- a/.github/wiki/api/variables/default.md +++ b/.github/wiki/api/variables/default.md @@ -8,7 +8,7 @@ > `const` **default**: `PluginFunc` -Defined in: [src/index.ts:164](https://github.com/acamarata/dayjs-hijri-plus/blob/599c7481510f5ea625b79c98a7030b9c8d90e4f7/src/index.ts#L164) +Defined in: [src/index.ts:164](https://github.com/acamarata/dayjs-hijri-plus/blob/033ca475760db2b9e4c6edd69cc9dc1f013b8d8f/src/index.ts#L164) Day.js plugin that adds Hijri calendar support. diff --git a/.github/wiki/examples/basic-usage.md b/.github/wiki/examples/basic-usage.md index 34a829b..cd97b2f 100644 --- a/.github/wiki/examples/basic-usage.md +++ b/.github/wiki/examples/basic-usage.md @@ -4,9 +4,9 @@ ```typescript import dayjs from 'dayjs'; -import hijri from 'dayjs-hijri-plus'; +import hijriPlugin from 'dayjs-hijri-plus'; -dayjs.extend(hijri); +dayjs.extend(hijriPlugin); ``` ## Convert today's date to Hijri @@ -14,9 +14,11 @@ dayjs.extend(hijri); ```typescript const today = dayjs(); const h = today.toHijri(); -// { hy: 1444, hm: 9, hd: 1 } (example — actual output depends on the current date) +// { hy: 1446, hm: 11, hd: 3 } (example — actual output depends on today's date) -console.log(`${h.hd} / ${h.hm} / ${h.hy}`); +if (h !== null) { + console.log(`${h.hd} / ${h.hm} / ${h.hy}`); +} ``` ## Convert a known Gregorian date @@ -26,16 +28,16 @@ console.log(`${h.hd} / ${h.hm} / ${h.hy}`); const d = dayjs('2023-03-23'); const h = d.toHijri(); -console.log(h.hy); // 1444 -console.log(h.hm); // 9 (Ramadan is the 9th month) -console.log(h.hd); // 1 +console.log(h?.hy); // 1444 +console.log(h?.hm); // 9 (Ramadan is the 9th month) +console.log(h?.hd); // 1 ``` ## Convert from Hijri to Gregorian ```typescript const gregorian = dayjs.fromHijri(1444, 9, 1); -console.log(gregorian.format('YYYY-MM-DD')); // '2023-03-23' +console.log(gregorian.format('YYYY-MM-DD')); // '2023-03-23' ``` ## Hijri accessor methods @@ -43,9 +45,9 @@ console.log(gregorian.format('YYYY-MM-DD')); // '2023-03-23' ```typescript const d = dayjs('2023-03-23'); -console.log(d.iYear()); // 1444 -console.log(d.iMonth()); // 9 -console.log(d.iDate()); // 1 +console.log(d.hijriYear()); // 1444 +console.log(d.hijriMonth()); // 9 +console.log(d.hijriDay()); // 1 ``` ## Format with Hijri tokens @@ -53,10 +55,10 @@ console.log(d.iDate()); // 1 ```typescript const d = dayjs('2023-03-23'); -d.format('iD iMMMM iYYYY'); // '1 Ramadan 1444' -d.format('iDD/iMM/iYYYY'); // '01/09/1444' -d.format('YYYY-MM-DD'); // '2023-03-23' (Gregorian tokens still work) -d.format('YYYY (iYYYY/iM/iD)'); // '2023 (1444/9/1)' +d.formatHijri('iD iMMMM iYYYY'); // '1 Ramadan 1444' +d.formatHijri('iDD/iMM/iYYYY'); // '01/09/1444' +d.formatHijri('YYYY-MM-DD'); // 'YYYY-MM-DD' — use .format() for Gregorian-only +d.formatHijri('YYYY (iYYYY/iM/iD)'); // '2023 (1444/9/1)' ``` ## Use FCNA calendar @@ -65,20 +67,20 @@ d.format('YYYY (iYYYY/iM/iD)'); // '2023 (1444/9/1)' const d = dayjs('2023-03-23'); const fcna = d.toHijri({ calendar: 'fcna' }); -console.log(fcna.hy); // 1444 -console.log(fcna.hm); // 9 -console.log(fcna.hd); // 1 // Near month boundaries, UAQ and FCNA may differ by one day +console.log(fcna?.hy); // 1444 +console.log(fcna?.hm); // 9 +console.log(fcna?.hd); // 1 or 2 depending on the month boundary ``` ## CJS usage ```javascript const dayjs = require('dayjs'); -const hijri = require('dayjs-hijri-plus'); +const hijriPlugin = require('dayjs-hijri-plus'); -dayjs.extend(hijri); +dayjs.extend(hijriPlugin); const d = dayjs('2023-03-23'); -console.log(d.iYear()); // 1444 +console.log(d.hijriYear()); // 1444 ``` diff --git a/.github/wiki/examples/formatting.md b/.github/wiki/examples/formatting.md index 8a52672..8ddf696 100644 --- a/.github/wiki/examples/formatting.md +++ b/.github/wiki/examples/formatting.md @@ -7,61 +7,60 @@ | `iYYYY` | Full Hijri year | `1444` | | `iYY` | 2-digit Hijri year | `44` | | `iMMMM` | Full month name | `Ramadan` | -| `iMMM` | Abbreviated month name | `Ram` | +| `iMMM` | Abbreviated month name | `Ramadan` | | `iMM` | 2-digit month number | `09` | | `iM` | Month number | `9` | | `iDD` | 2-digit day | `01` | | `iD` | Day number | `1` | +| `iEEEE` | Full weekday name | `Yawm al-Khamis` | +| `iEEE` | Short weekday name | `Kham` | +| `iE` | Weekday number | `5` (1=Sunday) | +| `ioooo` | Era | `AH` | -Tokens not prefixed with `i` are passed through to Day.js as Gregorian tokens. +Tokens not prefixed with `i` pass through to Day.js `.format()` as Gregorian tokens. ## Common format patterns ```typescript import dayjs from 'dayjs'; -import hijri from 'dayjs-hijri-plus'; +import hijriPlugin from 'dayjs-hijri-plus'; -dayjs.extend(hijri); +dayjs.extend(hijriPlugin); const d = dayjs('2023-03-23'); // Day Month Year (long) -d.format('iD iMMMM iYYYY'); +d.formatHijri('iD iMMMM iYYYY'); // '1 Ramadan 1444' // Numeric date -d.format('iDD/iMM/iYYYY'); +d.formatHijri('iDD/iMM/iYYYY'); // '01/09/1444' // Short month name -d.format('iD iMMM iYYYY'); -// '1 Ram 1444' +d.formatHijri('iD iMMM iYYYY'); +// '1 Ramadan 1444' // Combined Gregorian and Hijri -d.format('YYYY-MM-DD (iD iMMMM iYYYY)'); +d.formatHijri('YYYY-MM-DD (iD iMMMM iYYYY)'); // '2023-03-23 (1 Ramadan 1444)' // ISO-style Hijri -d.format('iYYYY-iMM-iDD'); +d.formatHijri('iYYYY-iMM-iDD'); // '1444-09-01' ``` ## Hijri month names ```typescript -const months = [ - 'Muharram', 'Safar', "Rabi' al-Awwal", "Rabi' al-Thani", - "Jumada al-Awwal", "Jumada al-Thani", 'Rajab', "Sha'ban", - 'Ramadan', 'Shawwal', "Dhu al-Qa'dah", "Dhu al-Hijjah" -]; - // iMMMM returns the standard transliteration for each month for (let m = 1; m <= 12; m++) { const d = dayjs.fromHijri(1444, m, 1); - console.log(d.format('iM iMMMM')); + console.log(d.formatHijri('iM iMMMM')); } // 1 Muharram // 2 Safar +// 3 Rabi' al-Awwal // ... // 9 Ramadan // ... @@ -72,26 +71,26 @@ for (let m = 1; m <= 12; m++) { ```tsx import dayjs from 'dayjs'; -import hijri from 'dayjs-hijri-plus'; +import hijriPlugin from 'dayjs-hijri-plus'; -dayjs.extend(hijri); +dayjs.extend(hijriPlugin); -interface HijriDateProps { +interface HijriDateDisplayProps { date: Date; } -function HijriDate({ date }: HijriDateProps) { +function HijriDateDisplay({ date }: HijriDateDisplayProps) { const d = dayjs(date); - const gregorian = d.format('YYYY-MM-DD'); - const hijriFormatted = d.format('iD iMMMM iYYYY'); + const gregorianIso = d.format('YYYY-MM-DD'); + const hijriFormatted = d.formatHijri('iD iMMMM iYYYY'); return ( -