add two methods to check for this week's parasha#232
Open
Elyahu41 wants to merge 1 commit intoKosherJava:masterfrom
Open
add two methods to check for this week's parasha#232Elyahu41 wants to merge 1 commit intoKosherJava:masterfrom
Elyahu41 wants to merge 1 commit intoKosherJava:masterfrom
Conversation
Owner
|
@Elyahu41 . Have a look at getUpcomingParshah() |
KosherJava
reviewed
Jan 26, 2024
| * | ||
| * @return the upcoming <em>parsha</em>. | ||
| */ | ||
| public Parsha getThisWeeksParshah() { |
Owner
There was a problem hiding this comment.
@Elyahu41 , the name needs more clarity (I think). getUpcomingParsha is very similar, with the only difference being that this will return null if it is YT. We probably want to overrride getUcomomingParsha() with a boolean to control this, and we can deprecate the one without a parameter for removal in 3.0.
Contributor
Author
There was a problem hiding this comment.
I understand. How about something like this:
public Parsha getUpcomingParshah(boolean thisWeek) {
JewishCalendar clone = (JewishCalendar) clone();
int daysToShabbos = (Calendar.SATURDAY - getDayOfWeek() + 7) % 7;
if (getDayOfWeek() != Calendar.SATURDAY) {
clone.forward(Calendar.DATE, daysToShabbos);
if (thisWeek) {
return clone.getParshah();
}
} else {
clone.forward(Calendar.DATE, 7);
}
while(clone.getParshah() == Parsha.NONE) { //Yom Kippur / Sukkos or Pesach with 2 potential non-parsha Shabbosim in a row
clone.forward(Calendar.DATE, 7);
}
return clone.getParshah();
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These methods were helpful to me because I just wanted to know what to read for Shnayim mikra weekly. The other getUpcomingParasha method will confuse people, in my opinion, because it will return a parasha in a week or two from now when the user might want to just know if there is a parasha this week or not.
There is also a second method for getSpecialShabbos