@hebcal/hdate
Version:
converts between Hebrew and Gregorian dates using Rata Die (R.D.) algorithm by Dershowitz and Reingold
57 lines (56 loc) • 2.15 kB
TypeScript
/**
* Returns true if the Gregorian year is a leap year
* @param year Gregorian year
* @example
* isGregLeapYear(2000); // true
* isGregLeapYear(2020); // true
* isGregLeapYear(2023); // false
* isGregLeapYear(2100); // false (divisible by 100 but not 400)
*/
export declare function isGregLeapYear(year: number): boolean;
/**
* Number of days in the Gregorian month for given year
* @param month Gregorian month (1=January, 12=December)
* @param year Gregorian year
* @example
* daysInGregMonth(2, 2024); // 29 (February in a leap year)
* daysInGregMonth(2, 2023); // 28
* daysInGregMonth(7, 2024); // 31 (July)
*/
export declare function daysInGregMonth(month: number, year: number): number;
/**
* Returns true if the object is a Javascript Date
* @example
* isDate(new Date()); // true
* isDate('2024-01-01'); // false
* isDate(1700000000000); // false
*/
export declare function isDate(obj: unknown): boolean;
/**
* Converts Gregorian date to absolute R.D. (Rata Die) days
* @param date Gregorian date
* @example
* greg2abs(new Date(2008, 10, 13)); // 733359 (13 November 2008)
* greg2abs(new Date(2005, 3, 2)); // 732038 (2 April 2005)
*/
export declare function greg2abs(date: Date): number;
/**
* Converts from Rata Die (R.D. number) to Gregorian date.
* See the footnote on page 384 of ``Calendrical Calculations, Part II:
* Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
* Clamen, Software--Practice and Experience, Volume 23, Number 4
* (April, 1993), pages 383-404 for an explanation.
*
* Note that this function returns the daytime portion of the date.
* For example, the 15th of Cheshvan 5769 began at sundown on
* 12 November 2008 and continues through 13 November 2008. This
* function would return only the date 13 November 2008.
* @param abs - R.D. number of days
* @example
* const abs = hebrew2abs(5769, months.CHESHVAN, 15);
* const date = abs2greg(abs); // 13 November 2008
* const year = date.getFullYear(); // 2008
* const monthNum = date.getMonth() + 1; // 11
* const day = date.getDate(); // 13
*/
export declare function abs2greg(abs: number): Date;