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

@hebcal/core

Package Overview
Dependencies
Maintainers
1
Versions
277
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hebcal/core

A perpetual Jewish Calendar API

  • 1.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1K
increased by120.65%
Maintainers
1
Weekly downloads
 
Created
Source

hebcal-es6

Hebcal, a perpetual Jewish Calendar (ES6)

Build Status

Installation

$ npm install @hebcal/core

Synopsis

import {hebcal, HDate, Location, Event} from '@hebcal/core';

const options = {
  year: 1981,
  isHebrewYear: false,
  candlelighting: true,
  location: Location.lookup('San Francisco'),
  sedrot: true,
  omer: true,
};
const events = hebcal.hebrewCalendar(options);

for (const ev of events) {
  const hd = ev.getDate();
  const date = hd.greg();
  console.log(date.toLocaleDateString(), ev.render(), hd.toString());
}

Classes

Event

Represents an Event with a title, date, and flags

HDate

Class representing a Hebrew date

HebrewDateEvent

Daily Hebrew date ("11th of Sivan, 5780")

Zmanim

Class representing halachic times

Location

Class representing Location

HavdalahEvent

Havdalah after Shabbat or holiday

CandleLightingEvent

Candle lighting before Shabbat or holiday

MoladEvent

Represents a Molad announcement on Shabbat Mevarchim

OmerEvent

Represents a day 1-49 of counting the Omer from Pesach to Shavuot

DafYomiEvent

For a Daf Yomi, the name is already translated attrs.dafyomi.name contains the untranslated string

Sedra

Represents Parashah HaShavua for an entire Hebrew year

ParshaEvent

Represents one of 54 weekly Torah portions, always on a Saturday

HolidayEvent

Represents a built-in holiday like Pesach, Purim or Tu BiShvat

RoshChodeshEvent

Represents Rosh Chodesh, the beginning of a new month

MevarchimChodeshEvent

Represents Mevarchim haChodesh, the announcement of the new month

Objects

common : object

Common hebrew date routines

dafyomi$1 : object

Daf Yomi

greg : object

Gregorian date routines

holidays : object

Lower-level holidays interface

hebcal : object

Main interface to Hebcal

Functions

hebLeapYear(x)boolean

Returns true if Hebrew year is a leap year

monthsInHebYear(x)number

Number of months in Hebrew year

daysInHebMonth(month, year)number

Number of days in Hebrew month in a given year

getMonthName(month, year)string

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

monthNum(month)number

Returns the Hebrew month number

hebElapsedDays(hYear)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

longCheshvan(year)boolean

true if Cheshvan is long in Hebrew YEAR

shortKislev(year)boolean

true if Kislev is short in Hebrew YEAR

monthFromName(c)number

Converts Hebrew month string name to numeric

dayOnOrBefore(day_of_week, 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.

range(start, end, [step])Array.<number>

Returns an array from start to end

gregLeapYear(year)boolean

Returns true if the Gregorian year is a leap year

daysInGregMonth(month, year)number

Number of days in the Gregorian month for given year

dayOfYear(date)number

Returns number of days since January 1 of that year

greg2abs(date)number

Converts Gregorian date to Julian Day Count

abs2greg(theDate)Date

Converts from Julian Day Count 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.

lookupTranslation(id, [locale])string

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

gettext(id, [locale])string

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

addLocale(locale, data)

Register locale translations.

registerLocale(locale, data)

Alias for addLocale()

useLocale(locale)LocaleData

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.

hebrewStripNikkud(str)string

Removes nekudot from Hebrew string

onOrBefore(day, t, offset)HDate
hebrew2abs(d)number

Converts Hebrew date to absolute Julian days. The absolute date is the number of days elapsed since the (imaginary) Gregorian date Sunday, December 31, 1 BC.

abs2hebrew(d)SimpleHebrewDate

Converts absolute Julian days to Hebrew date

getBirthdayOrAnniversary(hyear, gdate)HDate

Calculates a birthday or anniversary (non-yahrzeit). hyear must be after original gdate 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]

getYahrzeit(hyear, gdate)HDate

Calculates yahrzeit. hyear must be after original gdate 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]
throwError(error)
registerLocation(cityName, location)boolean

Adds a location name for Location.lookup() only if the name isn't already being used. Returns false if the name is already taken and true if successfully added.

