Comments (11)
@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.
You can always just do a look-ahead to see what is this coming shabbos's parsha
from zmanim.
@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.
from zmanim.
@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.
@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.
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.
from zmanim.
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.
Interesting, this way when Pesach starts on shabbos for example, then the 9th of nissan will return the parsha on the 29th.
from zmanim.
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)
- More `JewishCalendar` Tefila Rules / Special Days HOT 14
- Bain Hashmashos Spelled Hasmoshos
- isYomTov()
- add special Shabbasos
- check for machar_rosh_chodesh accounts for wday? HOT 1
- go-zmanim
- Yerushami Daf Yomi Trasliterated name error in order HOT 1
- Wrong formatter used on test output - LOW priority HOT 2
- In getDafYomiYerushalmi() [LastMischta, LastMesechtahMaxDaf + 1] returned for Daf 1 of Meschtas after Brachos HOT 2
- Spelling ? Kilayim כלאיים
- Flaw in logic? HOT 2
- Why use StringBuffer instead of StringBuilder? HOT 5
- Why Tfila vs. Tfilah?
- Spelling errors
- Identifying a zman?
- Add Mizmor Lesoda to TefilaRules HOT 10
- Cannot translate the parsha from the new API HOT 1
- Shushan Purim Katan is misspelled in Hebrew HOT 4
- VBA and VB6 port - vbzmanim HOT 2
- `NullPointerException` in `HebrewDateFormatter.formatDayOfWeek` due to uninitialized `weekFormat` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zmanim.