mirror of
https://github.com/acamarata/date-fns-hijri.git
synced 2026-06-30 18:54:25 +00:00
chore: CR/QA polish for v1.0.0 release
Fix documentation style (no em dashes). Update hijri-core devDep from file: path to ^1.0.0.
This commit is contained in:
parent
467506bb05
commit
536f1c5189
6 changed files with 19 additions and 19 deletions
|
|
@ -20,7 +20,7 @@ function toHijriDate(date: Date, options?: ConversionOptions): HijriDate | null
|
|||
|
||||
Convert a Gregorian `Date` to a Hijri date object.
|
||||
|
||||
Returns `null` when the date falls outside the calendar's supported range. UAQ covers 1356-1500 AH (approximately 1937-2077 CE).
|
||||
Returns `null` when the date falls outside the calendar's supported range. UAQ covers 1318-1500 AH (approximately 1900-2076 CE).
|
||||
|
||||
**Parameters:**
|
||||
|
||||
|
|
@ -37,10 +37,10 @@ Returns `null` when the date falls outside the calendar's supported range. UAQ c
|
|||
import { toHijriDate } from 'date-fns-hijri';
|
||||
|
||||
toHijriDate(new Date(2023, 2, 23, 12));
|
||||
// { hy: 1444, hm: 9, hd: 1 } — 1 Ramadan 1444
|
||||
// { hy: 1444, hm: 9, hd: 1 } - 1 Ramadan 1444
|
||||
|
||||
toHijriDate(new Date(1800, 0, 1));
|
||||
// null — out of range
|
||||
// null - out of range
|
||||
```
|
||||
|
||||
---
|
||||
|
|
@ -96,8 +96,8 @@ Check whether a Hijri date is valid. Verifies year, month (1-12), and day (1-day
|
|||
|
||||
```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, 13, 1); // false - no month 13
|
||||
isValidHijriDate(1444, 9, 31); // false - Ramadan has 29 or 30 days
|
||||
```
|
||||
|
||||
---
|
||||
|
|
@ -205,7 +205,7 @@ Get the English name of a Hijri month.
|
|||
| 9 | Ramadan | Ramadan | Ram |
|
||||
| 10 | Shawwal | Shawwal | Shw |
|
||||
| 11 | Dhul Qi'dah | Dhul-Qidah | DhQ |
|
||||
| 12 | Dhul Hijjah | Dhul-Hijah | DhH |
|
||||
| 12 | Dhul Hijjah | Dhul-Hijjah | DhH |
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ const eid = addHijriMonths(new Date(2023, 2, 23, 12), 1);
|
|||
pnpm add date-fns-hijri hijri-core
|
||||
```
|
||||
|
||||
`hijri-core` is a peer dependency — install it alongside this package.
|
||||
`hijri-core` is a peer dependency. Install it alongside this package.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ pnpm add date-fns-hijri hijri-core
|
|||
|
||||
Two calendar systems are built in:
|
||||
|
||||
- **UAQ (default):** Umm al-Qura. Official Saudi Arabia calendar. Tabular data covering 1356-1500 AH. Deterministic.
|
||||
- **UAQ (default):** Umm al-Qura. Official Saudi Arabia calendar. Tabular data covering 1318-1500 AH (1900-2076 CE). Deterministic.
|
||||
- **FCNA:** Fiqh Council of North America. Astronomical calculation. Extends slightly beyond UAQ's range.
|
||||
|
||||
Switch calendar system with the `options` argument:
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import {
|
|||
|
||||
// Convert a Gregorian date to Hijri
|
||||
const hijri = toHijriDate(new Date(2023, 2, 23));
|
||||
// { hy: 1444, hm: 9, hd: 1 } — 1 Ramadan 1444
|
||||
// { hy: 1444, hm: 9, hd: 1 } - 1 Ramadan 1444
|
||||
|
||||
// Convert back
|
||||
const gregorian = fromHijriDate(1444, 9, 1);
|
||||
|
|
@ -114,7 +114,7 @@ All functions accept an optional `options` argument for selecting the calendar s
|
|||
Two calendar systems are available via the `options.calendar` property.
|
||||
|
||||
**Umm al-Qura (default):**
|
||||
The official calendar of Saudi Arabia. Covers 1356–1500 AH. Tabular data; deterministic.
|
||||
The official calendar of Saudi Arabia. Covers 1318–1500 AH (1900–2076 CE). Tabular data; deterministic.
|
||||
|
||||
```typescript
|
||||
import { toHijriDate } from 'date-fns-hijri';
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"hijri-core": "file:../hijri-core",
|
||||
"hijri-core": "^1.0.0",
|
||||
"tsup": "^8.0.0",
|
||||
"typescript": "^5.5.0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ importers:
|
|||
specifier: ^22.0.0
|
||||
version: 22.19.11
|
||||
hijri-core:
|
||||
specifier: file:../hijri-core
|
||||
version: file:../hijri-core
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
tsup:
|
||||
specifier: ^8.0.0
|
||||
version: 8.5.1(typescript@5.9.3)
|
||||
|
|
@ -400,8 +400,8 @@ packages:
|
|||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||
os: [darwin]
|
||||
|
||||
hijri-core@file:../hijri-core:
|
||||
resolution: {directory: ../hijri-core, type: directory}
|
||||
hijri-core@1.0.0:
|
||||
resolution: {integrity: sha512-wImBZLBKbEWEEUE1nrc1CFY/uvx4XjGNWYChImJZlswXIVhrBCzSVaj6DP1AU2gUMJ6KDh2ygXo/u/Qx232CXA==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
joycon@3.1.1:
|
||||
|
|
@ -785,7 +785,7 @@ snapshots:
|
|||
fsevents@2.3.3:
|
||||
optional: true
|
||||
|
||||
hijri-core@file:../hijri-core: {}
|
||||
hijri-core@1.0.0: {}
|
||||
|
||||
joycon@3.1.1: {}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import type { HijriDate, ConversionOptions } from './types';
|
|||
* Convert a Gregorian `Date` to a Hijri date object.
|
||||
*
|
||||
* Returns `null` when the date falls outside the calendar's supported range
|
||||
* (UAQ: 1356–1500 AH; FCNA extends slightly further).
|
||||
* (UAQ: 1318–1500 AH / 1900–2076 CE; FCNA extends slightly further).
|
||||
*/
|
||||
export function toHijriDate(date: Date, options?: ConversionOptions): HijriDate | null {
|
||||
return coreToHijri(date, options);
|
||||
|
|
@ -104,7 +104,7 @@ export function getHijriDay(date: Date, options?: ConversionOptions): number | n
|
|||
/**
|
||||
* Get the number of days in a Hijri month (29 or 30).
|
||||
*
|
||||
* @throws {Error} If the year/month combination is outside the calendar's range.
|
||||
* @throws {RangeError} If the year is outside the calendar's supported range.
|
||||
*/
|
||||
export function getDaysInHijriMonth(
|
||||
hy: number,
|
||||
|
|
@ -159,7 +159,7 @@ export function getHijriWeekdayName(
|
|||
// Formatting
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** Ordered token pattern — longer tokens must appear before shorter prefixes. */
|
||||
/** Ordered token pattern: longer tokens appear before shorter prefixes to avoid partial matches. */
|
||||
const TOKEN_RE = /iYYYY|iYY|iMMMM|iMMM|iMM|iM|iDD|iD|iEEEE|iEEE|iE|ioooo|iooo/g;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue