Open yskraus opened 3 years ago
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
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
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:
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 typesYou 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
please let me know if im wrong but there is no easy way to get this years Rosh hashana based on the gregorian calendar