can't get date of the net month
yairprog opened this issue · 1 comments
I have a significant HDate: 20, 12, 5780 [dd/mm/yyyy].
I want to get the same HDate in the next month: 20, 1, 5781 [dd/mm/yyyy].
To do that, I wrote the following code:
"let nextMonth = new Hebcal.HDate(20, 13, 5780)"
But, while it worked for me in different cases, in this case, the Hdate object I got was the 20, 12, 5780 instead of 20, 1, 5781.
This bug stems from the fixMonth function (marked in bold the relevant code):
function fixMonth(date) {
**if (date.month == months.ADAR_II && !date.isLeapYear()) {
date.month -= 1; // to Adar I
fix(date);
}**
if (date.month < 1) {
date.month += MONTH_CNT(date.year);
date.year -= 1;
fix(date);
}
if (date.month > MONTH_CNT(date.year)) {
date.month -= MONTH_CNT(date.year);
date.year += 1;
fix(date);
}
}
(Year 5780 is not a Leap year.)
I would really appreciate fixing this problem and/or providing another function that will allow me to get the HDate of the next month.
thanks!
Hi, thanks for using Hebcal. This appears to be a duplicate of #65
Please note that https://github.com/hebcal/hebcal-js is no longer actively being maintained. We recommend that you use the more actively-maintained @hebcal/core
npm package.
However, you should be able to do what you're looking for with something like this
const hd = new Hebcal.HDate(20, 12, 5780); // original date
const nextMonth = new Hebcal.HDate(hd.abs() + hd.daysInMonth());