diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java index 85042bad..c18bf177 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishDate.java @@ -21,6 +21,8 @@ import java.util.Calendar; import java.util.GregorianCalendar; +import com.kosherjava.zmanim.ComplexZmanimCalendar; + /** * The JewishDate is the base calendar class, that supports maintenance of a {@link java.util.GregorianCalendar} * instance along with the corresponding Jewish date. This class can use the standard Java Date and Calendar @@ -992,6 +994,17 @@ public JewishDate(int jewishYear, int jewishMonth, int jewishDayOfMonth) { public JewishDate() { resetDate(); } + + /** + * A constructor that initializes the date to the current system date while taking into account sunset. + */ + public JewishDate(ComplexZmanimCalendar czc) { + if (Calendar.getInstance().after(czc.getSunset())) { + resetDateWithSunset(); + } else { + resetDate(); + } + } /** * A constructor that initializes the date to the {@link java.util.Date Date} paremeter. @@ -1220,6 +1233,15 @@ public void resetDate() { Calendar calendar = Calendar.getInstance(); setDate(calendar); } + + /** + * Resets this date to the current system date plus one (after sunset). + */ + public void resetDateWithSunset() { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH, 1); + setDate(calendar); + } /** * Returns a string containing the Jewish date in the form, "day Month, year" e.g. "21 Shevat, 5729". For more