@hebcal/hdate
converts between Hebrew and Gregorian dates using Rata Die (R.D.) algorithm by Dershowitz and Reingold
Installation
$ npm install @hebcal/hdate
Synopsis
import {greg, abs2hebrew} from '@hebcal/hdate';
const date = new Date(2008, 10, 13);
const abs = greg.greg2abs(date);
const hdate = abs2hebrew(abs);
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.
- No parameters - represents the current Hebrew date at time of instantiation
- 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 datenumber
- Converts absolute R.D. days to Hebrew date.
R.D. 1 == the imaginary date January 1, 1 (Gregorian)
- 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.
Param | Type | Description |
---|
[day] | number | Date | HDate | Day 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 | string | Hebrew month of year (1=NISAN, 7=TISHREI) |
[year] | number | Hebrew 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);
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
Param | Type | Default | Description |
---|
[locale] | string | | Optional locale name (defaults to active locale). |
[showYear] | boolean | true | Display year (defaults to true). |
Example
import {HDate, months} from '@hebcal/hdate';
const hd = new HDate(15, months.CHESHVAN, 5769);
console.log(hd.render('en'));
console.log(hd.render('he'));
hDate.renderGematriya([suppressNikud]) ⇒ string
Renders this Hebrew date in Hebrew gematriya, regardless of locale.
Kind: instance method of HDate
Param | Type | Default |
---|
[suppressNikud] | boolean | false |
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
Param | Type | Description |
---|
dow | number | day of week |
Example
new HDate(new Date('Wednesday February 19, 2014')).before(6).greg()
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
Param | Type | Description |
---|
dow | number | day of week |
Example
new HDate(new Date('Wednesday February 19, 2014')).onOrBefore(6).greg()
new HDate(new Date('Saturday February 22, 2014')).onOrBefore(6).greg()
new HDate(new Date('Sunday February 23, 2014')).onOrBefore(6).greg()
hDate.nearest(dow) ⇒ HDate
Returns an HDate
representing the nearest dayNumber to the current date
Sunday=0, Saturday=6
Kind: instance method of HDate
Param | Type | Description |
---|
dow | number | day of week |
Example
new HDate(new Date('Wednesday February 19, 2014')).nearest(6).greg()
new HDate(new Date('Tuesday February 18, 2014')).nearest(6).greg()
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
Param | Type | Description |
---|
dow | number | day of week |
Example
new HDate(new Date('Wednesday February 19, 2014')).onOrAfter(6).greg()
new HDate(new Date('Saturday February 22, 2014')).onOrAfter(6).greg()
new HDate(new Date('Sunday February 23, 2014')).onOrAfter(6).greg()
hDate.after(dow) ⇒ HDate
Returns an HDate
representing the a dayNumber after the current date.
Sunday=0, Saturday=6
Kind: instance method of HDate
Param | Type | Description |
---|
dow | number | day of week |
Example
new HDate(new Date('Wednesday February 19, 2014')).after(6).greg()
new HDate(new Date('Saturday February 22, 2014')).after(6).greg()
new HDate(new Date('Sunday February 23, 2014')).after(6).greg()
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.
Unit | Shorthand | Description |
---|
day | d | days |
week | w | weeks |
month | M | months |
year | y | years |
Kind: instance method of HDate
Param | Type | Default |
---|
amount | number | |
[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.
Unit | Shorthand | Description |
---|
day | d | days |
week | w | weeks |
month | M | months |
year | y | years |
Kind: instance method of HDate
Param | Type | Default |
---|
amount | number | |
[units] | string | "d" |
Example
import {HDate, months} from '@hebcal/hdate';
const hd1 = new HDate(15, months.CHESHVAN, 5769);
const hd2 = hd1.add(1, 'weeks');
const hd3 = hd1.add(-3, 'M');
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
Param | Type | Description |
---|
other | HDate | Hebrew 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);
hDate.isSameDate(other) ⇒ boolean
Compares this date to another date, returning true
if the dates match.
Kind: instance method of HDate
Param | Type | Description |
---|
other | HDate | Hebrew 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
Param | Type | Description |
---|
year | number | Hebrew year |
month | number | Hebrew month |
day | number | Hebrew date (1-30) |
HDate.isLeapYear(year) ⇒ boolean
Returns true if Hebrew year is a leap year
Kind: static method of HDate
Param | Type | Description |
---|
year | number | Hebrew 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
Param | Type | Description |
---|
year | number | Hebrew year |
HDate.daysInMonth(month, year) ⇒ number
Number of days in Hebrew month in a given year (29 or 30)
Kind: static method of HDate
Param | Type | Description |
---|
month | number | Hebrew month (e.g. months.TISHREI) |
year | number | Hebrew 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
Param | Type | Description |
---|
month | number | Hebrew month (e.g. months.TISHREI) |
year | number | Hebrew year |
HDate.monthNum(month) ⇒ number
Returns the Hebrew month number (NISAN=1, TISHREI=7)
Kind: static method of HDate
Param | Type | Description |
---|
month | number | string | A number, or Hebrew month name string |
HDate.daysInYear(year) ⇒ number
Number of days in the hebrew YEAR
Kind: static method of HDate
Param | Type | Description |
---|
year | number | Hebrew year |
HDate.longCheshvan(year) ⇒ boolean
true if Cheshvan is long in Hebrew year
Kind: static method of HDate
Param | Type | Description |
---|
year | number | Hebrew year |
HDate.shortKislev(year) ⇒ boolean
true if Kislev is short in Hebrew year
Kind: static method of HDate
Param | Type | Description |
---|
year | number | Hebrew year |
HDate.monthFromName(monthName) ⇒ number
Converts Hebrew month string name to numeric
Kind: static method of HDate
Param | Type | Description |
---|
monthName | string | number | monthName |
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
Param | Type |
---|
dayOfWeek | number |
absdate | number |
HDate.isHDate(obj) ⇒ boolean
Tests if the object is an instance of HDate
Kind: static method of HDate
HDate.fromGematriyaString(str, currentThousands) ⇒ HDate
Construct a new instance of HDate
from a Gematriya-formatted string
Kind: static method of HDate
Param | Type | Default |
---|
str | string | |
currentThousands | number | 5000 |
Example
HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג')
HDate.fromGematriyaString('כ׳ סיון תש״ד')
HDate.fromGematriyaString('ה׳ אִיָיר תש״ח')
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
Param | Type | Description |
---|
id | string | Message ID to translate |
[locale] | string | Optional 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
Param | Type | Description |
---|
id | string | Message ID to translate |
[locale] | string | Optional locale name (i.e: 'he' , 'fr' ). Defaults to active locale. |
Locale.addLocale(locale, data)
Register locale translations.
Kind: static method of Locale
Param | Type | Description |
---|
locale | string | Locale name (i.e.: 'he' , 'fr' ) |
data | LocaleData | parsed data from a .po file. |
Locale.addTranslation(locale, id, translation)
Adds a translation to locale
, replacing any previous translation.
Kind: static method of Locale
Param | Type | Description |
---|
locale | string | Locale name (i.e: 'he' , 'fr' ). |
id | string | Message ID to translate |
translation | string | Translation text |
Locale.addTranslations(locale, data)
Adds multiple translations to locale
, replacing any previous translations.
Kind: static method of Locale
Param | Type | Description |
---|
locale | string | Locale name (i.e: 'he' , 'fr' ). |
data | LocaleData | parsed 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
Param | Type | Description |
---|
locale | string | Locale 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
Param | Type | Description |
---|
n | number | |
[locale] | string | Optional locale name (i.e: 'he' , 'fr' ). Defaults to active locale. |
Locale.hebrewStripNikkud(str) ⇒ string
Removes nekudot from Hebrew string
Kind: static method of Locale
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
Param | Type | Description |
---|
hyear | number | Hebrew year (e.g. 5749) |
il | boolean | Use 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
Param | Type | Description |
---|
hd | HDate | number | Hebrew 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
Param | Type | Description |
---|
hd | HDate | number | Hebrew date or R.D. days |
[locale] | string | Optional 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
Param | Type | Description |
---|
hd | HDate | number | Hebrew 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
Param | Type |
---|
parsha | number | 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
Param | Type | Description |
---|
hd | HDate | number | Hebrew 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
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) / אדר ב׳ |
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);
const anniversary = getYahrzeit(5780, dt);
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);
const anniversary = getBirthdayOrAnniversary(5780, dt);
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
Param | Type |
---|
tzid | string |
date | Date |
getTimezoneOffset(tzid, date) ⇒ number
Returns number of minutes tzid
is offset from UTC on date date
.
Kind: global function
Param | Type |
---|
tzid | string |
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
).
Kind: global function
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
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
Example
gematriya(5774)
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
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) |
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
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 |
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 חֶֽסֶד שֶׁבִּגְבוּרָה
Param | Description |
---|
omerDay | the day of the omer, 1-49 inclusive |
lang | en (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 הַיוֹם עֲשָׂרָה יָמִים, שְׁהֵם שָׁבוּעַ אֶחָד וְשְׁלוֹשָׁה יָמִים לָעוֹמֶר
Param | Description |
---|
omerDay | the day of the omer, 1-49 inclusive |
lang | en (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 ㊾
Param | Description |
---|
omerDay | the day of the omer, 1-49 inclusive |