formatTime(timeFormat, dt)string
sunsetTime(hd, location, timeFormat, offset)Array.<Object>
tzeitTime(hd, location, timeFormat)Array.<Object>
makeCandleEvent(e, hd, dow, location, timeFormat, candlesOffset, [havdalahOffset])Event
getMolad(year, month)Molad

Calculates the molad for a Hebrew month

dafyomi(gregdate)DafYomiResult

Returns the Daf Yomi for given date

dafname(daf, [locale])string

Formats (with translation) the dafyomi result as a string like "Pesachim 34"

D(p)number

parsha doubler/undoubler

abs(year, absDate)Object

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

chanukah(day)string
getHolidaysForYear(year)Map.<string, Array.<Event>>

Returns a Map for the year indexed by HDate.toString()

getHolidaysOnDate(date)Array.<Event>

Returns an array of Events on this date (or undefined if no events)

reformatTimeStr(timeStr, suffix, options)string

Returns "8:13p" for US or "20:13" for any other locale/country

makeAnchor(s)string
getCandleLightingMinutes(options)number
getAbs(d)number

Gets the Julian absolute days for a number, Date, or HDate

getStartAndEnd(options)Array.<number>

Parse options object to determine start & end days

getOmerStartAndEnd(hyear)Array.<number>
getMaskFromOptions(options)number

Mask to filter Holiday array

hebrewCalendar(options)Array.<Event>

Generates a list of holidays

Typedefs

SimpleHebrewDate : Object

A simple Hebrew date object with numeric fields yy, mm, and dd

Molad : Object

Represents a Molad

DafYomiResult : Object

A Daf Yomi result

HebcalOptions : Object

Options to configure which events are returned

Event

Represents an Event with a title, date, and flags

Kind: global class

new Event(date, desc, [mask], [attrs])

Constructs Event

ParamTypeDefaultDescription
dateHDateHebrew date event occurs
descstringDescription (not translated)
[mask]number0optional holiday flags
[attrs]Object{}

event.getFlags() ⇒ number

Kind: instance method of Event

event.getAttrs() ⇒ Object

Kind: instance method of Event

event.observedInIsrael() ⇒ boolean

Is this event observed in Israel?

Kind: instance method of Event

event.observedInDiaspora() ⇒ boolean

Is this event observed in the Diaspora?

Kind: instance method of Event

event.render([locale]) ⇒ string

Returns (translated) description of this event

Kind: instance method of Event

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

event.renderBrief([locale]) ⇒ string

Returns a brief (translated) description of this event. For most events, this is the same as render(). For some events, it procudes a shorter text (e.g. without a time or added description).

Kind: instance method of Event

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

event.getDesc() ⇒ string

Returns untranslated description of this event

Kind: instance method of Event

event.basename() ⇒ string

Returns a simplified (untranslated) description for this event. For example, "Erev Pesach" => "Pesach", and "Sukkot III (CH''M)" => "Sukkot". For many holidays the basename and the event description are the same.

Kind: instance method of Event

event.getDate() ⇒ HDate

Returns Hebrew date of this event

Kind: instance method of Event

event.url() ⇒ string

Kind: instance method of Event

HDate

Class representing 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 Julian days to Hebrew date. The absolute Julian date is the number of days elapsed since the (imaginary) Gregorian date Sunday, December 31, 1 BC
  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, common} from '@hebcal/core';

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, common.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

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, using local time.

Kind: instance method of HDate

hDate.setFullYear(year) ⇒ HDate

Kind: instance method of HDate

ParamType
yearnumber

hDate.setMonth(month) ⇒ HDate

Kind: instance method of HDate

ParamType
monthnumber

hDate.setTishreiMonth(month) ⇒ HDate

Kind: instance method of HDate

ParamType
monthnumber

hDate.setDate(date) ⇒ HDate

Kind: instance method of HDate

ParamType
datenumber

hDate.greg() ⇒ Date

Converts to Gregorian date

Kind: instance method of HDate

hDate.abs() ⇒ number

Returns Julian absolute days

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]) ⇒ string

Returns translated/transliterated Hebrew date, e.g. '15 Cheshvan 5769'.

Kind: instance method of HDate

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

Example

import {HDate, common} from '@hebcal/core';

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

hDate.before(day) ⇒ HDate

Kind: instance method of HDate

ParamTypeDescription
daynumberday of week

hDate.onOrBefore(day) ⇒ HDate

Kind: instance method of HDate

ParamTypeDescription
daynumberday of week

hDate.nearest(day) ⇒ HDate

Kind: instance method of HDate

ParamTypeDescription
daynumberday of week

hDate.onOrAfter(day) ⇒ HDate

Kind: instance method of HDate

ParamTypeDescription
daynumberday of week

hDate.after(day) ⇒ HDate

Kind: instance method of HDate

ParamTypeDescription
daynumberday of week

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

HebrewDateEvent

Daily Hebrew date ("11th of Sivan, 5780")

Kind: global class

new HebrewDateEvent(date, locale)

ParamType
dateHDate
localestring

hebrewDateEvent.render([locale]) ⇒ string

Kind: instance method of HebrewDateEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

Example

import {HDate, HebrewDateEvent, common} from '@hebcal/core';

const hd = new HDate(15, common.months.CHESHVAN, 5769);
const ev = new HebrewDateEvent(hd);
console.log(ev.render()); // '15th of Cheshvan, 5769'
console.log(ev.render('he')); // 'ט״ו חֶשְׁוָן תשס״ט'

HebrewDateEvent.renderHebrew(day, monthName, fullYear) ⇒ string

Helper function to render a Hebrew date

Kind: static method of HebrewDateEvent

ParamType
daynumber
monthNamestring
fullYearnumber

Zmanim

Class representing halachic times

Kind: global class

new Zmanim(date, latitude, longitude)

Initialize a Zmanim instance.

ParamTypeDescription
dateDate | HDateRegular or Hebrew Date. If date is a regular Date, hours, minutes, seconds and milliseconds are ignored.
latitudenumber
longitudenumber

zmanim.suntime() ⇒ suncalc.GetTimesResult

Kind: instance method of Zmanim

zmanim.sunrise() ⇒ Date

Kind: instance method of Zmanim

zmanim.sunset() ⇒ Date

Kind: instance method of Zmanim

zmanim.hour() ⇒ number

Kind: instance method of Zmanim

zmanim.hourMins() ⇒ number

Kind: instance method of Zmanim

zmanim.gregEve() ⇒ Date

Kind: instance method of Zmanim

zmanim.nightHour() ⇒ number

Kind: instance method of Zmanim

zmanim.nightHourMins() ⇒ number

Kind: instance method of Zmanim

zmanim.hourOffset(hours) ⇒ Date

Kind: instance method of Zmanim

ParamType
hoursnumber

zmanim.chatzot() ⇒ Date

Kind: instance method of Zmanim

zmanim.chatzotNight() ⇒ Date

Kind: instance method of Zmanim

zmanim.alotHaShachar() ⇒ Date

Kind: instance method of Zmanim

zmanim.misheyakir() ⇒ Date

Kind: instance method of Zmanim

zmanim.misheyakirMachmir() ⇒ Date

Kind: instance method of Zmanim

zmanim.sofZmanShma() ⇒ Date

Kind: instance method of Zmanim

zmanim.sofZmanTfilla() ⇒ Date

Kind: instance method of Zmanim

zmanim.minchaGedola() ⇒ Date

Kind: instance method of Zmanim

zmanim.minchaKetana() ⇒ Date

Kind: instance method of Zmanim

zmanim.plagHaMincha() ⇒ Date

Kind: instance method of Zmanim

zmanim.tzeit() ⇒ Date

Kind: instance method of Zmanim

zmanim.neitzHaChama() ⇒ Date

Kind: instance method of Zmanim

zmanim.shkiah() ⇒ Date

Kind: instance method of Zmanim

Location

Class representing Location

Kind: global class

new Location(latitude, longitude, il, tzid, cityName, countryCode, geoid)

Initialize a Location instance

ParamTypeDescription
latitudenumberLatitude as a decimal, valid range -90 thru +90 (e.g. 41.85003)
longitudenumberLongitude as a decimal, valid range -180 thru +180 (e.g. -87.65005)
ilbooleanin Israel (true) or Diaspora (false)
tzidstringOlson timezone ID, e.g. "America/Chicago"
cityNamestringoptional descriptive city name
countryCodestringISO 3166 alpha-2 country code (e.g. "FR")
geoidnumberoptional numeric geographic ID

location.getLatitude() ⇒ number

Kind: instance method of Location

location.getLongitude() ⇒ number

Kind: instance method of Location

location.getIsrael() ⇒ boolean

Kind: instance method of Location

location.getName() ⇒ string

Kind: instance method of Location

location.getCountryCode() ⇒ string

Kind: instance method of Location

location.getTzid() ⇒ string

Kind: instance method of Location

location.sunset(hdate) ⇒ Date

Kind: instance method of Location

ParamType
hdateDate | HDate

location.tzeit(hdate) ⇒ Date

Kind: instance method of Location

ParamType
hdateDate | HDate

location.toString() ⇒ string

Kind: instance method of Location

Location.lookup(name) ⇒ Location

Creates a location object from one of 60 "classic" Hebcal city names. The following city names are supported: 'Ashdod', 'Atlanta', 'Austin', 'Baghdad', 'Beer Sheva', 'Berlin', 'Baltimore', 'Bogota', 'Boston', 'Budapest', 'Buenos Aires', 'Buffalo', 'Chicago', 'Cincinnati', 'Cleveland', 'Dallas', 'Denver', 'Detroit', 'Eilat', 'Gibraltar', 'Haifa', 'Hawaii', 'Helsinki', 'Houston', 'Jerusalem', 'Johannesburg', 'Kiev', 'La Paz', 'Livingston', 'Las Vegas', 'London', 'Los Angeles', 'Marseilles', 'Miami', 'Minneapolis', 'Melbourne', 'Mexico City', 'Montreal', 'Moscow', 'New York', 'Omaha', 'Ottawa', 'Panama City', 'Paris', 'Pawtucket', 'Petach Tikvah', 'Philadelphia', 'Phoenix', 'Pittsburgh', 'Providence', 'Portland', 'Saint Louis', 'Saint Petersburg', 'San Diego', 'San Francisco', 'Sao Paulo', 'Seattle', 'Sydney', 'Tel Aviv', 'Tiberias', 'Toronto', 'Vancouver', 'White Plains', 'Washington DC', 'Worcester'

Kind: static method of Location

ParamType
namestring

HavdalahEvent

Havdalah after Shabbat or holiday

Kind: global class

new HavdalahEvent(date, mask, attrs, [havdalahMins])

ParamType
dateHDate
masknumber
attrsObject
[havdalahMins]number

havdalahEvent.render([locale]) ⇒ string

Kind: instance method of HavdalahEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

havdalahEvent.renderBrief([locale]) ⇒ string

Returns translation of "Havdalah" without the time.

Kind: instance method of HavdalahEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

CandleLightingEvent

Candle lighting before Shabbat or holiday

Kind: global class

new CandleLightingEvent(date, mask, attrs)

ParamType
dateHDate
masknumber
attrsObject

candleLightingEvent.render([locale]) ⇒ string

Kind: instance method of CandleLightingEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

candleLightingEvent.renderBrief([locale]) ⇒ string

Returns translation of "Candle lighting" without the time.

Kind: instance method of CandleLightingEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

MoladEvent

Represents a Molad announcement on Shabbat Mevarchim

Kind: global class

new MoladEvent(date, hyear, hmonth)

ParamTypeDescription
dateHDateHebrew date event occurs
hyearnumbermolad year
hmonthnumbermolad month

moladEvent.render([locale]) ⇒ string

Kind: instance method of MoladEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

OmerEvent

Represents a day 1-49 of counting the Omer from Pesach to Shavuot

Kind: global class

new OmerEvent(date, omerDay)

ParamType
dateHDate
omerDaynumber

omerEvent.render([locale]) ⇒ string

Kind: instance method of OmerEvent
Todo

  • use gettext()
ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

omerEvent.renderBrief([locale]) ⇒ string

Returns translation of "Omer 22" without ordinal numbers.

Kind: instance method of OmerEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

DafYomiEvent

For a Daf Yomi, the name is already translated attrs.dafyomi.name contains the untranslated string

Kind: global class

new DafYomiEvent(date, daf)

ParamType
dateHDate
dafDafYomiResult

dafYomiEvent.render([locale]) ⇒ string

Kind: instance method of DafYomiEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

dafYomiEvent.renderBrief([locale]) ⇒ string

Returns daf yomi name the 'Daf Yomi: ' prefix.

Kind: instance method of DafYomiEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

dafYomiEvent.url() ⇒ string

Kind: instance method of DafYomiEvent

Sedra

