Create a Hebrew date. There are 3 basic forms for the HDate() constructor.
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)Optionalday: number | HDate | Date | SimpleHebrewDate
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.
Optionalmonth: string | number
Hebrew month of year (1=NISAN, 7=TISHREI)
Optionalyear: number
Hebrew year
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);
Hebrew day within the month (1-30)
Hebrew month of year (1=NISAN, 7=TISHREI)
Optionalrdabsolute Rata Die (R.D.) days
Hebrew year, 1-9999
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 |
number of units to add (negative values subtract)
Optionalunits: FlexibleTimeUnit
unit of time, defaults to days
a new HDate; the original is not modified
Returns an HDate corresponding to the specified day of week
after this Hebrew date.
Strictly after: if this date already falls on dayOfWeek, the next
occurrence a week later is returned.
day of week: Sunday=0, Saturday=6
a new HDate; the original is not modified
const wed = new HDate(new Date('Wednesday February 19, 2014'));
const sat = new HDate(new Date('Saturday February 22, 2014'));
const sun = new HDate(new Date('Sunday February 23, 2014'));
wed.after(6).greg().toDateString(); // 'Sat Feb 22 2014'
sat.after(6).greg().toDateString(); // 'Sat Mar 01 2014'
sun.after(6).greg().toDateString(); // 'Sat Mar 01 2014'
Returns an HDate corresponding to the specified day of week
before this Hebrew date.
Strictly before: if this date already falls on dayOfWeek, the
previous occurrence a week earlier is returned.
day of week: Sunday=0, Saturday=6
a new HDate; the original is not modified
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.
Hebrew date to compare
Returns a transliterated Hebrew month name, e.g. 'Elul' or 'Cheshvan'.
Converts this Hebrew date to the corresponding Gregorian date.
The returned Date object will be in the local (i.e. host system) time zone.
Hours, minutes, seconds and milliseconds will all be zero.
Note that this function returns the daytime portion of the date. For example, the 15th of Cheshvan 5769 began at sundown on 12 November 2008 and continues through 13 November 2008. This function would return only the date 13 November 2008.
Compares this Hebrew date to another date, returning true if the dates match.
Hebrew date to compare
Returns an HDate corresponding to the specified day of week
nearest to this Hebrew date.
Ties are broken forward: a date exactly 3 days from dayOfWeek in
both directions resolves to the later one.
day of week: Sunday=0, Saturday=6
a new HDate; the original is not modified
Returns an HDate corresponding to the specified day of week
on or after this Hebrew date
day of week: Sunday=0, Saturday=6
a new HDate; the original is not modified
const wed = new HDate(new Date('Wednesday February 19, 2014'));
const sat = new HDate(new Date('Saturday February 22, 2014'));
const sun = new HDate(new Date('Sunday February 23, 2014'));
wed.onOrAfter(6).greg().toDateString(); // 'Sat Feb 22 2014'
sat.onOrAfter(6).greg().toDateString(); // 'Sat Feb 22 2014'
sun.onOrAfter(6).greg().toDateString(); // 'Sat Mar 01 2014'
Returns an HDate corresponding to the specified day of week
on or before this Hebrew date
day of week: Sunday=0, Saturday=6
a new HDate; the original is not modified
const wed = new HDate(new Date('Wednesday February 19, 2014'));
const sat = new HDate(new Date('Saturday February 22, 2014'));
const sun = new HDate(new Date('Sunday February 23, 2014'));
wed.onOrBefore(6).greg().toDateString(); // 'Sat Feb 15 2014'
sat.onOrBefore(6).greg().toDateString(); // 'Sat Feb 22 2014'
sun.onOrBefore(6).greg().toDateString(); // 'Sat Feb 22 2014'
Returns the previous Hebrew date
a new HDate one day earlier; the original is not modified
Renders this Hebrew date as a translated or transliterated string,
including ordinal e.g. '15th of Cheshvan, 5769'.
Optionallocale: string
Optional locale name (defaults to active locale).
OptionalshowYear: boolean
Display year (defaults to true).
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'
console.log(hd.render('en', false)); // '15th of Cheshvan'
console.log(hd.render('he', false)); // '15 חֶשְׁוָן'
Renders this Hebrew date in Hebrew gematriya, regardless of locale.
OptionalsuppressNikud: boolean
suppress nekudot (default false)
OptionalsuppressYear: boolean
suppress Hebrew year (default false)
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 |
number of units to subtract (negative values add)
Optionalunits: FlexibleTimeUnit
unit of time, defaults to days
a new HDate; the original is not modified
StaticdayConvenience function for determining the R.D. date near a specified R.D. date, corresponding to the specified day of week.
Note: Applying this function to d+6 gives us the dayOfWeek on or after an
absolute day d. Similarly, applying it to d+3 gives the dayOfWeek nearest to
absolute date d, applying it to d-1 gives the dayOfWeek previous to absolute
date d, and applying it to d+7 gives the dayOfWeek following absolute date d.
The instance methods HDate.before, HDate.onOrBefore, HDate.nearest, HDate.onOrAfter and HDate.after wrap this with those offsets already applied.
day of week: Sunday=0, Saturday=6
R.D. number of days
R.D. number of days
StaticdaysStaticdaysStaticfromConstruct a new instance of HDate from a Gematriya-formatted string.
The string must have the form day-month-year, with the month name
written in Hebrew script (nikud optional, an optional bet prefix
allowed). A year below 1000 is assumed to omit the thousands and has
currentThousands added to it.
Hebrew date in gematriya, e.g. 'כ״ז בְּתַמּוּז תשפ״ג'
OptionalcurrentThousands: number
added to a year below 1000
the parsed Hebrew date
StaticgetReturns a transliterated string name of Hebrew month in year, for example 'Elul' or 'Cheshvan'.
Hebrew month (e.g. months.TISHREI)
Hebrew year
Statichebrew2absConverts Hebrew date to R.D. (Rata Die) fixed days. R.D. 1 is the imaginary date Monday, January 1, 1 on the Gregorian Calendar.
Hebrew year
Hebrew month (1=NISAN, 7=TISHREI)
Hebrew date (1-30)
StaticisStaticisStaticlongStaticmonthStaticmonthStaticmonthsStaticshort
A
HDaterepresents a Hebrew calendar date.An instance of this class encapsulates a date in the Hebrew calendar system. It consists of a year, month, and day, without any associated time or location data. The Hebrew calendar is a lunisolar calendar, meaning it is based on both lunar and solar cycles.
A Hebrew date internally stores three numbers:
This class uses Rata Die to convert between the Hebrew and Gregorian calendars.
To calculate times of day, use
Zmanimclass from@hebcal/coreSee