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

Get rosh Hashanah based on gregorian calendar #23

Open
yskraus opened this issue Jul 27, 2021 · 4 comments
Open

Get rosh Hashanah based on gregorian calendar #23

yskraus opened this issue Jul 27, 2021 · 4 comments

Comments

@yskraus
Copy link

yskraus commented Jul 27, 2021

please let me know if im wrong
but there is no easy way to get this years Rosh hashana based on the gregorian calendar

@zachweix
Copy link
Contributor

I'm not sure if it's documented, but you can use this static function to get the date of Rosh Hashana for this Jewish year. https://github.com/zmanim/zman/blob/main/src/Moadim/Holidays.php#L46
The only catch is that you need to figure out if it's before or after Rosh Hashana right now in the Gregorian calendar to see whether you need to add 1 to the year

@yskraus
Copy link
Author

yskraus commented Jul 27, 2021

so I need to check if today is after rosh hashona
I need to add a year to the Hebrew date then get the rosh hashing from next year
why not have it in a constructor to pass the gregorian year and get rosh hashona or any other holiday
right now you can only pass the Hebrew year

@tam5
Copy link
Contributor

tam5 commented Jul 27, 2021

but there is no easy way to get this years Rosh hashana based on the gregorian calendar

Right now, it could be accomplished via something like:

Zman::firstDayOfRoshHashana(
    Zman::parse('April 11, 2017')->jewishYear
);

// or
Zman::firstDayOfRoshHashana(
    Zman::now()->next('year')->jewishYear
);

which honestly seems simple enough to me to be getting on with.


so I need to check if today is after rosh hashona

This is the hardest part of what you are proposing. "After rosh hashona" is ambiguous, as you will always be after the last rosh hashana and before the next rosh hashana. Plus, since there are different ways to count "this year" i.e. tishrei vs nissan etc, I don't think we should really guess which one you meant.

It's for that reason that you need to explicitly specify the year for the rosh hashana you want.


I see a few ways this could be made a bit easier though:

  1. We could allow the firstDayOfRoshHashana function to be smart enough to accept either gregorian or jewish, and know that something like 5XXX is jewish and something like 2XXX is gregorian. I've avoided doing that so far, but I'm not super opposed if it will help.
  2. We recently added a comingShabbos (which mb should be renamed to nextShabbos), we could do a similar thing and add a nextRoshHashana which my hunch tells me is what you are actually after rather than something specific to calendar types

@zachweix
Copy link
Contributor

You don't need to say 5XXX vs 2XXX. You can get the Rosh Hashana for the current Gregorian year as follows: Get the current Jewish year (e.g. 5781) and get the current Gregorian year (e.g. 2021). If the difference is 3760, then we know that it is before Rosh Hashana and if the difference is 3761 then we know that it is after Rosh Hashana. If it's before then we get the first day of Rosh Hashana for the current Jewish year plus one. If it's after then we just get the first day of Rosh Hashana for the current year

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

3 participants