Skip to content

Function: addHijriMonths()

@taqwim/core


@taqwim/core / addHijriMonths

addHijriMonths(date, amount): HijriDateObject

Defined in: packages/core/src/lib/addHijriMonths.ts:34

Adds a specified number of Months to a Hijri date.

HijriDateObject

The Hijri date object to add Months to.

number

The number of Months to add.

HijriDateObject

The resulting Hijri date object after adding the specified number of Months, or null if the input date is invalid.

// Add 10 Months to 1 Ramadan 1445 ({ hy: 1445, hm: 9, hd: 1 })
const result = addHijriMonths(
{ hy: 1445, hm: 9, hd: 1 },
10
);
//=> { hy: 1445, hm: 11, hd: 12 }
// Add 1 Month to 30 Ramadan 1445 ({ hy: 1445, hm: 9, hd: 30 })
const result = addHijriMonths(
{ hy: 1445, hm: 9, hd: 30 },
1
);
//=> { hy: 1445, hm: 10, hd: 29 }
// Add 26 Months to 30 Ramadan 1445 ({ hy: 1445, hm: 9, hd: 30 })
const result = addHijriMonths(
{ hy: 1445, hm: 9, hd: 30 },
26
);
//=> { hy: 1447, hm: 12, hd: 29 }