Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hebcal/hdate

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hebcal/hdate

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

  • 0.9.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
132
decreased by-89.54%
Maintainers
1
Weekly downloads
 
Created
Source

@hebcal/hdate

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

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}

Classes

HDate

Represents a Hebrew date

Locale

A locale in Hebcal is used for translations/transliterations of holidays. @hebcal/hdate supports four locales by default

  • en - default, Sephardic transliterations (e.g. "Shabbat")
  • ashkenazi - Ashkenazi transliterations (e.g. "Shabbos")
  • he - Hebrew (e.g. "שַׁבָּת")
  • he-x-NoNikud - Hebrew without nikud (e.g. "שבת")
Sedra

Represents Parashah HaShavua for an entire Hebrew year

Members

greg

Gregorian date helper functions.

parshiot : Array.<string>

The 54 parshiyot of the Torah as transilterated strings parshiot[0] == 'Bereshit', parshiot[1] == 'Noach', parshiot[52] == "Ha'azinu".

Functions

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]

getPseudoISO(tzid, date)string

Returns a string similar to Date.toISOString() but in the timezone tzid. Contrary to the typical meaning of Z at the end of the string, this is not actually a UTC date.

getTimezoneOffset(tzid, date)number

Returns number of minutes tzid is offset from UTC on date date.

pad4(number)string

Formats a number with leading zeros so the resulting string is 4 digits long. Similar to string.padStart(4, '0') but will also format negative numbers similar to how the JavaScript date formats negative year numbers (e.g. -37 is formatted as -000037).

pad2(number)string

Formats a number with leading zeros so the resulting string is 2 digits long. Similar to string.padStart(2, '0').

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).

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.

hd2abs()

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

molad()

Calculates the molad for a Hebrew month

omerSefira(omerDay, lang)

Returns the sefira. For example, on day 8 חֶֽסֶד שֶׁבִּגְבוּרָה Chesed shebiGevurah Lovingkindness within Might

omerTodayIs(omerDay, lang)

Returns a sentence with that evening's omer count

omerEmoji(omerDay)

Returns an emoji number symbol with a circle, for example from the “Enclosed CJK Letters and Months” block of the Unicode standard

HDate

Represents a Hebrew date

Kind: global class

new HDate([day], [month], [year])

Create a Hebrew date. There are 3 basic forms for the HDate() constructor.

  1. No parameters - represents the current Hebrew date at time of instantiation
  2. One parameter
    • Date - represents the Hebrew date corresponding to the Gregorian date using local time. Hours, minutes, seconds and milliseconds are ignored.
    • HDate - clones a copy of the given Hebrew date
    • number - Converts absolute R.D. days to Hebrew date. R.D. 1 == the imaginary date January 1, 1 (Gregorian)
  3. Three parameters: Hebrew day, Hebrew month, Hebrew year. Hebrew day should be a number between 1-30, Hebrew month can be a number or string, and Hebrew year is always a number.
ParamTypeDescription
[day]number | Date | HDateDay of month (1-30) if a number. If a Date is specified, represents the Hebrew date corresponding to the Gregorian date using local time. If an HDate is specified, clones a copy of the given Hebrew date.
[month]number | stringHebrew month of year (1=NISAN, 7=TISHREI)
[year]numberHebrew year

Example

import {HDate, months} from '@hebcal/hdate';

const hd1 = new HDate();
const hd2 = new HDate(new Date(2008, 10, 13));
const hd3 = new HDate(15, 'Cheshvan', 5769);
const hd4 = new HDate(15, months.CHESHVAN, 5769);
const hd5 = new HDate(733359); // ==> 15 Cheshvan 5769
const monthName = 'אייר';
const hd6 = new HDate(5, monthName, 5773);

hDate.getFullYear() ⇒ number

Gets the Hebrew year of this Hebrew date

Kind: instance method of HDate

hDate.isLeapYear() ⇒ boolean

Tests if this date occurs during a leap year

Kind: instance method of HDate

hDate.getMonth() ⇒ number

Gets the Hebrew month (1=NISAN, 7=TISHREI) of this Hebrew date

