Skip to content

Question about Yom Tov #240

Open
Open

Description

@tom42530

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

Activity

  1. KosherJava commented on Sep 23, 2024

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

  2. tom42530 commented on Sep 23, 2024

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions