style: fix prettier table formatting in wiki

This commit is contained in:
Aric Camarata 2026-03-08 17:30:54 -04:00
parent bc32214cee
commit f00656ee20
2 changed files with 77 additions and 77 deletions

View file

@ -15,7 +15,7 @@ interface ConversionOptions {
### `toHijriDate` ### `toHijriDate`
```typescript ```typescript
function toHijriDate(date: Date, options?: ConversionOptions): HijriDate | null function toHijriDate(date: Date, options?: ConversionOptions): HijriDate | null;
``` ```
Convert a Gregorian `Date` to a Hijri date object. Convert a Gregorian `Date` to a Hijri date object.
@ -24,9 +24,9 @@ Returns `null` when the date falls outside the calendar's supported range. UAQ c
**Parameters:** **Parameters:**
| Name | Type | Description | | Name | Type | Description |
| --- | --- | --- | | --------- | ------------------- | ----------------------------------- |
| `date` | `Date` | A valid Gregorian date | | `date` | `Date` | A valid Gregorian date |
| `options` | `ConversionOptions` | Optional. Calendar system selection | | `options` | `ConversionOptions` | Optional. Calendar system selection |
**Returns:** `HijriDate | null` **Returns:** `HijriDate | null`
@ -48,7 +48,7 @@ toHijriDate(new Date(1800, 0, 1));
### `fromHijriDate` ### `fromHijriDate`
```typescript ```typescript
function fromHijriDate(hy: number, hm: number, hd: number, options?: ConversionOptions): Date function fromHijriDate(hy: number, hm: number, hd: number, options?: ConversionOptions): Date;
``` ```
Convert a Hijri date to a Gregorian `Date`. Convert a Hijri date to a Gregorian `Date`.
@ -57,11 +57,11 @@ The returned `Date` is set to midnight UTC of the equivalent Gregorian day.
**Parameters:** **Parameters:**
| Name | Type | Description | | Name | Type | Description |
| --- | --- | --- | | --------- | ------------------- | ----------------------------------- |
| `hy` | `number` | Hijri year | | `hy` | `number` | Hijri year |
| `hm` | `number` | Hijri month (1-12) | | `hm` | `number` | Hijri month (1-12) |
| `hd` | `number` | Hijri day (1-30) | | `hd` | `number` | Hijri day (1-30) |
| `options` | `ConversionOptions` | Optional. Calendar system selection | | `options` | `ConversionOptions` | Optional. Calendar system selection |
**Returns:** `Date` **Returns:** `Date`
@ -87,7 +87,7 @@ fromHijriDate(1444, 13, 1);
### `isValidHijriDate` ### `isValidHijriDate`
```typescript ```typescript
function isValidHijriDate(hy: number, hm: number, hd: number, options?: ConversionOptions): boolean function isValidHijriDate(hy: number, hm: number, hd: number, options?: ConversionOptions): boolean;
``` ```
Check whether a Hijri date is valid. Verifies year, month (1-12), and day (1-daysInMonth) all exist in the calendar's data table. Check whether a Hijri date is valid. Verifies year, month (1-12), and day (1-daysInMonth) all exist in the calendar's data table.
@ -95,9 +95,9 @@ Check whether a Hijri date is valid. Verifies year, month (1-12), and day (1-day
**Example:** **Example:**
```typescript ```typescript
isValidHijriDate(1444, 9, 1); // true isValidHijriDate(1444, 9, 1); // true
isValidHijriDate(1444, 13, 1); // false - no month 13 isValidHijriDate(1444, 13, 1); // false - no month 13
isValidHijriDate(1444, 9, 31); // false - Ramadan has 29 or 30 days isValidHijriDate(1444, 9, 31); // false - Ramadan has 29 or 30 days
``` ```
--- ---
@ -107,7 +107,7 @@ isValidHijriDate(1444, 9, 31); // false - Ramadan has 29 or 30 days
### `getHijriYear` ### `getHijriYear`
```typescript ```typescript
function getHijriYear(date: Date, options?: ConversionOptions): number | null function getHijriYear(date: Date, options?: ConversionOptions): number | null;
``` ```
Get the Hijri year for a Gregorian date. Returns `null` when out of range. Get the Hijri year for a Gregorian date. Returns `null` when out of range.
@ -117,7 +117,7 @@ Get the Hijri year for a Gregorian date. Returns `null` when out of range.
### `getHijriMonth` ### `getHijriMonth`
```typescript ```typescript
function getHijriMonth(date: Date, options?: ConversionOptions): number | null function getHijriMonth(date: Date, options?: ConversionOptions): number | null;
``` ```
Get the Hijri month (1-12) for a Gregorian date. Returns `null` when out of range. Get the Hijri month (1-12) for a Gregorian date. Returns `null` when out of range.
@ -127,7 +127,7 @@ Get the Hijri month (1-12) for a Gregorian date. Returns `null` when out of rang
### `getHijriDay` ### `getHijriDay`
```typescript ```typescript
function getHijriDay(date: Date, options?: ConversionOptions): number | null function getHijriDay(date: Date, options?: ConversionOptions): number | null;
``` ```
Get the Hijri day of month for a Gregorian date. Returns `null` when out of range. Get the Hijri day of month for a Gregorian date. Returns `null` when out of range.
@ -137,7 +137,7 @@ Get the Hijri day of month for a Gregorian date. Returns `null` when out of rang
### `getDaysInHijriMonth` ### `getDaysInHijriMonth`
```typescript ```typescript
function getDaysInHijriMonth(hy: number, hm: number, options?: ConversionOptions): number function getDaysInHijriMonth(hy: number, hm: number, options?: ConversionOptions): number;
``` ```
Get the number of days in a Hijri month. Returns 29 or 30. Get the number of days in a Hijri month. Returns 29 or 30.
@ -156,7 +156,7 @@ getDaysInHijriMonth(1444, 1); // 30 (Muharram 1444)
### `getHijriQuarter` ### `getHijriQuarter`
```typescript ```typescript
function getHijriQuarter(date: Date, options?: ConversionOptions): number | null function getHijriQuarter(date: Date, options?: ConversionOptions): number | null;
``` ```
Get the Hijri quarter (1-4) for a date. Months 1-3 = Q1, 4-6 = Q2, 7-9 = Q3, 10-12 = Q4. Get the Hijri quarter (1-4) for a date. Months 1-3 = Q1, 4-6 = Q2, 7-9 = Q3, 10-12 = Q4.
@ -176,58 +176,58 @@ getHijriQuarter(new Date(2023, 2, 23, 12)); // 3 (Ramadan = month 9 = Q3)
### `getHijriMonthName` ### `getHijriMonthName`
```typescript ```typescript
function getHijriMonthName(hm: number, length?: 'long' | 'medium' | 'short'): string function getHijriMonthName(hm: number, length?: 'long' | 'medium' | 'short'): string;
``` ```
Get the English name of a Hijri month. Get the English name of a Hijri month.
**Parameters:** **Parameters:**
| Name | Type | Default | Description | | Name | Type | Default | Description |
| --- | --- | --- | --- | | -------- | ------------------------------- | -------- | ------------------- |
| `hm` | `number` | | Month number (1-12) | | `hm` | `number` | | Month number (1-12) |
| `length` | `'long' \| 'medium' \| 'short'` | `'long'` | Name length | | `length` | `'long' \| 'medium' \| 'short'` | `'long'` | Name length |
**Throws:** `RangeError` if `hm` is not in [1, 12]. **Throws:** `RangeError` if `hm` is not in [1, 12].
**Month names by length:** **Month names by length:**
| Month | Long | Medium | Short | | Month | Long | Medium | Short |
| --- | --- | --- | --- | | ----- | ------------- | ----------- | ----- |
| 1 | Muharram | Muharram | Muh | | 1 | Muharram | Muharram | Muh |
| 2 | Safar | Safar | Saf | | 2 | Safar | Safar | Saf |
| 3 | Rabi'l Awwal | Rabi1 | Ra1 | | 3 | Rabi'l Awwal | Rabi1 | Ra1 |
| 4 | Rabi'l Thani | Rabi2 | Ra2 | | 4 | Rabi'l Thani | Rabi2 | Ra2 |
| 5 | Jumadal Awwal | Jumada1 | Ju1 | | 5 | Jumadal Awwal | Jumada1 | Ju1 |
| 6 | Jumadal Thani | Jumada2 | Ju2 | | 6 | Jumadal Thani | Jumada2 | Ju2 |
| 7 | Rajab | Rajab | Raj | | 7 | Rajab | Rajab | Raj |
| 8 | Sha'ban | Shaban | Shb | | 8 | Sha'ban | Shaban | Shb |
| 9 | Ramadan | Ramadan | Ram | | 9 | Ramadan | Ramadan | Ram |
| 10 | Shawwal | Shawwal | Shw | | 10 | Shawwal | Shawwal | Shw |
| 11 | Dhul Qi'dah | Dhul-Qidah | DhQ | | 11 | Dhul Qi'dah | Dhul-Qidah | DhQ |
| 12 | Dhul Hijjah | Dhul-Hijjah | DhH | | 12 | Dhul Hijjah | Dhul-Hijjah | DhH |
--- ---
### `getHijriWeekdayName` ### `getHijriWeekdayName`
```typescript ```typescript
function getHijriWeekdayName(date: Date, length?: 'long' | 'short'): string function getHijriWeekdayName(date: Date, length?: 'long' | 'short'): string;
``` ```
Get the Arabic weekday name for a Gregorian date. Uses `Date.getDay()` (0 = Sunday through 6 = Saturday) as the index. Get the Arabic weekday name for a Gregorian date. Uses `Date.getDay()` (0 = Sunday through 6 = Saturday) as the index.
**Weekday names:** **Weekday names:**
| JS getDay() | Day | Long | Short | | JS getDay() | Day | Long | Short |
| --- | --- | --- | --- | | ----------- | --------- | ------------------ | ----- |
| 0 | Sunday | Yawm al-Ahad | Ahad | | 0 | Sunday | Yawm al-Ahad | Ahad |
| 1 | Monday | Yawm al-Ithnayn | Ithn | | 1 | Monday | Yawm al-Ithnayn | Ithn |
| 2 | Tuesday | Yawm ath-Thulatha' | Thul | | 2 | Tuesday | Yawm ath-Thulatha' | Thul |
| 3 | Wednesday | Yawm al-Arba`a' | Arba | | 3 | Wednesday | Yawm al-Arba`a' | Arba |
| 4 | Thursday | Yawm al-Khamis | Kham | | 4 | Thursday | Yawm al-Khamis | Kham |
| 5 | Friday | Yawm al-Jum`a | Jum`a | | 5 | Friday | Yawm al-Jum`a | Jum`a |
| 6 | Saturday | Yawm as-Sabt | Sabt | | 6 | Saturday | Yawm as-Sabt | Sabt |
--- ---
@ -236,7 +236,7 @@ Get the Arabic weekday name for a Gregorian date. Uses `Date.getDay()` (0 = Sund
### `formatHijriDate` ### `formatHijriDate`
```typescript ```typescript
function formatHijriDate(date: Date, formatStr: string, options?: ConversionOptions): string function formatHijriDate(date: Date, formatStr: string, options?: ConversionOptions): string;
``` ```
Format a Gregorian date using Hijri calendar tokens. Format a Gregorian date using Hijri calendar tokens.
@ -245,21 +245,21 @@ Returns an empty string when the date falls outside the supported range. Non-tok
**Format tokens:** **Format tokens:**
| Token | Output | Example | | Token | Output | Example |
| --- | --- | --- | | ------- | ------------------------------ | ---------------- |
| `iYYYY` | 4-digit Hijri year | `1444` | | `iYYYY` | 4-digit Hijri year | `1444` |
| `iYY` | 2-digit Hijri year | `44` | | `iYY` | 2-digit Hijri year | `44` |
| `iMMMM` | Long month name | `Ramadan` | | `iMMMM` | Long month name | `Ramadan` |
| `iMMM` | Medium month name | `Ramadan` | | `iMMM` | Medium month name | `Ramadan` |
| `iMM` | Zero-padded month (01-12) | `09` | | `iMM` | Zero-padded month (01-12) | `09` |
| `iM` | Month (1-12) | `9` | | `iM` | Month (1-12) | `9` |
| `iDD` | Zero-padded day (01-30) | `01` | | `iDD` | Zero-padded day (01-30) | `01` |
| `iD` | Day (1-30) | `1` | | `iD` | Day (1-30) | `1` |
| `iEEEE` | Long weekday name | `Yawm al-Khamis` | | `iEEEE` | Long weekday name | `Yawm al-Khamis` |
| `iEEE` | Short weekday name | `Kham` | | `iEEE` | Short weekday name | `Kham` |
| `iE` | Numeric weekday (1=Sun, 7=Sat) | `5` | | `iE` | Numeric weekday (1=Sun, 7=Sat) | `5` |
| `ioooo` | Long era | `AH` | | `ioooo` | Long era | `AH` |
| `iooo` | Short era | `AH` | | `iooo` | Short era | `AH` |
**Examples:** **Examples:**
@ -281,7 +281,7 @@ formatHijriDate(new Date(2023, 2, 23), 'iEEEE');
### `addHijriMonths` ### `addHijriMonths`
```typescript ```typescript
function addHijriMonths(date: Date, months: number, options?: ConversionOptions): Date function addHijriMonths(date: Date, months: number, options?: ConversionOptions): Date;
``` ```
Add a number of Hijri months to a Gregorian date. Add a number of Hijri months to a Gregorian date.
@ -305,7 +305,7 @@ addHijriMonths(new Date(2023, 6, 18, 12), 1);
### `addHijriYears` ### `addHijriYears`
```typescript ```typescript
function addHijriYears(date: Date, years: number, options?: ConversionOptions): Date function addHijriYears(date: Date, years: number, options?: ConversionOptions): Date;
``` ```
Add a number of Hijri years to a Gregorian date. Add a number of Hijri years to a Gregorian date.
@ -321,7 +321,7 @@ If the resulting year has fewer days in the same month (e.g., day 30 in a 29-day
### `startOfHijriMonth` ### `startOfHijriMonth`
```typescript ```typescript
function startOfHijriMonth(date: Date, options?: ConversionOptions): Date function startOfHijriMonth(date: Date, options?: ConversionOptions): Date;
``` ```
Get the first day of the Hijri month that contains the given date. Get the first day of the Hijri month that contains the given date.
@ -333,7 +333,7 @@ Get the first day of the Hijri month that contains the given date.
### `endOfHijriMonth` ### `endOfHijriMonth`
```typescript ```typescript
function endOfHijriMonth(date: Date, options?: ConversionOptions): Date function endOfHijriMonth(date: Date, options?: ConversionOptions): Date;
``` ```
Get the last day of the Hijri month that contains the given date. Get the last day of the Hijri month that contains the given date.
@ -358,7 +358,7 @@ const end = endOfHijriMonth(new Date(2023, 3, 1, 12));
### `isSameHijriMonth` ### `isSameHijriMonth`
```typescript ```typescript
function isSameHijriMonth(dateA: Date, dateB: Date, options?: ConversionOptions): boolean function isSameHijriMonth(dateA: Date, dateB: Date, options?: ConversionOptions): boolean;
``` ```
Check whether two Gregorian dates fall in the same Hijri month. Check whether two Gregorian dates fall in the same Hijri month.
@ -370,7 +370,7 @@ Returns `false` if either date is outside the supported range.
### `isSameHijriYear` ### `isSameHijriYear`
```typescript ```typescript
function isSameHijriYear(dateA: Date, dateB: Date, options?: ConversionOptions): boolean function isSameHijriYear(dateA: Date, dateB: Date, options?: ConversionOptions): boolean;
``` ```
Check whether two Gregorian dates fall in the same Hijri year. Check whether two Gregorian dates fall in the same Hijri year.

View file

@ -90,7 +90,7 @@ Month arithmetic works by converting to a total month offset from the Hijri epoc
```typescript ```typescript
const totalMonths = (h.hy - 1) * 12 + (h.hm - 1) + months; const totalMonths = (h.hy - 1) * 12 + (h.hm - 1) + months;
const newYear = Math.floor(totalMonths / 12) + 1; const newYear = Math.floor(totalMonths / 12) + 1;
const newMonth = (((totalMonths % 12) + 12) % 12) + 1; const newMonth = (((totalMonths % 12) + 12) % 12) + 1;
``` ```
@ -109,12 +109,12 @@ This handles the case where month lengths differ (29 vs 30 days) without requiri
`tsup` produces four outputs from a single source: `tsup` produces four outputs from a single source:
| File | Format | Purpose | | File | Format | Purpose |
| --- | --- | --- | | ------------------ | ----------------------- | ------------------- |
| `dist/index.cjs` | CommonJS | Node.js `require()` | | `dist/index.cjs` | CommonJS | Node.js `require()` |
| `dist/index.mjs` | ESM | `import` / bundlers | | `dist/index.mjs` | ESM | `import` / bundlers |
| `dist/index.d.ts` | TypeScript declarations | CJS consumers | | `dist/index.d.ts` | TypeScript declarations | CJS consumers |
| `dist/index.d.mts` | TypeScript declarations | ESM consumers | | `dist/index.d.mts` | TypeScript declarations | ESM consumers |
`hijri-core` is marked as external so it resolves from the consumer's `node_modules` rather than being bundled. This is required for the peer dependency pattern to work correctly. `hijri-core` is marked as external so it resolves from the consumer's `node_modules` rather than being bundled. This is required for the peer dependency pattern to work correctly.