Пример #1
0
 def test_purim(self):
     purims = [
         dates.HebrewDate(5778, 12, 14),
         dates.HebrewDate(5779, 13, 14)
     ]
     for purim in purims:
         assert holiday(purim) == 'Purim'
         assert holiday(purim + 1) == 'Shushan Purim'
     assert holiday(dates.HebrewDate(5779, 12, 14)) == 'Purim Katan'
Пример #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"
Пример #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'
Пример #4
0
 def test_roshhashana(self):
     roshhashana = dates.HebrewDate(5779, 7, 1)
     assert all([
         holiday(day, location) == 'Rosh Hashana'
         for day in [roshhashana, roshhashana + 1]
         for location in [True, False]
     ])
Пример #5
0
def _memorial_day(year):
    """
    Return the Hebrew date for Memorial Day in the given Hebrew year.

    Note: Independence Day is always celebrated the following day.
    """
    return dates.HebrewDate(year.year, 2, 4)
Пример #6
0
 def test_comparer_errors(self):
     day1 = dates.HebrewDate(5777, 12, 10)
     for date in [day1, day1.to_greg(), day1.to_jd()]:
         for comparer in [gt, lt, eq, ne, ge, le]:
             for value in [1, 0, 'hello', None, '']:
                 with pytest.raises(TypeError):
                     comparer(date, value)
Пример #7
0
 def test_iterdate(self):
     year = 5770
     workingdate = dates.HebrewDate(year, 7, 1)
     for month in (list(range(7, 13)) + list(range(1, 7))):
         for date in Month(year, month).iterdates():
             assert date == workingdate
             workingdate += 1
Пример #8
0
 def test_pesach(self):
     pesach = dates.HebrewDate(5778, 1, 15)
     for i in range(6):
         assert (holiday(pesach + i, True) == 'Pesach'
                 and holiday(pesach + i) == 'Pesach')
     eighth = pesach + 7
     assert holiday(eighth) == 'Pesach' and holiday(eighth, True) is None
     assert holiday(eighth + 1) is None
Пример #9
0
def compareDates(dt1_in, dt2_in):
    dt1 = dates.HebrewDate(today.year, dt1_in.month, dt1_in.day)
    dt2 = dates.HebrewDate(today.year, dt2_in.month, dt2_in.day)
    #if dt1.day == today.day and dt1.month == today.month:
    #    return -2
    if dt1._is_leap(dt1.year):
        #print ("yup" + str(dt1))
        if dt1.month == 13 and dt2.month == 1:
            return 1
    else:
        #print ("nope" + str(dt1))
        if dt1.month == 12 and dt2.month == 1:
            return 1

    if dt1.month > dt2.month or (dt1.month == dt2.month and dt1.day > dt2.day):
        return -1
    if dt1.month < dt2.month or (dt1.month == dt2.month and dt1.day < dt2.day):
        return 1
    return 0
Пример #10
0
	def __secs_to_heb_date(
		self, h_month: int, h_day: int, hour: int = 0, min: int = 0, sec: int = 0
	):
		"""Returns the number of seconds from now until the next time a hebrew date occurs"""
		now = dt.datetime.now()
		h_year = dates.HebrewDate.today().year
		h_trigger_date = dates.HebrewDate(h_year, h_month, h_day)

		# the datetime when new academic year should be triggered
		dt_trigger = dt.datetime.combine(
			h_trigger_date.to_pydate(), dt.time(hour, min, sec)
		)

		# if we're past dt_trigger but before Rosh Hashana change trigger to next year
		if now > dt_trigger:
			h_trigger_date = dates.HebrewDate(h_year + 1, h_month, h_day)
			dt_trigger = dt.datetime.combine(
				h_trigger_date.to_pydate(), dt.time(hour, min, sec)
			)

		return (dt_trigger - now).total_seconds()
Пример #11
0
 def generate_dates(self, date):
     # first_heb_date = dates.HebrewDate.from_pydate(datetime.datetime.strptime(date, configuration.DATE_FORMAT_CODE))
     first_heb_date = dates.HebrewDate.from_pydate(date)
     print(
         f"Generate {self.num_of_years} next dates corresponding the Hebrew date: {self.format(first_heb_date)}"
     )
     desired_dates = [
         dates.HebrewDate(first_heb_date.year + i, first_heb_date.month,
                          first_heb_date.day).to_greg()
         for i in range(self.num_of_years)
     ]
     return desired_dates
