GithubHelp home page GithubHelp logo

Comments (11)

KosherJava avatar KosherJava commented on August 15, 2024

@srulih ,
Thanks for your report. This was done by design, and the documentation is clear about it. I am open to change it (I get contacted about this from time to time). The design for this was for a luach, and in almost all cases returning a parsha during the week would force the developer to code to exclude the parsha display if it was not Shabbos. Please note that the current code will NOT work as expected if you comment out the https://github.com/KosherJava/zmanim/blob/master/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java#L463 line. I am open to a PR to change the current behavior.

from zmanim.

zachweix avatar zachweix commented on August 15, 2024

You can always just do a look-ahead to see what is this coming shabbos's parsha

from zmanim.

KosherJava avatar KosherJava commented on August 15, 2024

@zachweix , that is true, but comes with a small performance hit.
@srulih , what would be your expectation when the next Shabbos (or 2) are Yomim Tovim. Would you expect it to show the parsha of the next regular parsha for a few weeks? It would help to know your use case. Is it just for Shabbos Mincha, sheni vachamishi laining, or do you have something else in mind?

from zmanim.

srulih avatar srulih commented on August 15, 2024

from zmanim.

KosherJava avatar KosherJava commented on August 15, 2024

@srulih , I understand what you want, but I am trying to understand the point (I am sure that you have a good reason, but I am curious). About my other question, if you are between YK and Sukkos and want the parsha, when the next one or 2 weeks may have no parsha, would you expect it to return Bereishis that will occur in a few weeks, or NONE? The same can happen by Pesach.

from zmanim.

KosherJava avatar KosherJava commented on August 15, 2024

@srulih and @zachweix , assuming we build a getUpcomingParsha(), if you call it when the date is set to Shabbos, would you expect it to return the parsha of the current parsha, or the following one?

from zmanim.

zachweix avatar zachweix commented on August 15, 2024

That's an interesting question. I like to show the parsha every day on a calendar, so that if you're looking on Wednesday you know that shabbos is Toldos (for example) and on shabbos you know it's toldos. But in theory I can first check the parsha and then only if that fails get the upcoming parsha.

from zmanim.

srulih avatar srulih commented on August 15, 2024

from zmanim.

KosherJava avatar KosherJava commented on August 15, 2024

Yes it implies that, but it also forces the person using the API to check the day of week. In any case, @zachweix and @srulih ,
How does this look?

public Parsha getUpcomingParshah() {
    JewishCalendar clone = (JewishCalendar) clone();
    int daysToShabbos = ((int) Calendar.SATURDAY - getDayOfWeek()  + 7) % 7;
    clone.forward(Calendar.DATE, daysTohabbos);
    while(clone.getParshah() == Parsha.NONE) {
        clone.forward(Calendar.DATE, 7);
    }
    return clone.getParshah();
}

from zmanim.

zachweix avatar zachweix commented on August 15, 2024

Interesting, this way when Pesach starts on shabbos for example, then the 9th of nissan will return the parsha on the 29th.

from zmanim.

KosherJava avatar KosherJava commented on August 15, 2024

Slightly tweaked to guard against an error when it is Shabbos

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

from zmanim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.