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

Question about Yom Tov #240

Open
tom42530 opened this issue Sep 23, 2024 · 2 comments
Open

Question about Yom Tov #240

tom42530 opened this issue Sep 23, 2024 · 2 comments

Comments

@tom42530
Copy link

Hi,

I try to get Yom Tov start to end time but i don't how to get it.

For now i 'm able to know if current date is yomTov with

new JewishCalendar(lCalendar).isYomTov();

For example Rosh Hashana 2024 in Paris, i need have start time wednesday 2 october 19h09 and end time friday 4 octobre 20h10

Thanks in advance

@KosherJava
Copy link
Owner

@tom42530 ,
The JewishCalendar has no concept of time. There are a few steps needed for your use case. You are on the correct track though.

  1. Check to see if today is EREV Yom Tov by calling isErevYomTov().
  2. Since Erev Yom Tov can sometimes be on a Shabbos, you have to check if today is isAssurBemelacha() before determining what time Yom Tov starts.
  3. hasCandleLighting() will be helpful.
  4. To get the TIME of either candle lighting, sunset, tzais etc, you have to use the ZmanimCalendar or ComplexZmanimCalendar to get the times (there are too many opinions for the code to guess what you would like).

Please let me know if there is anything else that I can help clarify.

@tom42530
Copy link
Author

Ok thanks for the clarification.

here's my working method.

   boolean isYomTov() {
        Calendar lCalendarTomorrow = Calendar.getInstance();
        lCalendarTomorrow.setTimeInMillis(getNow().getTimeInMillis());
        lCalendarTomorrow.add(Calendar.DATE, 1);


        if (isWorkProhibed(getNow()) && isWorkProhibed(lCalendarTomorrow)) {
            return true;
        } else if (isWorkProhibed(lCalendarTomorrow)) {
            final long lNowMs = getNow().getTimeInMillis();
            return lNowMs >= DateUtils.ceiling(buildComplexZmanimCalendar(getNow()).getCandleLighting(), Calendar.MINUTE).getTime();
        } else if (isWorkProhibed(getNow())) {
            final long lNowMs = getNow().getTimeInMillis();
            return lNowMs < DateUtils.ceiling(buildComplexZmanimCalendar(getNow()).getTzaisGeonim8Point5Degrees(), Calendar.MINUTE).getTime();
        } else {
            return false;
        }
    }


    private boolean isWorkProhibed(Calendar aCalendar) {
        JewishCalendar lJewishCalendar = new JewishCalendar(aCalendar);
        return lJewishCalendar.isYomTov() && lJewishCalendar.isAssurBemelacha();
    }

Feel free to send me remarks if nomething wrong.

Thanks for your work

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

No branches or pull requests

2 participants