Пример #12
0
 def test_esther(self):
     fasts = [
         dates.HebrewDate(5778, 12, 13),
         dates.HebrewDate(5776, 13, 13),
         dates.HebrewDate(5777, 12, 11),  #nidche
         dates.HebrewDate(5784, 13, 11)  #ibbur and nidche
     ]
     for fast in fasts:
         assert holiday(fast) == 'Taanis Esther'
     non_fasts = [
         dates.HebrewDate(5776, 12, 13),
         dates.HebrewDate(5777, 12, 13),
         dates.HebrewDate(5784, 12, 11),
         dates.HebrewDate(5784, 13, 13)
     ]
     for non in non_fasts:
         assert holiday(non) is None
Пример #13
0
 def test_iterdates(self):
     year = 5778
     workingdate = dates.HebrewDate(year, 7, 1)
     for date in Year(year).iterdates():
         assert workingdate == date
         workingdate += 1
Пример #14
0
 def test_av(self):
     fasts = [dates.HebrewDate(5777, 5, 9), dates.HebrewDate(5778, 5, 10)]
     for fast in fasts:
         assert holiday(fast) == '9 of Av'
     assert holiday(dates.HebrewDate(5778, 5, 9)) is None
Пример #15
0
 def test_tamuz(self):
     fasts = [dates.HebrewDate(5777, 4, 17), dates.HebrewDate(5778, 4, 18)]
     for fast in fasts:
         assert holiday(fast) == '17 of Tamuz'
     assert holiday(dates.HebrewDate(5778, 4, 17)) is None
Пример #16
0
 def test_gedalia(self):
     assert holiday(dates.HebrewDate(5779, 7, 3)) == 'Tzom Gedalia'
     assert holiday(dates.HebrewDate(5778, 7, 3)) is None
     assert holiday(dates.HebrewDate(5778, 7, 4)) == 'Tzom Gedalia'
Пример #17
0
 def test_yomkippur(self):
     assert holiday(dates.HebrewDate(5775, 7, 10)) == 'Yom Kippur'
Пример #18
0
def getHebDate(m, d):
    global today
    if (m == 0):
        return today

    return dates.HebrewDate(today.year, m, d)
Пример #19
0
 def test_pesach_sheni(self):
     ps = dates.HebrewDate(5781, 2, 14)
     assert holiday(ps) == 'Pesach Sheni'
     assert holiday(ps + 1) is None
Пример #20
0
def _yom_kippur(year):
    """
    Return the Hebrew date for Yom Kippur in the given Hebrew year.
    """
    return dates.HebrewDate(year.year, 7, 10)
Пример #21
0
def _sukkoth(year):
    """
    Return the Hebrew date for Sukkoth in the given Hebrew year.
    """
    return dates.HebrewDate(year.year, 7, 15)
Пример #22
0
 def test_chanuka(self):
     for year in [5778, 5787]:
         chanuka = dates.HebrewDate(year, 9, 25)
         for i in range(8):
             assert holiday(chanuka + i) == 'Chanuka'
         assert holiday(chanuka + 8) is None
Пример #23
0
 def test_shmini(self):
     shmini = dates.HebrewDate(5780, 7, 22)
     assert holiday(shmini, True) == 'Shmini Atzeres'
     assert holiday(shmini) == 'Shmini Atzeres'
     assert holiday(shmini + 1) == 'Simchas Torah'
     assert holiday(shmini + 1, True) is None
Пример #24
0
 def test_succos(self):
     day = dates.HebrewDate(5778, 7, 18)
     assert holiday(day) == 'Succos'
     day2 = dates.HebrewDate(5778, 7, 23)
     assert holiday(day2, israel=True) is None
Пример #25
0
def _new_year(year):
    """
    Return the Hebrew date for the first day of a new year in the given Hebrew
    year.
    """
    return dates.HebrewDate(year.year, 7, 1)
Пример #26
0
 def test_shavuos(self):
     shavuos = dates.HebrewDate(5778, 3, 6)
     assert all(
         [holiday(day) == 'Shavuos' for day in [shavuos, shavuos + 1]])
     assert holiday(shavuos, True) == 'Shavuos'
     assert holiday(shavuos + 1, True) is None
Пример #27
0
def _fast_day(year):
    """
    Return the Hebrew date for Tisha B'Av in the given Hebrew year.
    """
    return dates.HebrewDate(year.year, 5, 9)
Пример #28
0
 def test_tubeav(self):
     assert holiday(dates.HebrewDate(5779, 5, 15)) == "Tu B'av"
Пример #29
0
 def test_tubshvat(self):
     assert holiday(dates.HebrewDate(5779, 11, 15)) == "Tu B'shvat"
Пример #30
0
def _simchat_torah(year):
    """
    Return the Hebrew date for Simchat Torah in the given Hebrew year.
    """
    return dates.HebrewDate(year.year, 7, 22)