Represents Parashah HaShavua for an entire Hebrew year

Kind: global class

new Sedra(hebYr, il)

Caculates the Parashah HaShavua for an entire Hebrew year

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

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

Returns the parsha (or parshiyot) read on Hebrew date

Kind: instance method of Sedra

ParamTypeDescription
hDateHDate | numberHebrew date or absolute days

sedra.getString(hDate) ⇒ string

Looks up parsha for the date, then returns a (translated) string

Kind: instance method of Sedra

ParamTypeDescription
hDateHDate | numberHebrew date or absolute days

sedra.lookup(hDate) ⇒ Object

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

Kind: instance method of Sedra

ParamTypeDescription
hDateHDate | numberHebrew date or absolute days

sedra.isParsha(hDate) ⇒ 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
hDateHDate | numberHebrew date or absolute days

sedra.getSedraArray() ⇒ Array.<Object>

Kind: instance method of Sedra

sedra.getYear() ⇒ number

Kind: instance method of Sedra

ParshaEvent

Represents one of 54 weekly Torah portions, always on a Saturday

Kind: global class

new ParshaEvent(date, parsha)

ParamTypeDescription
dateHDate
parshaArray.<string>untranslated name of single or double parsha, such as ['Bereshit'] or ['Achrei Mot', 'Kedoshim']

parshaEvent.render([locale]) ⇒ string

Kind: instance method of ParshaEvent

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

parshaEvent.basename() ⇒ string

Kind: instance method of ParshaEvent

parshaEvent.url() ⇒ string

Kind: instance method of ParshaEvent

HolidayEvent

Represents a built-in holiday like Pesach, Purim or Tu BiShvat

Kind: global class

new HolidayEvent(date, desc, [mask], [attrs])

Constructs Holiday event

ParamTypeDefaultDescription
dateHDateHebrew date event occurs
descstringDescription (not translated)
[mask]number0optional holiday flags
[attrs]Object{}

holidayEvent.basename() ⇒ string

Kind: instance method of HolidayEvent

holidayEvent.renderFullOrBasename(locale) ⇒ string

Kind: instance method of HolidayEvent

ParamType
localestring

holidayEvent.url() ⇒ string

Kind: instance method of HolidayEvent

RoshChodeshEvent

Represents Rosh Chodesh, the beginning of a new month

Kind: global class

new RoshChodeshEvent(date, monthName)

Constructs Rosh Chodesh event

ParamTypeDescription
dateHDateHebrew date event occurs
monthNamestringHebrew month name (not translated)

roshChodeshEvent.render([locale]) ⇒ string

Returns (translated) description of this event

Kind: instance method of RoshChodeshEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

roshChodeshEvent.basename() ⇒ string

Kind: instance method of RoshChodeshEvent

MevarchimChodeshEvent

Represents Mevarchim haChodesh, the announcement of the new month

Kind: global class

new MevarchimChodeshEvent(date, monthName)

Constructs Mevarchim haChodesh event

ParamTypeDescription
dateHDateHebrew date event occurs
monthNamestringHebrew month name (not translated)

mevarchimChodeshEvent.render([locale]) ⇒ string

Returns (translated) description of this event

Kind: instance method of MevarchimChodeshEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

mevarchimChodeshEvent.renderBrief([locale]) ⇒ string

Returns (translated) description of this event

Kind: instance method of MevarchimChodeshEvent

ParamTypeDescription
[locale]stringOptional locale name (defaults to active locale).

common : object

Common hebrew date routines

Kind: global namespace

dafyomi$1 : object

Daf Yomi

Kind: global namespace

greg : object

Gregorian date routines

Kind: global namespace

holidays : object

Lower-level holidays interface

Kind: global namespace

hebcal : object

Main interface to Hebcal

Kind: global namespace

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

days : enum

Days of the week (SUN=0, SAT=6)

Kind: global enum
Read only: true
Properties

NameTypeDefaultDescription
SUNnumber0Sunday
MONnumber1Monday
TUEnumber2Tuesday
WEDnumber3Wednesday
THUnumber4Thursday
FRInumber5Friday
SATnumber6Saturday

flags : enum

Holiday flags for Event

Kind: global enum
Read only: true
Properties

