@hebcal/hdate
TypeScript icon, indicating that this package has built-in type declarations

0.9.1 • Public • Published

@hebcal/hdate

converts between Hebrew and Gregorian dates

Build Status

Installation

$ npm install @hebcal/hdate

Synopsis

import {greg, abs2hebrew} from '@hebcal/hdate';

const date = new Date(2008, 10, 13); // 13 November 2008
const abs = greg.greg2abs(date);
const hdate = abs2hebrew(abs); // {yy: 5769, mm: CHESHVAN, dd: 15}

Members

greg

Gregorian date helper functions.

Functions

hebrew2abs(year, month, day)number

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.

abs2hebrew(abs)SimpleHebrewDate

Converts absolute R.D. days to Hebrew date

isLeapYear(year)boolean

Returns true if Hebrew year is a leap year

monthsInYear(year)number

Number of months in this Hebrew year (either 12 or 13 depending on leap year)

daysInMonth(month, year)number

Number of days in Hebrew month in a given year (29 or 30)

getMonthName(month, year)

Returns a transliterated string name of Hebrew month in year, for example 'Elul' or 'Cheshvan'.

elapsedDays(year)number

Days from sunday prior to start of Hebrew calendar to mean conjunction of Tishrei in Hebrew YEAR

daysInYear(year)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

longCheshvan(year)boolean

true if Cheshvan is long in Hebrew year

shortKislev(year)boolean

true if Kislev is short in Hebrew year

monthFromName(monthName)number

Converts Hebrew month string name to numeric

getYahrzeit(hyear, date)Date

Calculates yahrzeit. hyear must be after original date of death. Returns undefined when requested year preceeds or is same as original year.

Hebcal uses the algorithm defined in "Calendrical Calculations" by Edward M. Reingold and Nachum Dershowitz.

The customary anniversary date of a death is more complicated and depends also on the character of the year in which the first anniversary occurs. There are several cases:

  • If the date of death is Marcheshvan 30, the anniversary in general depends on the first anniversary; if that first anniversary was not Marcheshvan 30, use the day before Kislev 1.
  • If the date of death is Kislev 30, the anniversary in general again depends on the first anniversary — if that was not Kislev 30, use the day before Tevet 1.
  • If the date of death is Adar II, the anniversary is the same day in the last month of the Hebrew year (Adar or Adar II).
  • If the date of death is Adar I 30, the anniversary in a Hebrew year that is not a leap year (in which Adar only has 29 days) is the last day in Shevat.
  • In all other cases, use the normal (that is, same month number) anniversary of the date of death. [Calendrical Calculations p. 113]
getBirthdayOrAnniversary(hyear, date)Date

Calculates a birthday or anniversary (non-yahrzeit). hyear must be after original date of anniversary. Returns undefined when requested year preceeds or is same as original year.

Hebcal uses the algorithm defined in "Calendrical Calculations" by Edward M. Reingold and Nachum Dershowitz.

The birthday of someone born in Adar of an ordinary year or Adar II of a leap year is also always in the last month of the year, be that Adar or Adar II. The birthday in an ordinary year of someone born during the first 29 days of Adar I in a leap year is on the corresponding day of Adar; in a leap year, the birthday occurs in Adar I, as expected.

Someone born on the thirtieth day of Marcheshvan, Kislev, or Adar I has his birthday postponed until the first of the following month in years where that day does not occur. [Calendrical Calculations p. 111]

gematriya(num)string

Converts a numerical value to a string of Hebrew letters.

When specifying years of the Hebrew calendar in the present millennium, we omit the thousands (which is presently 5 [ה]).

gematriyaStrToNum(str)number

Converts a string of Hebrew letters to a numerical value.

Only considers the value of Hebrew letters א through ת. Ignores final Hebrew letters such as ך (kaf sofit) or ם (mem sofit) and vowels (nekudot).

greg

Gregorian date helper functions.

Kind: global variable

months : enum

Hebrew months of the year (NISAN=1, TISHREI=7)

Kind: global enum
Read only: true
Properties

Name Type Default Description
NISAN number 1 Nissan / ניסן
IYYAR number 2 Iyyar / אייר
SIVAN number 3 Sivan / סיון
TAMUZ number 4 Tamuz (sometimes Tammuz) / תמוז
AV number 5 Av / אב
ELUL number 6 Elul / אלול
TISHREI number 7 Tishrei / תִּשְׁרֵי
CHESHVAN number 8 Cheshvan / חשון
KISLEV number 9 Kislev / כסלו
TEVET number 10 Tevet / טבת
SHVAT number 11 Sh'vat / שבט
ADAR_I number 12 Adar or Adar Rishon / אדר
ADAR_II number 13 Adar Sheini (only on leap years) / אדר ב׳

hebrew2abs(year, month, day) ⇒ number

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.

Kind: global function

Param Type Description
year number Hebrew year
month number Hebrew month
day number Hebrew date (1-30)

abs2hebrew(abs) ⇒ SimpleHebrewDate

Converts absolute R.D. days to Hebrew date

Kind: global function

Param Type Description
abs number absolute R.D. days

isLeapYear(year) ⇒ boolean

Returns true if Hebrew year is a leap year

Kind: global function

Param Type Description
year number Hebrew year

monthsInYear(year) ⇒ number

Number of months in this Hebrew year (either 12 or 13 depending on leap year)

Kind: global function

Param Type Description
year number Hebrew year

daysInMonth(month, year) ⇒ number

Number of days in Hebrew month in a given year (29 or 30)

Kind: global function

Param Type Description
month number Hebrew month (e.g. months.TISHREI)
year number Hebrew year

getMonthName(month, year)

Returns a transliterated string name of Hebrew month in year, for example 'Elul' or 'Cheshvan'.

Kind: global function

Param Type Description
month number Hebrew month (e.g. months.TISHREI)
year number Hebrew year

elapsedDays(year) ⇒ number

Days from sunday prior to start of Hebrew calendar to mean conjunction of Tishrei in Hebrew YEAR

Kind: global function

Param Type Description
year number Hebrew year

daysInYear(year) ⇒ 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

Kind: global function

Param Type Description
year number Hebrew year

longCheshvan(year) ⇒ boolean

true if Cheshvan is long in Hebrew year

Kind: global function

Param Type Description
year number Hebrew year

shortKislev(year) ⇒ boolean

true if Kislev is short in Hebrew year

Kind: global function

Param Type Description
year number Hebrew year

monthFromName(monthName) ⇒ number

Converts Hebrew month string name to numeric

Kind: global function

Param Type Description
monthName string monthName

getYahrzeit(hyear, date) ⇒ Date

Calculates yahrzeit. hyear must be after original date of death. Returns undefined when requested year preceeds or is same as original year.

Hebcal uses the algorithm defined in "Calendrical Calculations" by Edward M. Reingold and Nachum Dershowitz.

The customary anniversary date of a death is more complicated and depends also on the character of the year in which the first anniversary occurs. There are several cases:

  • If the date of death is Marcheshvan 30, the anniversary in general depends on the first anniversary; if that first anniversary was not Marcheshvan 30, use the day before Kislev 1.
  • If the date of death is Kislev 30, the anniversary in general again depends on the first anniversary — if that was not Kislev 30, use the day before Tevet 1.
  • If the date of death is Adar II, the anniversary is the same day in the last month of the Hebrew year (Adar or Adar II).
  • If the date of death is Adar I 30, the anniversary in a Hebrew year that is not a leap year (in which Adar only has 29 days) is the last day in Shevat.
  • In all other cases, use the normal (that is, same month number) anniversary of the date of death. [Calendrical Calculations p. 113]

Kind: global function
Returns: Date - anniversary occurring in hyear

Param Type Description
hyear number Hebrew year
date Date | SimpleHebrewDate | number Gregorian or Hebrew date of death

Example

import {getYahrzeit} from '@hebcal/hdate';
const dt = new Date(2014, 2, 2); // '2014-03-02' == '30 Adar I 5774'
const anniversary = getYahrzeit(5780, dt); // '2/25/2020' == '30 Sh\'vat 5780'

getBirthdayOrAnniversary(hyear, date) ⇒ Date

Calculates a birthday or anniversary (non-yahrzeit). hyear must be after original date of anniversary. Returns undefined when requested year preceeds or is same as original year.

Hebcal uses the algorithm defined in "Calendrical Calculations" by Edward M. Reingold and Nachum Dershowitz.

The birthday of someone born in Adar of an ordinary year or Adar II of a leap year is also always in the last month of the year, be that Adar or Adar II. The birthday in an ordinary year of someone born during the first 29 days of Adar I in a leap year is on the corresponding day of Adar; in a leap year, the birthday occurs in Adar I, as expected.

Someone born on the thirtieth day of Marcheshvan, Kislev, or Adar I has his birthday postponed until the first of the following month in years where that day does not occur. [Calendrical Calculations p. 111]

Kind: global function
Returns: Date - anniversary occurring in hyear

Param Type Description
hyear number Hebrew year
date Date | SimpleHebrewDate | number Gregorian or Hebrew date of event

Example

import {getBirthdayOrAnniversary} from '@hebcal/hdate';
const dt = new Date(2014, 2, 2); // '2014-03-02' == '30 Adar I 5774'
const anniversary = getBirthdayOrAnniversary(5780, dt); // '3/26/2020' == '1 Nisan 5780'

gematriya(num) ⇒ string

Converts a numerical value to a string of Hebrew letters.

When specifying years of the Hebrew calendar in the present millennium, we omit the thousands (which is presently 5 [ה]).

Kind: global function

Param Type
num number

Example

gematriya(5774) // 'תשע״ד' - cropped to 774
gematriya(25) // 'כ״ה'
gematriya(60) // 'ס׳'
gematriya(3761) // 'ג׳תשס״א'
gematriya(1123) // 'א׳קכ״ג'

gematriyaStrToNum(str) ⇒ number

Converts a string of Hebrew letters to a numerical value.

Only considers the value of Hebrew letters א through ת. Ignores final Hebrew letters such as ך (kaf sofit) or ם (mem sofit) and vowels (nekudot).

Kind: global function

Param Type
str string

Package Sidebar

Install

npm i @hebcal/hdate

Weekly Downloads

38

Version

0.9.1

License

GPL-2.0

Unpacked Size

96.5 kB

Total Files

18

Last publish

Collaborators

  • mjradwin