예제 #1
0
    def yom_ha_zikkaron(cls, gregorian_year):
        """Return fixed date of Yom ha_Zikkaron occurring in Gregorian
        year 'gregorian_year'."""
        hebrew_year = gregorian_year - GregorianDate.to_year(cls.EPOCH)
        iyyar4 = HebrewDate(hebrew_year, HebrewMonth.IYYAR, 4).to_fixed()

        if DayOfWeek.from_fixed(iyyar4) in (DayOfWeek.Thursday, DayOfWeek.Friday):
            return DayOfWeek.Wednesday.before(iyyar4)
        elif DayOfWeek.Sunday == DayOfWeek.from_fixed(iyyar4):
            return iyyar4 + 1
        else:
            return iyyar4
예제 #2
0
 def tzom_tevet(cls, gregorian_year):
     """Return the list of fixed dates for Tzom Tevet (Tevet 10) that
     occur in Gregorian year 'gregorian_year'. It can occur 0, 1 or 2 times per
     Gregorian year."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y = HebrewDate.from_fixed(jan1).year
     d1 = HebrewDate(y, HebrewMonth.TEVET, 10).to_fixed()
     d1 = d1 + 1 if DayOfWeek.from_fixed(d1) == DayOfWeek.Saturday else d1
     d2 = HebrewDate(y + 1, HebrewMonth.TEVET, 10).to_fixed()
     d2 = d2 + 1 if DayOfWeek.from_fixed(d2) == DayOfWeek.Saturday else d2
     dates = [d1, d2]
     return list_range(dates, GregorianDate.year_range(gregorian_year))
예제 #3
0
    def possible_days(cls, month, day):
        """Return a list of possible days of week for Hebrew day 'day'
        and Hebrew month 'month'."""
        h_date0 = HebrewDate(5, HebrewMonth.NISAN, 1)
        h_year = 6 if month > HebrewMonth.ELUL else 5
        h_date = HebrewDate(h_year, month, day)
        n = h_date.to_fixed() - h_date0.to_fixed()
        basic = [DayOfWeek.Tuesday, DayOfWeek.Thursday, DayOfWeek.Saturday]

        if month == HebrewMonth.MARHESHVAN and day == 30:
            extra = []
        elif month == HebrewMonth.KISLEV and day < 30:
            extra = [DayOfWeek.Monday, DayOfWeek.Wednesday, DayOfWeek.Friday]
        elif month == HebrewMonth.KISLEV and day == 30:
            extra = [DayOfWeek.Monday]
        elif month in [HebrewMonth.TEVET, HebrewMonth.SHEVAT]:
            extra = [DayOfWeek.Sunday, DayOfWeek.Monday]
        elif month == HebrewMonth.ADAR and day < 30:
            extra = [DayOfWeek.Sunday, DayOfWeek.Monday]
        else:
            extra = [DayOfWeek.Sunday]

        basic.extend(extra)
        return map(lambda x: DayOfWeek.from_fixed(x + n), basic)
 def testKnownData(self):
     for (fixed_date, day_of_week) in self.data.iteritems():
         self.assertEqual(day_of_week, DayOfWeek.from_fixed(fixed_date))
예제 #5
0
 def is_long_year(cls, i_year):
     """Return True if ISO year 'i_year' is a long (53-week) year."""
     jan1  = DayOfWeek.from_fixed(GregorianDate.new_year(i_year))
     dec31 = DayOfWeek._from_fixed(GregorianDate.year_end(i_year))
     return jan1 == DayOfWeek.Thursday or dec31 == DayOfWeek.Thursday
예제 #6
0
 def tishah_be_av(cls, gregorian_year):
     """Return fixed date of Tishah be_Av occurring in Gregorian year 'gregorian_year'."""
     hebrew_year = gregorian_year - GregorianDate.to_year(cls.EPOCH)
     av9 = HebrewDate(hebrew_year, HebrewMonth.AV, 9).to_fixed()
     return av9 + 1 if DayOfWeek.from_fixed(av9) == DayOfWeek.Saturday else av9
예제 #7
0
 def ta_anit_esther(cls, gregorian_year):
     """Return fixed date of Ta'anit Esther occurring in Gregorian
     year 'gregorian_year'."""
     purim_date = cls.purim(gregorian_year)
     return purim_date - 3 if DayOfWeek.from_fixed(purim_date) == DayOfWeek.Sunday else purim_date - 1