Skip to content

Commit

Permalink
Changed gentable to use enum for parshios.
Browse files Browse the repository at this point in the history
  • Loading branch information
simlist committed Sep 10, 2024
1 parent b92400e commit 1e980e6
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/pyluach/parshios.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from collections import deque, OrderedDict
from functools import lru_cache
from enum import IntEnum, auto
from enum import Enum, IntEnum, auto

from pyluach.dates import HebrewDate
from pyluach.utils import _is_leap
Expand Down Expand Up @@ -152,15 +152,31 @@ def _gentable(year, israel=False):
parsha = parshalist.popleft()
table[shabbos] = [parsha]
if (
(parsha == 21 and (HebrewDate(year, 1, 14) - shabbos) // 7 < 3)
or (parsha in [26, 28] and not leap)
(
parsha == _Parshios_Enum.VAYAKHEL
and (HebrewDate(year, 1, 14) - shabbos) // 7 < 3
)
or (
parsha in [
_Parshios_Enum.TAZRIA, _Parshios_Enum.ACHAREI_MOS
] and not leap
)
or (
parsha == 31 and not leap
parsha == _Parshios_Enum.BEHAR and not leap
and (not israel or pesachday != 7)
)
or (parsha == 38 and not israel and pesachday == 5)
or (parsha == 41 and (HebrewDate(year, 5, 9)-shabbos) // 7 < 2)
or (parsha == 50 and HebrewDate(year+1, 7, 1).weekday() > 4)
or (
parsha == _Parshios_Enum.CHUKAS
and not israel and pesachday == 5
)
or (
parsha == _Parshios_Enum.MATTOS
and (HebrewDate(year, 5, 9)-shabbos) // 7 < 2
)
or (
parsha == _Parshios_Enum.NITZAVIM
and HebrewDate(year+1, 7, 1).weekday() > 4
)
):
# If any of that then it's a double parsha.
table[shabbos].append(parshalist.popleft())
Expand Down

0 comments on commit 1e980e6

Please sign in to comment.