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)Optional
day: 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.
Optional
month: string | numberHebrew month of year (1=NISAN, 7=TISHREI)
Optional
year: numberHebrew 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)
Optional
rdabsolute 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 |
Optional
units: stringReturns 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
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
Renders this Hebrew date as a translated or transliterated string,
including ordinal e.g. '15th of Cheshvan, 5769'
.
Optional
locale: stringOptional locale name (defaults to active locale).
Optional
showYear: booleanDisplay 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 חֶשְׁוָן'
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 |
Optional
units: stringStatic
dayConvenience 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.
day of week: Sunday=0, Saturday=6
Static
daysStatic
daysStatic
fromStatic
getStatic
hebrew2absStatic
isHDateStatic
isStatic
longStatic
monthStatic
monthStatic
monthsStatic
short
A
HDate
represents 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
Zmanim
class from@hebcal/core
See