Skip to content

Function: subHijriMonths()

@taqwim/core


@taqwim/core / subHijriMonths

subHijriMonths(date, amount): HijriDateObject

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

Substracts a specified number of Months from a Hijri date.

HijriDateObject

The Hijri date object to sub Months to.

number

The number of Months to sub.

HijriDateObject

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

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