NameTypeDefaultDescription
CHAGnumberCHAGChag, yontiff, yom tov
LIGHT_CANDLESnumberLIGHT_CANDLESLight candles 18 minutes before sundown
YOM_TOV_ENDSnumberYOM_TOV_ENDSEnd of holiday (end of Yom Tov)
CHUL_ONLYnumberCHUL_ONLYObserved only in the Diaspora (chutz l'aretz)
IL_ONLYnumberIL_ONLYObserved only in Israel
LIGHT_CANDLES_TZEISnumberLIGHT_CANDLES_TZEISLight candles in the evening at Tzeit time (3 small stars)
CHANUKAH_CANDLESnumberCHANUKAH_CANDLESCandle-lighting for Chanukah
ROSH_CHODESHnumberROSH_CHODESHRosh Chodesh, beginning of a new Hebrew month
MINOR_FASTnumberMINOR_FASTMinor fasts like Tzom Tammuz, Ta'anit Esther, ...
SPECIAL_SHABBATnumberSPECIAL_SHABBATShabbat Shekalim, Zachor, ...
PARSHA_HASHAVUAnumberPARSHA_HASHAVUAWeekly sedrot on Saturdays
DAF_YOMInumberDAF_YOMIDaily page of Talmud
OMER_COUNTnumberOMER_COUNTDays of the Omer
MODERN_HOLIDAYnumberMODERN_HOLIDAYYom HaShoah, Yom HaAtzma'ut, ...
MAJOR_FASTnumberMAJOR_FASTYom Kippur and Tish'a B'Av
SHABBAT_MEVARCHIMnumberSHABBAT_MEVARCHIMOn the Saturday before Rosh Chodesh
MOLADnumberMOLADMolad
USER_EVENTnumberUSER_EVENTYahrzeit or Hebrew Anniversary
HEBREW_DATEnumberHEBREW_DATEDaily Hebrew date ("11th of Sivan, 5780")

hebLeapYear(x) ⇒ boolean

Returns true if Hebrew year is a leap year

Kind: global function

ParamTypeDescription
xnumberHebrew year

monthsInHebYear(x) ⇒ number

Number of months in Hebrew year

Kind: global function

ParamTypeDescription
xnumberHebrew year

daysInHebMonth(month, year) ⇒ number

Number of days in Hebrew month in a given year

Kind: global function

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

getMonthName(month, year) ⇒ string

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

monthNum(month) ⇒ number

Returns the Hebrew month number

Kind: global function

ParamTypeDescription
monthnumber | stringA number, or Hebrew month name string

hebElapsedDays(hYear) ⇒ number

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

Kind: global function

ParamTypeDescription
hYearnumberHebrew year

daysInYear(year) ⇒ number

Number of days in the hebrew YEAR

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(c) ⇒ number

Converts Hebrew month string name to numeric

Kind: global function

ParamTypeDescription
cstringmonthName

dayOnOrBefore(day_of_week, 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: global function

ParamType
day_of_weeknumber
absdatenumber

range(start, end, [step]) ⇒ Array.<number>

Returns an array from start to end

Kind: global function

ParamTypeDefaultDescription
startnumberbeginning number, inclusive
endnumberending number, inclusive
[step]number1

gregLeapYear(year) ⇒ boolean

Returns true if the Gregorian year is a leap year

Kind: global function

ParamTypeDescription
yearnumberGregorian year

daysInGregMonth(month, year) ⇒ number

Number of days in the Gregorian month for given year

Kind: global function

ParamTypeDescription
monthnumberGregorian month (1=January, 12=December)
yearnumberGregorian year

dayOfYear(date) ⇒ number

Returns number of days since January 1 of that year

Kind: global function

ParamTypeDescription
dateDateGregorian date

greg2abs(date) ⇒ number

Converts Gregorian date to Julian Day Count

Kind: global function

ParamTypeDescription
dateDateGregorian date

abs2greg(theDate) ⇒ Date

Converts from Julian Day Count 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.

Kind: global function

ParamTypeDescription
theDatenumberabsolute Julian days

lookupTranslation(id, [locale]) ⇒ string

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

Kind: global function

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

gettext(id, [locale]) ⇒ string

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

Kind: global function

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

addLocale(locale, data)

Register locale translations.

Kind: global function

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

registerLocale(locale, data)

Alias for addLocale()

Kind: global function

ParamType
localestring
dataany

useLocale(locale) ⇒ LocaleData

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: global function

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

hebrewStripNikkud(str) ⇒ string

Removes nekudot from Hebrew string

Kind: global function

ParamType
strstring

onOrBefore(day, t, offset) ⇒ HDate

Kind: global function

ParamType
daynumber
tHDate
offsetnumber

hebrew2abs(d) ⇒ number

Converts Hebrew date to absolute Julian days. The absolute date is the number of days elapsed since the (imaginary) Gregorian date Sunday, December 31, 1 BC.

Kind: global function

ParamTypeDescription
dHDate | SimpleHebrewDateHebrew Date

abs2hebrew(d) ⇒ SimpleHebrewDate

Converts absolute Julian days to Hebrew date

Kind: global function

ParamTypeDescription
dnumberabsolute Julian days

getBirthdayOrAnniversary(hyear, gdate) ⇒ HDate

Calculates a birthday or anniversary (non-yahrzeit). hyear must be after original gdate 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: HDate - anniversary occurring in hyear

ParamTypeDescription
hyearnumberHebrew year
gdateDate | HDateGregorian or Hebrew date of event

Example

import {hebcal} from '@hebcal/core';
const dt = new Date(2014, 2, 2); // '2014-03-02' == '30 Adar I 5774'
const hd = hebcal.getBirthdayOrAnniversary(5780, dt); // '1 Nisan 5780'
console.log(hd.greg().toLocaleDateString('en-US')); // '3/26/2020'

getYahrzeit(hyear, gdate) ⇒ HDate

Calculates yahrzeit. hyear must be after original gdate 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: HDate - anniversary occurring in hyear

ParamTypeDescription
hyearnumberHebrew year
gdateDate | HDateGregorian or Hebrew date of death

Example

import {hebcal} from '@hebcal/core';
const dt = new Date(2014, 2, 2); // '2014-03-02' == '30 Adar I 5774'
const hd = hebcal.getYahrzeit(5780, dt); // '30 Sh\'vat 5780'
console.log(hd.greg().toLocaleDateString('en-US')); // '2/25/2020'

throwError(error)

Kind: global function

ParamType
errorstring

registerLocation(cityName, location) ⇒ boolean

Adds a location name for Location.lookup() only if the name isn't already being used. Returns false if the name is already taken and true if successfully added.

Kind: global function

ParamType
cityNamestring
locationLocation

formatTime(timeFormat, dt) ⇒ string

Kind: global function

ParamType
timeFormatIntl.DateTimeFormat
dtDate

sunsetTime(hd, location, timeFormat, offset) ⇒ Array.<Object>

Kind: global function

ParamType
hdHDate
locationLocation
timeFormatIntl.DateTimeFormat
offsetnumber

tzeitTime(hd, location, timeFormat) ⇒ Array.<Object>

Kind: global function

ParamType
hdHDate
locationLocation
timeFormatIntl.DateTimeFormat

makeCandleEvent(e, hd, dow, location, timeFormat, candlesOffset, [havdalahOffset]) ⇒ Event

Kind: global function

ParamType
eEvent
hdHDate
downumber
locationLocation
timeFormatIntl.DateTimeFormat
candlesOffsetnumber
[havdalahOffset]number

getMolad(year, month) ⇒ Molad

Calculates the molad for a Hebrew month

Kind: global function

ParamType
yearnumber
monthnumber

dafyomi(gregdate) ⇒ DafYomiResult

Returns the Daf Yomi for given date

Kind: global function
Returns: DafYomiResult - Tractact name and page number

ParamTypeDescription
gregdateDateGregorian date

dafname(daf, [locale]) ⇒ string

Formats (with translation) the dafyomi result as a string like "Pesachim 34"

Kind: global function

ParamTypeDescription
dafDafYomiResultthe Daf Yomi
[locale]stringOptional locale name (defaults to active locale).

D(p) ⇒ number

parsha doubler/undoubler

Kind: global function

ParamType
pnumber

abs(year, absDate) ⇒ Object

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

Kind: global function

ParamType
yearnumber
absDatenumber

chanukah(day) ⇒ string

Kind: global function

ParamType
daynumber

getHolidaysForYear(year) ⇒ Map.<string, Array.<Event>>

Returns a Map for the year indexed by HDate.toString()

Kind: global function

ParamTypeDescription
yearnumberHebrew year

getHolidaysForYear~addEvents(year, arr)

Kind: inner method of getHolidaysForYear

ParamType
yearnumber
arrArray.<Object>

getHolidaysOnDate(date) ⇒ Array.<Event>

Returns an array of Events on this date (or undefined if no events)

Kind: global function

ParamTypeDescription
dateHDate | Date | numberHebrew Date, Gregorian date, or absolute Julian date

reformatTimeStr(timeStr, suffix, options) ⇒ string

Returns "8:13p" for US or "20:13" for any other locale/country

Kind: global function

ParamTypeDescription
timeStrstringoriginal time like "20:30"
suffixstring"p" or "pm" or " P.M.". Add leading space if you want it
optionsObject

makeAnchor(s) ⇒ string

Kind: global function

ParamType
sstring

getCandleLightingMinutes(options) ⇒ number

Kind: global function

ParamType
optionsHebcalOptions

getAbs(d) ⇒ number

Gets the Julian absolute days for a number, Date, or HDate

Kind: global function

ParamType
dDate | HDate | number

getStartAndEnd(options) ⇒ Array.<number>

Parse options object to determine start & end days

Kind: global function

ParamType
optionsHebcalOptions

getOmerStartAndEnd(hyear) ⇒ Array.<number>

Kind: global function

ParamType
hyearnumber

getMaskFromOptions(options) ⇒ number

Mask to filter Holiday array

Kind: global function

ParamType
optionsHebcalOptions

hebrewCalendar(options) ⇒ Array.<Event>

Generates a list of holidays

Kind: global function

ParamType
optionsHebcalOptions

SimpleHebrewDate : Object

A simple Hebrew date object with numeric fields yy, mm, and dd

Kind: global typedef
Properties

NameTypeDescription
yynumberHebrew year
mmnumberHebrew month of year (1=NISAN, 7=TISHREI)
ddnumberDay of month (1-30)

Molad : Object

Represents a Molad

Kind: global typedef
Properties

NameTypeDescription
downumberDay of Week (0=Sunday, 6=Saturday)
hournumberhour of day (0-23)
minutesnumberminutes past hour (0-59)
chalakimnumberparts of a minute (0-17)

DafYomiResult : Object

A Daf Yomi result

Kind: global typedef
Properties

NameTypeDescription
namestringTractate name
blattnumberPage number

HebcalOptions : Object

Options to configure which events are returned

Kind: global typedef
Properties

NameTypeDescription
locationLocationlatitude/longitude/tzid used for candle-lighting
yearnumberGregorian or Hebrew year
isHebrewYearbooleanto interpret year as Hebrew year
monthnumberGregorian or Hebrew month (to filter results to a single month)
numYearsnumbergenerate calendar for multiple years (default 1)
startDate | HDate | numberuse specific start date (requires end date)
endDate | HDate | numberuse specific end date (requires start date)
candlelightingbooleancalculate candle-lighting and havdalah times
candleLightingMinsnumberminutes before sundown to light candles (default 18)
havdalahMinsnumberminutes after sundown for Havdalah (typical values are 42, 50, or 72)
havdalahTzeitbooleancalculate Havdalah according to Tzeit Hakochavim - Nightfall (the point when 3 small stars are observable in the night time sky with the naked eye). Defaults to true unless havdalahMins is specified
sedrotbooleancalculate parashah hashavua on Saturdays
ilbooleanIsraeli holiday and sedra schedule
noMinorFastbooleansuppress minor fasts
noModernbooleansuppress modern holidays
noRoshChodeshbooleansuppress Rosh Chodesh
shabbatMevarchimbooleanadd Shabbat Mevarchim
noSpecialShabbatbooleansuppress Special Shabbat
noHolidaysbooleansuppress regular holidays
dafyomibooleaninclude Daf Yomi
omerbooleaninclude Days of the Omer
moladbooleaninclude event announcing the molad
ashkenazibooleanuse Ashkenazi transliterations for event titles (default Sephardi transliterations)
localestringtranslate event titles according to a locale (one of fi, fr, he, hu, pl, ru, ashkenazi, ashkenazi_litvish, ashkenazi_poylish, ashkenazi_standard)
hour12booleanuse 12-hour time (1-12) instead of default 24-hour time (0-23)
addHebrewDatesbooleanprint the Hebrew date for the entire date range
addHebrewDatesForEventsbooleanprint the Hebrew date for dates with some events

Keywords

FAQs

Package last updated on 22 Jun 2020

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