Skip to content

Commit

Permalink
isYomTov() now returns true for 20 Nissan
Browse files Browse the repository at this point in the history
Thanks Shai for catching this 11 year old bug.
  • Loading branch information
KosherJava authored Aug 4, 2024
1 parent db82893 commit 4e5abe6
Showing 1 changed file with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Zmanim Java API
* Copyright (C) 2011 - 2023 Eliyahu Hershfeld
* Copyright (C) 2011 - 2024 Eliyahu Hershfeld
* Copyright (C) September 2002 Avrom Finkelstien
* Copyright (C) 2019 - 2022 Y Paritcher
*
Expand All @@ -26,7 +26,7 @@

/**
* The JewishCalendar extends the JewishDate class and adds calendar methods.
* <p>
*
* This open source Java code was originally ported by <a href="http://www.facebook.com/avromf">Avrom Finkelstien</a>
* from his C++ code. It was refactored to fit the KosherJava Zmanim API with simplification of the code, enhancements
* and some bug fixing. The class allows setting whether the holiday and <em>parsha</em> scheme follows the Israel scheme
Expand All @@ -42,7 +42,7 @@
* @see java.util.Calendar
* @author &copy; Y. Paritcher 2019 - 2022
* @author &copy; Avrom Finkelstien 2002
* @author &copy; Eliyahu Hershfeld 2011 - 2023
* @author &copy; Eliyahu Hershfeld 2011 - 2024
*/
public class JewishCalendar extends JewishDate {
/** The 14th day of Nissan, the day before Pesach (Passover).*/
Expand Down Expand Up @@ -387,9 +387,8 @@ public boolean isBirkasHachamah() {
* Rosh Hashana as 1, we have to add 1 day for a total of 171. To this add a day since the tekufah is on a Tuesday
* night, and we push off the bracha to Wednesday morning resulting in the 172 used in the calculation.
*/
// 28 years of 365.25 days + the offset from molad tohu mentioned above
return elapsedDays % (28 * 365.25) == 172;
}
return elapsedDays % (28 * 365.25) == 172; // 28 years of 365.25 days + the offset from molad tohu mentioned above
}

/**
* Return the type of year for <em>parsha</em> calculations. The algorithm follows the
Expand Down Expand Up @@ -704,7 +703,7 @@ public int getYomTovIndex() {
if (day == 15 || (day == 16 && !inIsrael)) {
return SUCCOS;
}
if (day >= 17 && day <= 20 || day == 16) {
if (day >= 16 && day <= 20) {
return CHOL_HAMOED_SUCCOS;
}
if (day == 21) {
Expand Down Expand Up @@ -785,7 +784,7 @@ public int getYomTovIndex() {
/**
* Returns true if the current day is <em>Yom Tov</em>. The method returns true even for holidays such as {@link #CHANUKAH}
* and minor ones such as {@link #TU_BEAV} and {@link #PESACH_SHENI}. <em>Erev Yom Tov</em> (with the exception of
* {@link #HOSHANA_RABBA}, and <em>erev</em> the second days of {@link #PESACH}) returns false, as do {@link #isTaanis() fast
* {@link #HOSHANA_RABBA} and <em>erev</em> the second days of {@link #PESACH}) returns false, as do {@link #isTaanis() fast
* days} besides {@link #YOM_KIPPUR}. Use {@link #isAssurBemelacha()} to find the days that have a prohibition of work.
*
* @return true if the current day is a Yom Tov
Expand All @@ -799,7 +798,7 @@ public int getYomTovIndex() {
*/
public boolean isYomTov() {
int holidayIndex = getYomTovIndex();
if ((isErevYomTov() && (holidayIndex != HOSHANA_RABBA || (holidayIndex == CHOL_HAMOED_PESACH && getJewishDayOfMonth() != 20)))
if ((isErevYomTov() && (holidayIndex != HOSHANA_RABBA && holidayIndex != CHOL_HAMOED_PESACH))
|| (isTaanis() && holidayIndex != YOM_KIPPUR) || holidayIndex == ISRU_CHAG) {
return false;
}
Expand Down Expand Up @@ -1065,9 +1064,8 @@ public boolean isYomKippurKatan() {
if (day == 29 && dayOfWeek != Calendar.FRIDAY && dayOfWeek != Calendar.SATURDAY) {
return true;
}

return (day == 27 || day == 28) && dayOfWeek == Calendar.THURSDAY;
}
return (day == 27 || day == 28) && dayOfWeek == Calendar.THURSDAY;
}

/**
* The Monday, Thursday and Monday after the first <em>Shabbos</em> after {@link #isRoshChodesh() <em>Rosh Chodesh</em>}
Expand All @@ -1084,8 +1082,8 @@ public boolean isBeHaB() {
int day = getJewishDayOfMonth();

if (month == JewishDate.CHESHVAN || month == JewishDate.IYAR) {
return (dayOfWeek == Calendar.MONDAY && day > 4 && day < 18)
|| (dayOfWeek == Calendar.THURSDAY && day > 7 && day < 14);
return (dayOfWeek == Calendar.MONDAY && day > 4 && day < 18)
|| (dayOfWeek == Calendar.THURSDAY && day > 7 && day < 14);
}
return false;
}
Expand Down Expand Up @@ -1419,7 +1417,7 @@ public int getTekufasTishreiElapsedDays() {
public boolean isVeseinTalUmatarStartDate() {
if (inIsrael) {
// The 7th Cheshvan can't occur on Shabbos, so always return true for 7 Cheshvan
return getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 7;
return getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 7;
} else {
if (getDayOfWeek() == Calendar.SATURDAY) { //Not recited on Friday night
return false;
Expand All @@ -1430,7 +1428,7 @@ public boolean isVeseinTalUmatarStartDate() {
return getTekufasTishreiElapsedDays() == 47;
}
}
}
}

/**
* Returns true if tonight is the first night to start reciting <em>Vesein Tal Umatar Livracha</em> (
Expand All @@ -1453,7 +1451,7 @@ public boolean isVeseinTalUmatarStartDate() {
public boolean isVeseinTalUmatarStartingTonight() {
if (inIsrael) {
// The 7th Cheshvan can't occur on Shabbos, so always return true for 6 Cheshvan
return getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 6;
return getJewishMonth() == CHESHVAN && getJewishDayOfMonth() == 6;
} else {
if (getDayOfWeek() == Calendar.FRIDAY) { //Not recited on Friday night
return false;
Expand All @@ -1464,7 +1462,7 @@ public boolean isVeseinTalUmatarStartingTonight() {
return getTekufasTishreiElapsedDays() == 46;
}
}
}
}

/**
* Returns if <em>Vesein Tal Umatar Livracha</em> (<em>Sheailas Geshamim</em>) is recited. This will return
Expand Down

0 comments on commit 4e5abe6

Please sign in to comment.