Skip to content

Commit

Permalink
add two methods to check for this week's parasha
Browse files Browse the repository at this point in the history
  • Loading branch information
Ely committed Jan 14, 2024
1 parent 2638fc3 commit 8d8b897
Showing 1 changed file with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,38 @@ public Parsha getParshah() {
}
return Parsha.NONE; //keep the compiler happy
}

/**
* Returns this week's {@link Parsha <em>Parsha</em>} regardless of if it is the weekday or <em>Shabbos</em> (where next
* Shabbos's <em>Parsha</em> will be returned. If the upcoming <em>Shabbos</em> is a <em>Yom Tov</em> and has no <em>Parsha</em>,
* {@link Parsha#NONE} will be returned.
*
* @return the upcoming <em>parsha</em>.
*/
public Parsha getThisWeeksParshah() {
JewishCalendar clone = (JewishCalendar) clone();
int daysToShabbos = (Calendar.SATURDAY - getDayOfWeek() + 7) % 7;
if (getDayOfWeek() != Calendar.SATURDAY) {
clone.forward(Calendar.DATE, daysToShabbos);
}
return clone.getParshah();
}

/**
* Returns this week's {@link #getSpecialShabbos() special shabbos} regardless of if it is the weekday or <em>Shabbos</em> (where next
* Shabbos's <em>Parsha</em> will be returned. If the upcoming <em>Shabbos</em> is a <em>Yom Tov</em> and has no <em>Parsha</em>
* or special shabbos, {@link Parsha#NONE} will be returned.
*
* @return the upcoming <em>parsha</em>.
*/
public Parsha getThisWeeksSpecialParshah() {
JewishCalendar clone = (JewishCalendar) clone();
int daysToShabbos = (Calendar.SATURDAY - getDayOfWeek() + 7) % 7;
if (getDayOfWeek() != Calendar.SATURDAY) {
clone.forward(Calendar.DATE, daysToShabbos);
}
return clone.getSpecialShabbos();
}

/**
* Returns the upcoming {@link Parsha <em>Parsha</em>} regardless of if it is the weekday or <em>Shabbos</em> (where next
Expand All @@ -517,7 +549,7 @@ public Parsha getParshah() {
*/
public Parsha getUpcomingParshah() {
JewishCalendar clone = (JewishCalendar) clone();
int daysToShabbos = (Calendar.SATURDAY - getDayOfWeek() + 7) % 7;
int daysToShabbos = (Calendar.SATURDAY - getDayOfWeek() + 7) % 7;
if (getDayOfWeek() != Calendar.SATURDAY) {
clone.forward(Calendar.DATE, daysToShabbos);
} else {
Expand Down

0 comments on commit 8d8b897

Please sign in to comment.