Kind: instance method of HDate

hDate.getTishreiMonth() ⇒ number

The Tishrei-based month of the date. 1 is Tishrei, 7 is Nisan, 13 is Elul in a leap year

Kind: instance method of HDate

hDate.daysInMonth() ⇒ number

Number of days in the month of this Hebrew date

Kind: instance method of HDate

hDate.getDate() ⇒ number

Gets the day within the month (1-30)

Kind: instance method of HDate

hDate.getDay() ⇒ number

Gets the day of the week. 0=Sunday, 6=Saturday

Kind: instance method of HDate

hDate.greg() ⇒ Date

Converts to Gregorian date

Kind: instance method of HDate

hDate.abs() ⇒ number

Returns R.D. (Rata Die) fixed days. R.D. 1 == Monday, January 1, 1 (Gregorian) Note also that R.D. = Julian Date − 1,721,424.5 https://en.wikipedia.org/wiki/Rata_Die#Dershowitz_and_Reingold

Kind: instance method of HDate

hDate.getMonthName() ⇒ string

Returns a transliterated Hebrew month name, e.g. 'Elul' or 'Cheshvan'.

Kind: instance method of HDate

hDate.render([locale], [showYear]) ⇒ string

Renders this Hebrew date as a translated or transliterated string, including ordinal e.g. '15th of Cheshvan, 5769'.

Kind: instance method of HDate

ParamTypeDefaultDescription
[locale]stringOptional locale name (defaults to active locale).
[showYear]booleantrueDisplay year (defaults to true).

Example

import {HDate, months} from '@hebcal/hdate';

const hd = new HDate(15, months.CHESHVAN, 5769);
console.log(hd.render('en')); // '15th of Cheshvan, 5769'
console.log(hd.render('he')); // '15 חֶשְׁוָן, 5769'

hDate.renderGematriya([suppressNikud]) ⇒ string

Renders this Hebrew date in Hebrew gematriya, regardless of locale.

Kind: instance method of HDate

ParamTypeDefault
[suppressNikud]booleanfalse

Example

import {HDate, months} from '@hebcal/hdate';
const hd = new HDate(15, months.CHESHVAN, 5769);
console.log(hd.renderGematriya()); // 'ט״ו חֶשְׁוָן תשס״ט'

hDate.before(dow) ⇒ HDate

Returns an HDate representing the a dayNumber before the current date. Sunday=0, Saturday=6

Kind: instance method of HDate

ParamTypeDescription
downumberday of week

Example

new HDate(new Date('Wednesday February 19, 2014')).before(6).greg() // Sat Feb 15 2014

hDate.onOrBefore(dow) ⇒ HDate

Returns an HDate representing the a dayNumber on or before the current date. Sunday=0, Saturday=6

Kind: instance method of HDate

ParamTypeDescription
downumberday of week

Example

