mirror of
https://github.com/acamarata/date-fns-hijri.git
synced 2026-07-01 03:04:25 +00:00
style: fix prettier table formatting in wiki
This commit is contained in:
parent
bc32214cee
commit
f00656ee20
2 changed files with 77 additions and 77 deletions
|
|
@ -15,7 +15,7 @@ interface ConversionOptions {
|
|||
### `toHijriDate`
|
||||
|
||||
```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.
|
||||
|
|
@ -24,9 +24,9 @@ Returns `null` when the date falls outside the calendar's supported range. UAQ c
|
|||
|
||||
**Parameters:**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `date` | `Date` | A valid Gregorian date |
|
||||
| Name | Type | Description |
|
||||
| --------- | ------------------- | ----------------------------------- |
|
||||
| `date` | `Date` | A valid Gregorian date |
|
||||
| `options` | `ConversionOptions` | Optional. Calendar system selection |
|
||||
|
||||
**Returns:** `HijriDate | null`
|
||||
|
|
@ -48,7 +48,7 @@ toHijriDate(new Date(1800, 0, 1));
|
|||
### `fromHijriDate`
|
||||
|
||||
```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`.
|
||||
|
|
@ -57,11 +57,11 @@ The returned `Date` is set to midnight UTC of the equivalent Gregorian day.
|
|||
|
||||
**Parameters:**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `hy` | `number` | Hijri year |
|
||||
| `hm` | `number` | Hijri month (1-12) |
|
||||
| `hd` | `number` | Hijri day (1-30) |
|
||||
| Name | Type | Description |
|
||||
| --------- | ------------------- | ----------------------------------- |
|
||||
| `hy` | `number` | Hijri year |
|
||||
| `hm` | `number` | Hijri month (1-12) |
|
||||
| `hd` | `number` | Hijri day (1-30) |
|
||||
| `options` | `ConversionOptions` | Optional. Calendar system selection |
|
||||
|
||||
**Returns:** `Date`
|
||||
|
|
@ -87,7 +87,7 @@ fromHijriDate(1444, 13, 1);
|
|||
### `isValidHijriDate`
|
||||
|
||||
```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.
|
||||
|
|
@ -95,9 +95,9 @@ Check whether a Hijri date is valid. Verifies year, month (1-12), and day (1-day
|
|||
**Example:**
|
||||
|
||||
```typescript
|
||||
isValidHijriDate(1444, 9, 1); // true
|
||||
isValidHijriDate(1444, 13, 1); // false - no month 13
|
||||
isValidHijriDate(1444, 9, 31); // false - Ramadan has 29 or 30 days
|
||||
isValidHijriDate(1444, 9, 1); // true
|
||||
isValidHijriDate(1444, 13, 1); // false - no month 13
|
||||
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`
|
||||
|
||||
```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.
|
||||
|
|
@ -117,7 +117,7 @@ Get the Hijri year for a Gregorian date. Returns `null` when out of range.
|
|||
### `getHijriMonth`
|
||||
|
||||
```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.
|
||||
|
|
@ -127,7 +127,7 @@ Get the Hijri month (1-12) for a Gregorian date. Returns `null` when out of rang
|
|||
### `getHijriDay`
|
||||
|
||||
```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.
|
||||
|
|
@ -137,7 +137,7 @@ Get the Hijri day of month for a Gregorian date. Returns `null` when out of rang
|
|||
### `getDaysInHijriMonth`
|
||||
|
||||
```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.
|
||||
|
|
@ -156,7 +156,7 @@ getDaysInHijriMonth(1444, 1); // 30 (Muharram 1444)
|
|||
### `getHijriQuarter`
|
||||
|
||||
```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.
|
||||
|
|
@ -176,58 +176,58 @@ getHijriQuarter(new Date(2023, 2, 23, 12)); // 3 (Ramadan = month 9 = Q3)
|
|||
### `getHijriMonthName`
|
||||
|
||||
```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.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `hm` | `number` | | Month number (1-12) |
|
||||
| `length` | `'long' \| 'medium' \| 'short'` | `'long'` | Name length |
|
||||
| Name | Type | Default | Description |
|
||||
| -------- | ------------------------------- | -------- | ------------------- |
|
||||
| `hm` | `number` | | Month number (1-12) |
|
||||
| `length` | `'long' \| 'medium' \| 'short'` | `'long'` | Name length |
|
||||
|
||||
**Throws:** `RangeError` if `hm` is not in [1, 12].
|
||||
|
||||
**Month names by length:**
|
||||
|
||||
| Month | Long | Medium | Short |
|
||||
| --- | --- | --- | --- |
|
||||
| 1 | Muharram | Muharram | Muh |
|
||||
| 2 | Safar | Safar | Saf |
|
||||
| 3 | Rabi'l Awwal | Rabi1 | Ra1 |
|
||||
| 4 | Rabi'l Thani | Rabi2 | Ra2 |
|
||||
| 5 | Jumadal Awwal | Jumada1 | Ju1 |
|
||||
| 6 | Jumadal Thani | Jumada2 | Ju2 |
|
||||
| 7 | Rajab | Rajab | Raj |
|
||||
| 8 | Sha'ban | Shaban | Shb |
|
||||
| 9 | Ramadan | Ramadan | Ram |
|
||||
| 10 | Shawwal | Shawwal | Shw |
|
||||
| 11 | Dhul Qi'dah | Dhul-Qidah | DhQ |
|
||||
| 12 | Dhul Hijjah | Dhul-Hijjah | DhH |
|
||||
| Month | Long | Medium | Short |
|
||||
| ----- | ------------- | ----------- | ----- |
|
||||
| 1 | Muharram | Muharram | Muh |
|
||||
| 2 | Safar | Safar | Saf |
|
||||
| 3 | Rabi'l Awwal | Rabi1 | Ra1 |
|
||||
| 4 | Rabi'l Thani | Rabi2 | Ra2 |
|
||||
| 5 | Jumadal Awwal | Jumada1 | Ju1 |
|
||||
| 6 | Jumadal Thani | Jumada2 | Ju2 |
|
||||
| 7 | Rajab | Rajab | Raj |
|
||||
| 8 | Sha'ban | Shaban | Shb |
|
||||
| 9 | Ramadan | Ramadan | Ram |
|
||||
| 10 | Shawwal | Shawwal | Shw |
|
||||
| 11 | Dhul Qi'dah | Dhul-Qidah | DhQ |
|
||||
| 12 | Dhul Hijjah | Dhul-Hijjah | DhH |
|
||||
|
||||
---
|
||||
|
||||
### `getHijriWeekdayName`
|
||||
|
||||
```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.
|
||||
|
||||
**Weekday names:**
|
||||
|
||||
| JS getDay() | Day | Long | Short |
|
||||
| --- | --- | --- | --- |
|
||||
| 0 | Sunday | Yawm al-Ahad | Ahad |
|
||||
| 1 | Monday | Yawm al-Ithnayn | Ithn |
|
||||
| 2 | Tuesday | Yawm ath-Thulatha' | Thul |
|
||||
| 3 | Wednesday | Yawm al-Arba`a' | Arba |
|
||||
| 4 | Thursday | Yawm al-Khamis | Kham |
|
||||
| 5 | Friday | Yawm al-Jum`a | Jum`a |
|
||||
| 6 | Saturday | Yawm as-Sabt | Sabt |
|
||||
| JS getDay() | Day | Long | Short |
|
||||
| ----------- | --------- | ------------------ | ----- |
|
||||
| 0 | Sunday | Yawm al-Ahad | Ahad |
|
||||
| 1 | Monday | Yawm al-Ithnayn | Ithn |
|
||||
| 2 | Tuesday | Yawm ath-Thulatha' | Thul |
|
||||
| 3 | Wednesday | Yawm al-Arba`a' | Arba |
|
||||
| 4 | Thursday | Yawm al-Khamis | Kham |
|
||||
| 5 | Friday | Yawm al-Jum`a | Jum`a |
|
||||
| 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`
|
||||
|
||||
```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.
|
||||
|
|
@ -245,21 +245,21 @@ Returns an empty string when the date falls outside the supported range. Non-tok
|
|||
|
||||
**Format tokens:**
|
||||
|
||||
| Token | Output | Example |
|
||||
| --- | --- | --- |
|
||||
| `iYYYY` | 4-digit Hijri year | `1444` |
|
||||
| `iYY` | 2-digit Hijri year | `44` |
|
||||
| `iMMMM` | Long month name | `Ramadan` |
|
||||
| `iMMM` | Medium month name | `Ramadan` |
|
||||
| `iMM` | Zero-padded month (01-12) | `09` |
|
||||
| `iM` | Month (1-12) | `9` |
|
||||
| `iDD` | Zero-padded day (01-30) | `01` |
|
||||
| `iD` | Day (1-30) | `1` |
|
||||
| `iEEEE` | Long weekday name | `Yawm al-Khamis` |
|
||||
| `iEEE` | Short weekday name | `Kham` |
|
||||
| `iE` | Numeric weekday (1=Sun, 7=Sat) | `5` |
|
||||
| `ioooo` | Long era | `AH` |
|
||||
| `iooo` | Short era | `AH` |
|
||||
| Token | Output | Example |
|
||||
| ------- | ------------------------------ | ---------------- |
|
||||
| `iYYYY` | 4-digit Hijri year | `1444` |
|
||||
| `iYY` | 2-digit Hijri year | `44` |
|
||||
| `iMMMM` | Long month name | `Ramadan` |
|
||||
| `iMMM` | Medium month name | `Ramadan` |
|
||||
| `iMM` | Zero-padded month (01-12) | `09` |
|
||||
| `iM` | Month (1-12) | `9` |
|
||||
| `iDD` | Zero-padded day (01-30) | `01` |
|
||||
| `iD` | Day (1-30) | `1` |
|
||||
| `iEEEE` | Long weekday name | `Yawm al-Khamis` |
|
||||
| `iEEE` | Short weekday name | `Kham` |
|
||||
| `iE` | Numeric weekday (1=Sun, 7=Sat) | `5` |
|
||||
| `ioooo` | Long era | `AH` |
|
||||
| `iooo` | Short era | `AH` |
|
||||
|
||||
**Examples:**
|
||||
|
||||
|
|
@ -281,7 +281,7 @@ formatHijriDate(new Date(2023, 2, 23), 'iEEEE');
|
|||
### `addHijriMonths`
|
||||
|
||||
```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.
|
||||
|
|
@ -305,7 +305,7 @@ addHijriMonths(new Date(2023, 6, 18, 12), 1);
|
|||
### `addHijriYears`
|
||||
|
||||
```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.
|
||||
|
|
@ -321,7 +321,7 @@ If the resulting year has fewer days in the same month (e.g., day 30 in a 29-day
|
|||
### `startOfHijriMonth`
|
||||
|
||||
```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.
|
||||
|
|
@ -333,7 +333,7 @@ Get the first day of the Hijri month that contains the given date.
|
|||
### `endOfHijriMonth`
|
||||
|
||||
```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.
|
||||
|
|
@ -358,7 +358,7 @@ const end = endOfHijriMonth(new Date(2023, 3, 1, 12));
|
|||
### `isSameHijriMonth`
|
||||
|
||||
```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.
|
||||
|
|
@ -370,7 +370,7 @@ Returns `false` if either date is outside the supported range.
|
|||
### `isSameHijriYear`
|
||||
|
||||
```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.
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ Month arithmetic works by converting to a total month offset from the Hijri epoc
|
|||
|
||||
```typescript
|
||||
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;
|
||||
```
|
||||
|
||||
|
|
@ -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:
|
||||
|
||||
| File | Format | Purpose |
|
||||
| --- | --- | --- |
|
||||
| `dist/index.cjs` | CommonJS | Node.js `require()` |
|
||||
| `dist/index.mjs` | ESM | `import` / bundlers |
|
||||
| `dist/index.d.ts` | TypeScript declarations | CJS consumers |
|
||||
| `dist/index.d.mts` | TypeScript declarations | ESM consumers |
|
||||
| File | Format | Purpose |
|
||||
| ------------------ | ----------------------- | ------------------- |
|
||||
| `dist/index.cjs` | CommonJS | Node.js `require()` |
|
||||
| `dist/index.mjs` | ESM | `import` / bundlers |
|
||||
| `dist/index.d.ts` | TypeScript declarations | CJS 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.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue