0.9.1 • Published 4 months ago

@hebcal/hdate v0.9.1

Weekly downloads
-
License
GPL-2.0
Repository
github
Last release
4 months ago

@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

Functions

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

NameTypeDefaultDescription
NISANnumber1Nissan / ניסן
IYYARnumber2Iyyar / אייר
SIVANnumber3Sivan / סיון
TAMUZnumber4Tamuz (sometimes Tammuz) / תמוז
AVnumber5Av / אב
ELULnumber6Elul / אלול
TISHREInumber7Tishrei / תִּשְׁרֵי
CHESHVANnumber8Cheshvan / חשון
KISLEVnumber9Kislev / כסלו
TEVETnumber10Tevet / טבת
SHVATnumber11Sh'vat / שבט
ADAR_Inumber12Adar or Adar Rishon / אדר
ADAR_IInumber13Adar 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

ParamTypeDescription
yearnumberHebrew year
monthnumberHebrew month
daynumberHebrew date (1-30)

abs2hebrew(abs) ⇒ SimpleHebrewDate

Converts absolute R.D. days to Hebrew date

Kind: global function

ParamTypeDescription
absnumberabsolute R.D. days

isLeapYear(year) ⇒ boolean

Returns true if Hebrew year is a leap year

Kind: global function

ParamTypeDescription
yearnumberHebrew year

monthsInYear(year) ⇒ number

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

Kind: global function

ParamTypeDescription
yearnumberHebrew year

daysInMonth(month, year) ⇒ number

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

Kind: global function

ParamTypeDescription
monthnumberHebrew month (e.g. months.TISHREI)
yearnumberHebrew year

getMonthName(month, year)

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

Kind: global function

ParamTypeDescription
monthnumberHebrew month (e.g. months.TISHREI)
yearnumberHebrew year

elapsedDays(year) ⇒ number

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

Kind: global function

ParamTypeDescription
yearnumberHebrew 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

ParamTypeDescription
yearnumberHebrew year

longCheshvan(year) ⇒ boolean

true if Cheshvan is long in Hebrew year

Kind: global function

ParamTypeDescription
yearnumberHebrew year

shortKislev(year) ⇒ boolean

true if Kislev is short in Hebrew year

Kind: global function

ParamTypeDescription
yearnumberHebrew year

monthFromName(monthName) ⇒ number

Converts Hebrew month string name to numeric

Kind: global function

ParamTypeDescription
monthNamestringmonthName

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

ParamTypeDescription
hyearnumberHebrew year
dateDate | SimpleHebrewDate | numberGregorian 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

ParamTypeDescription
hyearnumberHebrew year
dateDate | SimpleHebrewDate | numberGregorian 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

ParamType
numnumber

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

ParamType
strstring
0.9.1

4 months ago

0.9.0

5 months ago

0.8.2

5 months ago

0.8.1

5 months ago

0.8.0

5 months ago