new HDate(new Date('Wednesday February 19, 2014')).onOrBefore(6).greg() // Sat Feb 15 2014
new HDate(new Date('Saturday February 22, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014
new HDate(new Date('Sunday February 23, 2014')).onOrBefore(6).greg() // Sat Feb 22 2014

hDate.nearest(dow) ⇒ HDate

Returns an HDate representing the nearest dayNumber to the current date Sunday=0, Saturday=6

Kind: instance method of HDate

ParamTypeDescription
downumberday of week

Example

new HDate(new Date('Wednesday February 19, 2014')).nearest(6).greg() // Sat Feb 22 2014
new HDate(new Date('Tuesday February 18, 2014')).nearest(6).greg() // Sat Feb 15 2014

hDate.onOrAfter(dow) ⇒ HDate

Returns an HDate representing the a dayNumber on or after the current date. Sunday=0, Saturday=6

Kind: instance method of HDate

ParamTypeDescription
downumberday of week

Example

new HDate(new Date('Wednesday February 19, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
new HDate(new Date('Saturday February 22, 2014')).onOrAfter(6).greg() // Sat Feb 22 2014
new HDate(new Date('Sunday February 23, 2014')).onOrAfter(6).greg() // Sat Mar 01 2014

hDate.after(dow) ⇒ HDate

Returns an HDate representing the a dayNumber after the current date. Sunday=0, Saturday=6

Kind: instance method of HDate

ParamTypeDescription
downumberday of week

Example

new HDate(new Date('Wednesday February 19, 2014')).after(6).greg() // Sat Feb 22 2014
new HDate(new Date('Saturday February 22, 2014')).after(6).greg() // Sat Mar 01 2014
new HDate(new Date('Sunday February 23, 2014')).after(6).greg() // Sat Mar 01 2014

hDate.next() ⇒ HDate

Returns the next Hebrew date

Kind: instance method of HDate

hDate.prev() ⇒ HDate

Returns the previous Hebrew date

Kind: instance method of HDate

hDate.add(amount, [units]) ⇒ HDate

Returns a cloned HDate object with a specified amount of time added

Units are case insensitive, and support plural and short forms. Note, short forms are case sensitive.

UnitShorthandDescription
dayddays
weekwweeks
monthMmonths
yearyyears

Kind: instance method of HDate

ParamTypeDefault
amountnumber
[units]string"d"

hDate.subtract(amount, [units]) ⇒ HDate

Returns a cloned HDate object with a specified amount of time subracted

Units are case insensitive, and support plural and short forms. Note, short forms are case sensitive.

UnitShorthandDescription
dayddays
weekwweeks
monthMmonths
yearyyears

Kind: instance method of HDate

ParamTypeDefault
amountnumber
[units]string"d"

Example

import {HDate, months} from '@hebcal/hdate';

const hd1 = new HDate(15, months.CHESHVAN, 5769);
const hd2 = hd1.add(1, 'weeks'); // 7 Kislev 5769
const hd3 = hd1.add(-3, 'M'); // 30 Av 5768

hDate.deltaDays(other) ⇒ number

Returns the difference in days between the two given HDates.

The result is positive if this date is comes chronologically after the other date, and negative if the order of the two dates is reversed.

The result is zero if the two dates are identical.

Kind: instance method of HDate

ParamTypeDescription
otherHDateHebrew date to compare

Example

import {HDate, months} from '@hebcal/hdate';

const hd1 = new HDate(25, months.KISLEV, 5770);
const hd2 = new HDate(15, months.CHESHVAN, 5769);
const days = hd1.deltaDays(hd2); // 394

hDate.isSameDate(other) ⇒ boolean

Compares this date to another date, returning true if the dates match.

Kind: instance method of HDate

ParamTypeDescription
otherHDateHebrew date to compare

hDate.toString() ⇒ string

Kind: instance method of HDate

HDate.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: static method of HDate

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

HDate.isLeapYear(year) ⇒ boolean

Returns true if Hebrew year is a leap year

Kind: static method of HDate

ParamTypeDescription
yearnumberHebrew year

HDate.monthsInYear(year) ⇒ number

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

Kind: static method of HDate

ParamTypeDescription
yearnumberHebrew year

HDate.daysInMonth(month, year) ⇒ number

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

Kind: static method of HDate

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

HDate.getMonthName(month, year) ⇒ string

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

Kind: static method of HDate

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

HDate.monthNum(month) ⇒ number

Returns the Hebrew month number (NISAN=1, TISHREI=7)

Kind: static method of HDate

ParamTypeDescription
monthnumber | stringA number, or Hebrew month name string

HDate.daysInYear(year) ⇒ number

Number of days in the hebrew YEAR

Kind: static method of HDate

ParamTypeDescription
yearnumberHebrew year

HDate.longCheshvan(year) ⇒ boolean

true if Cheshvan is long in Hebrew year

Kind: static method of HDate

ParamTypeDescription
yearnumberHebrew year

HDate.shortKislev(year) ⇒ boolean

true if Kislev is short in Hebrew year

Kind: static method of HDate

ParamTypeDescription
yearnumberHebrew year

HDate.monthFromName(monthName) ⇒ number

Converts Hebrew month string name to numeric

Kind: static method of HDate

ParamTypeDescription
monthNamestring | numbermonthName

HDate.dayOnOrBefore(dayOfWeek, absdate) ⇒ number

Note: Applying this function to d+6 gives us the DAYNAME on or after an absolute day d. Similarly, applying it to d+3 gives the DAYNAME nearest to absolute date d, applying it to d-1 gives the DAYNAME previous to absolute date d, and applying it to d+7 gives the DAYNAME following absolute date d.

Kind: static method of HDate

ParamType
dayOfWeeknumber
absdatenumber

HDate.isHDate(obj) ⇒ boolean

Tests if the object is an instance of HDate

Kind: static method of HDate

ParamType
objany

HDate.fromGematriyaString(str, currentThousands) ⇒ HDate

Construct a new instance of HDate from a Gematriya-formatted string

Kind: static method of HDate

ParamTypeDefault
strstring
currentThousandsnumber5000

Example

HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
 HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
 HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708

Locale

A locale in Hebcal is used for translations/transliterations of holidays. @hebcal/hdate supports four locales by default

  • en - default, Sephardic transliterations (e.g. "Shabbat")
  • ashkenazi - Ashkenazi transliterations (e.g. "Shabbos")
  • he - Hebrew (e.g. "שַׁבָּת")
  • he-x-NoNikud - Hebrew without nikud (e.g. "שבת")

Kind: global class

Locale.lookupTranslation(id, [locale]) ⇒ string

Returns translation only if locale offers a non-empty translation for id. Otherwise, returns undefined.

Kind: static method of Locale

ParamTypeDescription
idstringMessage ID to translate
[locale]stringOptional locale name (i.e: 'he', 'fr'). Defaults to active locale.

Locale.gettext(id, [locale]) ⇒ string

By default, if no translation was found, returns id.

Kind: static method of Locale

ParamTypeDescription
idstringMessage ID to translate
[locale]stringOptional locale name (i.e: 'he', 'fr'). Defaults to active locale.

Locale.addLocale(locale, data)

Register locale translations.

Kind: static method of Locale

ParamTypeDescription
localestringLocale name (i.e.: 'he', 'fr')
dataLocaleDataparsed data from a .po file.

Locale.addTranslation(locale, id, translation)

Adds a translation to locale, replacing any previous translation.

Kind: static method of Locale

ParamTypeDescription
localestringLocale name (i.e: 'he', 'fr').
idstringMessage ID to translate
translationstringTranslation text

Locale.addTranslations(locale, data)

Adds multiple translations to locale, replacing any previous translations.

Kind: static method of Locale

ParamTypeDescription
localestringLocale name (i.e: 'he', 'fr').
dataLocaleDataparsed data from a .po file.

Locale.useLocale(locale)

Activates a locale. Throws an error if the locale has not been previously added. After setting the locale to be used, all strings marked for translations will be represented by the corresponding translation in the specified locale.

Kind: static method of Locale

ParamTypeDescription
localestringLocale name (i.e: 'he', 'fr')

Locale.getLocaleName() ⇒ string

Returns the name of the active locale (i.e. 'he', 'ashkenazi', 'fr')

Kind: static method of Locale

Locale.getLocaleNames() ⇒ Array.<string>

Returns the names of registered locales

Kind: static method of Locale

Locale.ordinal(n, [locale]) ⇒ string

Kind: static method of Locale

ParamTypeDescription
nnumber
[locale]stringOptional locale name (i.e: 'he', 'fr'). Defaults to active locale.

Locale.hebrewStripNikkud(str) ⇒ string

Removes nekudot from Hebrew string

Kind: static method of Locale

ParamType
strstring

Sedra

Represents Parashah HaShavua for an entire Hebrew year

Kind: global class

new Sedra(hyear, il)

Caculates the Parashah HaShavua for an entire Hebrew year

ParamTypeDescription
hyearnumberHebrew year (e.g. 5749)
ilbooleanUse Israel sedra schedule (false for Diaspora)

sedra.get(hd) ⇒ Array.<string>

Returns the parsha (or parshiyot) read on Hebrew date

Kind: instance method of Sedra

ParamTypeDescription
hdHDate | numberHebrew date or R.D. days

sedra.getString(hd, [locale]) ⇒ string

Looks up parsha for the date, then returns a translated or transliterated string

Kind: instance method of Sedra

ParamTypeDescription
hdHDate | numberHebrew date or R.D. days
[locale]stringOptional locale name (i.e: 'he', 'fr'). Defaults to active locale

sedra.isParsha(hd) ⇒ boolean

Checks to see if this day would be a regular parasha HaShavua Torah reading or special holiday reading

Kind: instance method of Sedra

ParamTypeDescription
hdHDate | numberHebrew date or R.D. days

sedra.find(parsha) ⇒ HDate | null

Returns the date that a parsha occurs or null if the parsha doesn't occur this year

Kind: instance method of Sedra

ParamType
parshanumber | string | Array.<string>

sedra.getSedraArray() ⇒ Array.<NumberOrString>

Returns the underlying annual sedra schedule. Used by @hebcal/triennial

Kind: instance method of Sedra

sedra.getFirstSaturday() ⇒ number

R.D. date of the first Saturday on or after Rosh Hashana

Kind: instance method of Sedra

sedra.getYear() ⇒ number

Kind: instance method of Sedra

sedra.lookup(hd) ⇒ SedraResult

Returns an object describing the parsha on the first Saturday on or after hd

Kind: instance method of Sedra

ParamTypeDescription
hdHDate | numberHebrew date or R.D. days

greg

Gregorian date helper functions.

Kind: global variable

parshiot : Array.<string>

The 54 parshiyot of the Torah as transilterated strings parshiot[0] == 'Bereshit', parshiot[1] == 'Noach', parshiot[52] == "Ha'azinu".

Kind: global variable
Read only: true

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) / אדר ב׳

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'

getPseudoISO(tzid, date) ⇒ string

Returns a string similar to Date.toISOString() but in the timezone tzid. Contrary to the typical meaning of Z at the end of the string, this is not actually a UTC date.

Kind: global function

ParamType
tzidstring
dateDate

getTimezoneOffset(tzid, date) ⇒ number

Returns number of minutes tzid is offset from UTC on date date.

Kind: global function

ParamType
tzidstring
dateDate

pad4(number) ⇒ string

Formats a number with leading zeros so the resulting string is 4 digits long. Similar to string.padStart(4, '0') but will also format negative numbers similar to how the JavaScript date formats negative year numbers (e.g. -37 is formatted as -000037).

Kind: global function

ParamType
numbernumber

pad2(number) ⇒ string

Formats a number with leading zeros so the resulting string is 2 digits long. Similar to string.padStart(2, '0').

Kind: global function

ParamType
numbernumber

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

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)

hd2abs()

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

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

molad()

Calculates the molad for a Hebrew month

Kind: global function

omerSefira(omerDay, lang) ⇒

Returns the sefira. For example, on day 8 חֶֽסֶד שֶׁבִּגְבוּרָה Chesed shebiGevurah Lovingkindness within Might

Kind: global function
Returns: a string such as Lovingkindness within Might or חֶֽסֶד שֶׁבִּגְבוּרָה

ParamDescription
omerDaythe day of the omer, 1-49 inclusive
langen (English), he (Hebrew with nikud), or translit (Hebrew in Sephardic transliteration)

omerTodayIs(omerDay, lang) ⇒

Returns a sentence with that evening's omer count

Kind: global function
Returns: a string such as Today is 10 days, which is 1 week and 3 days of the Omer or הַיוֹם עֲשָׂרָה יָמִים, שְׁהֵם שָׁבוּעַ אֶחָד וְשְׁלוֹשָׁה יָמִים לָעוֹמֶר

ParamDescription
omerDaythe day of the omer, 1-49 inclusive
langen (English), he (Hebrew with nikud)

omerEmoji(omerDay) ⇒

Returns an emoji number symbol with a circle, for example from the “Enclosed CJK Letters and Months” block of the Unicode standard

Kind: global function
Returns: a single Unicode character from through

ParamDescription
omerDaythe day of the omer, 1-49 inclusive

Keywords

FAQs

Package last updated on 29 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc