UNPKG

@hebcal/hdate

Version:

converts between Hebrew and Gregorian dates using Rata Die (R.D.) algorithm by Dershowitz and Reingold

152 lines (151 loc) 4.98 kB
/** * Hebrew months of the year (NISAN=1, TISHREI=7) * @readonly * @enum {number} */ export declare const months: { /** Nissan / ניסן */ readonly NISAN: 1; /** Iyyar / אייר */ readonly IYYAR: 2; /** Sivan / סיון */ readonly SIVAN: 3; /** Tamuz (sometimes Tammuz) / תמוז */ readonly TAMUZ: 4; /** Av / אב */ readonly AV: 5; /** Elul / אלול */ readonly ELUL: 6; /** Tishrei / תִּשְׁרֵי */ readonly TISHREI: 7; /** Cheshvan / חשון */ readonly CHESHVAN: 8; /** Kislev / כסלו */ readonly KISLEV: 9; /** Tevet / טבת */ readonly TEVET: 10; /** Sh'vat / שבט */ readonly SHVAT: 11; /** Adar or Adar Rishon / אדר */ readonly ADAR_I: 12; /** Adar Sheini (only on leap years) / אדר ב׳ */ readonly ADAR_II: 13; }; /** Transliterated Hebrew month names. */ export type MonthName = 'Nisan' | 'Iyyar' | 'Sivan' | 'Tamuz' | 'Av' | 'Elul' | 'Tishrei' | 'Cheshvan' | 'Kislev' | 'Tevet' | "Sh'vat" | 'Adar' | 'Adar I' | 'Adar II'; /** * Converts Hebrew date to R.D. (Rata Die) fixed days. * R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian * Calendar. * @param year Hebrew year * @param month Hebrew month * @param day Hebrew date (1-30) * @example * import {hebrew2abs, months} from '@hebcal/hdate'; * hebrew2abs(5769, months.CHESHVAN, 15); // 733359 */ export declare function hebrew2abs(year: number, month: number, day: number): number; /** * Convenience wrapper for `hebrew2abs` that accepts a * `SimpleHebrewDate` (`{yy, mm, dd}`) rather than three separate * arguments. Returns the same R.D. (Rata Die) day number. * @example * import {hd2abs, months} from '@hebcal/hdate'; * hd2abs({yy: 5769, mm: months.CHESHVAN, dd: 15}); // 733359 */ export declare function hd2abs(hdate: SimpleHebrewDate): number; export type SimpleHebrewDate = { /** Hebrew year */ yy: number; /** Hebrew month of year (1=NISAN, 7=TISHREI) */ mm: number; /** Day of month (1-30) */ dd: number; }; /** * Converts absolute R.D. days to Hebrew date * @param abs absolute R.D. days * @example * abs2hebrew(733359); // {yy: 5769, mm: 8, dd: 15} (15 Cheshvan 5769) */ export declare function abs2hebrew(abs: number): SimpleHebrewDate; /** * Returns true if Hebrew year is a leap year * @param year Hebrew year * @example * isLeapYear(5783); // false * isLeapYear(5784); // true */ export declare function isLeapYear(year: number): boolean; /** * Number of months in this Hebrew year (either 12 or 13 depending on leap year) * @param year Hebrew year * @example * monthsInYear(5783); // 12 * monthsInYear(5784); // 13 */ export declare function monthsInYear(year: number): number; /** * Number of days in Hebrew month in a given year (29 or 30) * @param month Hebrew month (e.g. months.TISHREI) * @param year Hebrew year * @example * import {daysInMonth, months} from '@hebcal/hdate'; * daysInMonth(months.CHESHVAN, 5769); // 29 * daysInMonth(months.KISLEV, 5769); // 30 */ export declare function daysInMonth(month: number, year: number): number; /** * Returns a transliterated string name of Hebrew month in year, * for example 'Elul' or 'Cheshvan'. * @param month Hebrew month (e.g. months.TISHREI) * @param year Hebrew year * @example * import {getMonthName, months} from '@hebcal/hdate'; * getMonthName(months.CHESHVAN, 5769); // 'Cheshvan' * getMonthName(months.ADAR_I, 5784); // 'Adar I' (leap year) * getMonthName(months.ADAR_I, 5783); // 'Adar' (common year) */ export declare function getMonthName(month: number, year: number): MonthName; /** * Days from sunday prior to start of Hebrew calendar to mean * conjunction of Tishrei in Hebrew YEAR * @param year Hebrew year */ export declare function elapsedDays(year: number): number; /** * Number of days in the hebrew YEAR. * A common Hebrew calendar year can have a length of 353, 354 or 355 days * A leap Hebrew calendar year can have a length of 383, 384 or 385 days * @param year Hebrew year * @example * daysInYear(5783); // 355 * daysInYear(5784); // 383 (leap year) */ export declare function daysInYear(year: number): number; /** * true if Cheshvan is long in Hebrew year * @param year Hebrew year * @example * longCheshvan(5783); // true * longCheshvan(5784); // false */ export declare function longCheshvan(year: number): boolean; /** * true if Kislev is short in Hebrew year * @param year Hebrew year * @example * shortKislev(5783); // false * shortKislev(5784); // true */ export declare function shortKislev(year: number): boolean; /** * Converts Hebrew month string name to numeric * @param monthName monthName * @example * monthFromName('Cheshvan'); // 8 * monthFromName('חשון'); // 8 * monthFromName('Adar II'); // 13 * monthFromName(7); // 7 (passthrough) */ export declare function monthFromName(monthName: string | number): number;