Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add two methods to check for this week's parasha #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Elyahu41
Copy link
Contributor

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

@KosherJava
Copy link
Owner

@Elyahu41 . Have a look at getUpcomingParshah()

*
* @return the upcoming <em>parsha</em>.
*/
public Parsha getThisWeeksParshah() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Contributor Author

@Elyahu41 Elyahu41 Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants