Closed PupaRebbe closed 3 months ago
Static functions should be called on the HDate
class itself and not on an instance of the class.
const {HDate} = require('@hebcal/core');
const year = 5784;
console.log(HDate.monthsInYear(year));
console.log(HDate.monthNum(3));
console.log(HDate.daysInYear(year));
console.log(HDate.longCheshvan(year));
console.log(HDate.shortKislev(year));
console.log(HDate.monthFromName('SIVAN'));
console.log(HDate.isHDate(new HDate()));
console.log(HDate.isHDate(new Date()));
console.log(HDate.isHDate(12345));
console.log(HDate.isHDate('Hello'));
Interesting because there are other functions categorized as static in the readme and they work on an instance.
const hd = new HDate();
console.log(hd.isLeapYear(hd.getFullYear()));
console.log(hd.daysInMonth(hd.getMonth(), hd.getFullYear()));
console.log(hd.getMonthName(hd.getMonth(), hd.getFullYear()));
Please note carefully that for some functions like isLeapYear, there are both instance and static class functions. If you read carefully, you will also note that there is a difference in how many parameters each function accepts
https://github.com/hebcal/hebcal-es6/blob/main/README.md#HDate+isLeapYear
boolean
Tests if this date occurs during a leap year
Kind: instance method of HDate
https://github.com/hebcal/hebcal-es6/blob/main/README.md#HDate.isLeapYear
boolean
Returns true if Hebrew year is a leap year
Kind: static method of HDate
Param | Type | Description |
---|---|---|
year | number |
Hebrew year |
When i run any of these functions it throws a TypeError: hd.[funcName] is not a function. The functions do exist in the source code, but seem to be private. Am i missing something?