JewishDate class
The JewishDate is the base calendar class, that supports maintenance of a DateTime instance along with the corresponding Jewish date. This class does not have a concept of a time (which the DateTime class does). Please note that the calendar does not currently support dates prior to 1/1/1 Gregorian. Also keep in mind that the Gregorian calendar started on October 15, 1582, so any calculations prior to that are suspect (at least from a Gregorian perspective). While 1/1/1 Gregorian and forward are technically supported, any calculations prior to Hillel II (Hakatan)'s calendar (4119 in the Jewish Calendar / 359 CE Julian as recorded by Rav Hai Gaon) would be just an approximation.
This open source Dart code was ported from the KosherJava Zmanim library originally written by Avrom Finkelstien in C++ and refactored to Java by Eliyahu Hershfeld, with simplification of the code, enhancements and some bug fixing.
Some of Avrom's original C++ code was translated from C/C++ code in Calendrical Calculations by Nachum Dershowitz and Edward M. Reingold, Software-- Practice & Experience, vol. 20, no. 9 (September, 1990), pp. 899-928. Any method marked "ND+ER" indicates that the method was taken from this source with minor modifications.
If you are looking for a class that implements a Jewish calendar version of the calendar, one is available from the ICU (International Components for Unicode) project, formerly part of IBM's DeveloperWorks.
See also JewishCalendar. See also HebrewDateFormatter. See also DateTime. © Avrom Finkelstien 2002 © Eliyahu Hershfeld 2011 - 2019
- Implemented types
- Implementers
Constructors
- JewishDate()
- Default constructor will set a default date to the current system date.
- JewishDate.fromDateTime(DateTime dateTime)
- A constructor that initializes the date to the DateTime parameter.
- JewishDate.fromMolad(double molad)
- Constructor that creates a JewishDate based on a molad passed in. The molad would be the number of chalakim/parts starting at the beginning of Sunday prior to the molad Tohu BeHaRaD (Be = Monday, Ha= 5 hours and Rad =204 chalakim/parts) - prior to the start of the Jewish calendar. BeHaRaD is 23:11:20 on Sunday night(5 hours 204/1080 chalakim after sunset on Sunday evening).
- JewishDate.initDate({required int jewishYear, required int jewishMonth, required int jewishDayOfMonth, int hour = 12, int minute = 0, int second = 0})
- Creates a Jewish date based on a Jewish year, month and day of month.
Properties
- hashCode → int
-
Returns a hash code based on the absolute Gregorian date.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
back(
[Calendar field = Calendar.DATE, int amount = 1]) → void - Rolls the date back by the specified field and amount. Supports Calendar.DATE (default), Calendar.MONTH, and Calendar.YEAR.
-
clone(
) → JewishDate - Creates a deep copy of this object.
-
compareTo(
JewishDate jewishDate) → int -
Compares two dates as per the compareTo() method in the Comparable interface. Returns a value less than 0 if this
date is "less than" (before) the date, greater than 0 if this date is "greater than" (after) the date, or 0 if
they are equal.
override
-
forward(
[Calendar field = Calendar.DATE, int amount = 1]) → void - Rolls the date, month or year forward by the amount passed in. It modifies both the Gregorian and Jewish dates accordingly. If manipulation beyond the fields supported here is required, use DateTime arithmetic and pass the result back via setDate. For example:
-
getAbsDate(
) → int - Returns the absolute date (days since January 1, 0001 on the Gregorian calendar).
-
getChalakimSinceMoladTohu(
) → double - Returns the number of chalakim (parts - 1080 to the hour) from the original hypothetical Molad Tohu to the Jewish year and month that this Object is set to.
-
getCheshvanKislevKviah(
) → int - Returns the Cheshvan and Kislev kviah (whether a Jewish year is short, regular or long). It will return SHELAIMIM if both cheshvan and kislev are 30 days, KESIDRAN if Cheshvan is 29 days and Kislev is 30 days and CHASERIM if both are 29 days.
-
getDayOfWeek(
) → int - Returns the day of the week as a number between 1-7.
-
getDaysInJewishMonth(
) → int - Returns the number of days of the Jewish month that the calendar is currently set to.
-
getDaysInJewishYear(
) → int - Returns the number of days for the current year that the calendar is set to.
-
getDaysSinceStartOfJewishYear(
) → int - returns the number of days from Rosh Hashana of the date passed in, to the full date passed in.
-
getGregorianCalendar(
) → DateTime - Returns this object's date as a DateTime object.
-
getGregorianDayOfMonth(
) → int - Returns the Gregorian day of the month.
-
getGregorianMonth(
) → int - Returns the Gregorian month (between 0-11).
-
getGregorianYear(
) → int - Returns the Gregorian year.
-
getJewishDayOfMonth(
) → int - Returns the Jewish day of month.
-
getJewishMonth(
) → int - Returns the Jewish month 1-12 (or 13 years in a leap year). The month count starts with 1 for Nisan and goes to 13 for Adar II
-
getJewishYear(
) → int - Returns the Jewish year.
-
getLastDayOfGregorianMonth(
int month) → int - Returns the last day in a gregorian month
-
getMolad(
) → JewishDate - Returns the molad for a given year and month. Returns a JewishDate Object set to the date of the molad with the getMoladHours, getMoladMinutes and getMoladChalakim set. In the current implementation, it sets the molad time based on a midnight date rollover. This means that Rosh Chodesh Adar II, 5771 with a molad of 7 chalakim past midnight on Shabbos 29 Adar I / March 5, 2011 12:00 AM and 7 chalakim, will have the following values: hours: 0, minutes: 0, Chalakim: 7.
-
getMoladChalakim(
) → int - Returns the molad chalakim/parts. Only an object populated with getMolad, setJewishDate or or setMoladChalakim will have these fields populated. A regular JewishDate object will have this field set to 0.
-
getMoladHours(
) → int - Returns the molad hours. Only a JewishDate object populated with getMolad, setJewishDate or setMoladHours will have this field populated. A regular JewishDate object will have this field set to 0.
-
getMoladMinutes(
) → int - Returns the molad minutes. Only an object populated with getMolad, setJewishDate or or setMoladMinutes will have these fields populated. A regular JewishDate object will have this field set to 0.
-
isCheshvanLong(
) → bool - Returns if Cheshvan is long (30 days VS 29 days) for the current year that the calendar is set to. The method name isLong is done since in a Kesidran (ordered) year Cheshvan is short.
-
isGregorianLeapYear(
int year) → bool - Returns is the year passed in is a Gregorian leap year.
-
isJewishLeapYear(
) → bool - Returns if the year the calendar is set to is a Jewish leap year. Years 3, 6, 8, 11, 14, 17 and 19 in the 19 year cycle are leap years.
-
isKislevShort(
) → bool - Returns if the Kislev is short for the year that this class is set to. The method name isShort is done since in a Kesidran (ordered) year Kislev is long.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resetDate(
) → void - Resets this date to the current system date.
-
setDate(
DateTime dateTime) → void - Sets the date based on a DateTime object. Modifies the Jewish date as well.
-
setGregorianDate(
int year, int month, int dayOfMonth) → void - Sets the Gregorian Date, and updates the Jewish date accordingly. A value of 0 is expected for January (0-based months).
-
setGregorianDayOfMonth(
int dayOfMonth) → void - sets the Gregorian Day of month.
-
setGregorianMonth(
int month) → void - Sets the Gregorian month.
-
setGregorianYear(
int year) → void - sets the Gregorian year.
-
setJewishDate(
int year, int month, int dayOfMonth, [int hours = 0, int minutes = 0, int chalakim = 0]) → void - Sets the Jewish Date and updates the Gregorian date accordingly.
-
setJewishDayOfMonth(
int dayOfMonth) → void - sets the Jewish day of month.
-
setJewishMonth(
int month) → void - sets the Jewish month.
-
setJewishYear(
int year) → void - sets the Jewish year.
-
setMoladChalakim(
int moladChalakim) → void - Sets the molad chalakim/parts. The expectation is that the traditional minute-less chalakim will be broken out to setMoladMinutes and chalakim, so 793 (TaShTZaG) parts would have the minutes set to 44 and chalakim to 1.
-
setMoladHours(
int moladHours) → void - Sets the molad hours.
-
setMoladMinutes(
int moladMinutes) → void - Sets the molad minutes. The expectation is that the traditional minute-less chalakim will be broken out to minutes and setMoladChalakim , so 793 (TaShTZaG) parts would have the minutes set to 44 and chalakim to 1.
-
toString(
) → String -
Returns a string containing the Jewish date in the form, "day Month, year" e.g. "21 Shevat, 5729". For more
complex formatting, use the formatter classes.
override
Operators
-
operator ==(
Object object) → bool -
Two JewishDate objects are equal if they represent the same absolute date.
override
Static Methods
-
getJewishCalendarElapsedDays(
int year) → int - Returns the number of days elapsed from the Sunday prior to the start of the Jewish calendar to the mean conjunction of Tishri of the Jewish year.
Constants
- ADAR → const int
- Value of the month field indicating Adar (or Adar I in a isJewishLeapYear), the twelfth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 6th month of the year.
- ADAR_II → const int
- Value of the month field indicating Adar II, the leap (intercalary or embolismic) thirteenth (Undecimber) numeric month of the year added in Jewish isJewishLeapYear). The leap years are years 3, 6, 8, 11, 14, 17 and 19 of a 19 year cycle. With the year starting at TISHREI, it would actually be the 7th month of the year.
- AV → const int
- Value of the month field indicating Av, the fifth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 11th (or 12th in a isJewishLeapYear) month of the year.
- CHASERIM → const int
- A short year where both CHESHVAN and KISLEV are 29 days.
- CHESHVAN → const int
- Value of the month field indicating Cheshvan/marcheshvan, the eighth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 2nd month of the year.
- ELUL → const int
- Value of the month field indicating Elul, the sixth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 12th (or 13th in a isJewishLeapYear) month of the year.
- friday → const int
- IYAR → const int
- Value of the month field indicating Iyar, the second numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 8th (or 9th in a isJewishLeapYear) month of the year.
- KESIDRAN → const int
- An ordered year where CHESHVAN is 29 days and KISLEV is 30 days.
- KISLEV → const int
- Value of the month field indicating Kislev, the ninth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 3rd month of the year.
- monday → const int
- NISSAN → const int
- Value of the month field indicating Nissan, the first numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 7th (or 8th in a isJewishLeapYear) month of the year.
- saturday → const int
- SHELAIMIM → const int
- A long year where both CHESHVAN and KISLEV are 30 days.
- SHEVAT → const int
- Value of the month field indicating Shevat, the eleventh numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 5th month of the year.
- SIVAN → const int
- Value of the month field indicating Sivan, the third numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 9th (or 10th in a isJewishLeapYear) month of the year.
- sunday → const int
- TAMMUZ → const int
- Value of the month field indicating Tammuz, the fourth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 10th (or 11th in a isJewishLeapYear) month of the year.
- TEVES → const int
- Value of the month field indicating Teves, the tenth numeric month of the year in the Jewish calendar. With the year starting at TISHREI, it would actually be the 4th month of the year.
- thursday → const int
- TISHREI → const int
- Value of the month field indicating Tishrei, the seventh numeric month of the year in the Jewish calendar. With the year starting at this month, it would actually be the 1st month of the year.
- tuesday → const int
- wednesday → const int