def _gentable(year, israel=False): """Return OrderedDict mapping date of Shabbos to list of parsha numbers. The numbers start with Beraishis as 0. Double parshios are represented as a list of the two numbers. If there is no Parsha the value is None. """ parshalist = deque([51, 52] + list(range(52))) table = OrderedDict() leap = HebrewDate._is_leap(year) pesachday = HebrewDate(year, 1, 15).weekday() rosh_hashana = HebrewDate(year, 7, 1) shabbos = (rosh_hashana + 2).shabbos() if rosh_hashana.weekday() > 4: parshalist.popleft() while shabbos.year == year: if _parshaless(shabbos, israel): table[shabbos] = None else: 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) or (parsha == 31 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) ): # If any of that then it's a double parsha. table[shabbos].append(parshalist.popleft()) shabbos += 7 return table
def _gentable(year, israel=False): """Return OrderedDict mapping date of Shabbos to list of parsha numbers. The numbers start with Beraishis as 0. Double parshios are represented as a list of the two numbers. If there is no Parsha the value is None. """ parshalist = deque([51, 52] + list(range(52))) table = OrderedDict() leap = HebrewDate._is_leap(year) pesachday = HebrewDate(year, 1, 15).weekday() rosh_hashana = HebrewDate(year, 7, 1) shabbos = rosh_hashana.shabbos() if rosh_hashana.weekday() > 4: parshalist.popleft() while shabbos.year == year: if _parshaless(shabbos, israel): table[shabbos] = None else: 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) or (parsha == 31 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)): # If any of that then it's a double parsha. table[shabbos].append(parshalist.popleft()) shabbos += 7 return table
def get_hebrew_independence_day(self, jewish_year): """ Returns the independence day eve and independence day dates according to the given hebrew year :param jewish_year: the specific hebrew year for calculating the independence day dates :return: independence day dates in the type of List[Tuple[HebrewDate, str]] """ month = 2 day = 5 original_hebrew_independence_date = HebrewDate(jewish_year, month, day) if original_hebrew_independence_date.weekday() == 6: day = 4 if original_hebrew_independence_date.weekday() == 7: day = 3 if original_hebrew_independence_date.weekday() == 2: day = 6 return [(HebrewDate(jewish_year, month, day - 1), "Independence Day Eve"), (HebrewDate(jewish_year, month, day), "Independence Day")]