Ejemplo n.º 1
0
 def test_eighth_day_pesach(self):
     eighth_day_pesach = dates.HebrewDate(5779, 1, 22)
     reunion_shabbos = dates.HebrewDate(5779, 5, 2)
     assert parshios.getparsha_string(eighth_day_pesach) is None
     assert parshios.getparsha_string(eighth_day_pesach, True) == 'Acharei Mos'
     assert parshios.getparsha(eighth_day_pesach + 7) == [28,]
     assert parshios.getparsha(eighth_day_pesach + 7, True) == [29,]
     assert parshios.getparsha_string(reunion_shabbos) == "Matos, Ma'sei"
     assert parshios.getparsha_string(reunion_shabbos, True) == "Ma'sei"
Ejemplo n.º 2
0
 def test_eighth_day_pesach(self):
     eighth_day_pesach = dates.HebrewDate(5779, 1, 22)
     reunion_shabbos = dates.HebrewDate(5779, 5, 2)
     assert parshios.getparsha_string(eighth_day_pesach) is None
     assert parshios.getparsha_string(eighth_day_pesach, True) == 'Acharei Mos'
     assert parshios.getparsha(eighth_day_pesach + 7) == [28,]
     assert parshios.getparsha(eighth_day_pesach + 7, True) == [29,]
     assert parshios.getparsha_string(reunion_shabbos) == "Matos, Ma'sei"
     assert parshios.getparsha_string(reunion_shabbos, True) == "Ma'sei"
Ejemplo n.º 3
0
 def test_chukas_balak(self):
     chukas_balak = dates.HebrewDate(5780, 4, 12)
     assert parshios.getparsha(chukas_balak) == [38, 39]
     assert parshios.getparsha(chukas_balak, True) == [39, ]
     assert parshios.getparsha(chukas_balak - 8) == [37, ]
     assert parshios.getparsha(chukas_balak - 13, True) == [38, ]
     shavuos = dates.HebrewDate(5780, 3, 6)
     assert parshios.getparsha_string(shavuos, True) == 'Naso'
     assert parshios.getparsha_string(shavuos) is None
     assert parshios. getparsha_string(shavuos + 7, True) == "Beha'aloscha"
     assert parshios.getparsha_string(shavuos + 7) == 'Naso'
Ejemplo n.º 4
0
 def test_chukas_balak(self):
     chukas_balak = dates.HebrewDate(5780, 4, 12)
     assert parshios.getparsha(chukas_balak) == [38, 39]
     assert parshios.getparsha(chukas_balak, True) == [39, ]
     assert parshios.getparsha(chukas_balak - 8) == [37, ]
     assert parshios.getparsha(chukas_balak - 13, True) == [38, ]
     shavuos = dates.HebrewDate(5780, 3, 6)
     assert parshios.getparsha_string(shavuos, True) == 'Naso'
     assert parshios.getparsha_string(shavuos) is None
     assert parshios. getparsha_string(shavuos + 7, True) == "Beha'aloscha"
     assert parshios.getparsha_string(shavuos + 7) == 'Naso'
Ejemplo n.º 5
0
def get_hags(date=datetime.date.today(),
             days_range_future=0,
             days_range_past=0,
             return_shabbat=True):
    holidays_dict = get_holidays(date)

    if not holidays_dict:
        if return_shabbat and date.weekday() == 5:  # 5 == Shabbat
            holidays_dict = {9: 'Shabbat'}  # lowest priority

            ###############################################################################################################################################
            #       The marked code includes parashot and special shabbatot (Para, Hodesh, etc), but has a bug that 2020-05-30 does not have a parasha    #
            ###############################################################################################################################################
            #
            # import date_utils.calendar_util
            # from jewish_dates.parasha import getTorahSections
            # shabbat = date #+ datetime.timedelta(days=1)
            # julian = date_utils.calendar_util.gregorian_to_jd(shabbat.year, shabbat.month, shabbat.day)
            # hebYear, hebMonth, hebDay = date_utils.calendar_util.jd_to_hebrew(julian)
            # str = getTorahSections(hebMonth, hebDay, hebYear, False)
            # if str:
            #    folders_dict.update({8: str})  # second-lowest priority

            # TODO: Add special shabbatot: http://individual.utoronto.ca/kalendis/hebrew/parshah.htm
            # TODO: maybe ;ppk at this package: https://pypi.org/project/convertdate/
            parashot = parshios.getparsha(GregorianDate(
                date.year, date.month, date.day),
                                          israel=True)
            if parashot:
                for index, parash in enumerate(parashot):
                    holidays_dict.update({8 + index / 100: PARSHIOT[parash]
                                          })  # second-lowest priority
        else:
            for i in range(1,
                           max(days_range_future, days_range_past) * 2 +
                           2):  # check if any holidays next/past x days
                day_offset = i // 2 * (
                    1, -1
                )[i %
                  2]  # returns this order of values: 0, +1, -1, +2, -2, +3, -3, etc...
                if day_offset > days_range_future or day_offset < -days_range_past:
                    continue
                offset_date = date + datetime.timedelta(days=day_offset)
                holidays_dict = get_holidays(offset_date)
                if not holidays_dict:
                    holidays_dict = get_personal(offset_date)
                if holidays_dict:
                    break

    # export list of holidays, in order of priority
    sorted_folders = []
    if holidays_dict and len(holidays_dict) > 0:
        for key in sorted(holidays_dict):
            sorted_folders += [holidays_dict[key]]

    return sorted_folders
Ejemplo n.º 6
0
 def test_getparsha(self):
     for key in KNOWN_VALUES:
         assert (parshios.getparsha(dates.GregorianDate(*key)) ==
                 KNOWN_VALUES[key])
Ejemplo n.º 7
0
 def test_getparsha(self):
     for key in KNOWN_VALUES:
         assert (parshios.getparsha(dates.GregorianDate(*key)) ==
                 KNOWN_VALUES[key])
Ejemplo n.º 8
0
 def parsha(self):
     parsha_number = parshios.getparsha(self._pyluach_hebrew_date())
     if parsha_number is not None:
         return parsha_number[0]
     else:
         return None