Ejemplo n.º 1
0
    def test_jewish_holidays(self):
        # http://www.chabad.org/holidays/passover/pesach_cdo/aid/671901/jewish/When-is-Passover-in-2013-2014-2015-2016-and-2017.htm
        # the date here is the start of the holiday, so the eve=1 option is used
        passovers = [(2013, 3, 25), (2014, 4, 14), (2015, 4, 3), (2016, 4, 22),
                     (2017, 4, 10)]
        for y, m, d in passovers:
            self.assertEqual(holidays.passover(y, eve=1), (y, m, d))

        rosh_hashanahs = [
            (2014, 9, 24),
            (2015, 9, 13),
            (2016, 10, 2),
            (2017, 9, 20),
        ]
        for y, m, d in rosh_hashanahs:
            self.assertEqual(holidays.rosh_hashanah(y, eve=1), (y, m, d))

        self.assertEqual(holidays.hanukkah(2015, True), (2015, 12, 6))
        self.assertEqual(holidays.hanukkah(2015), (2015, 12, 7))

        self.assertEqual(holidays.yom_kippur(2015), (2015, 9, 23))
        self.assertEqual(holidays.yom_kippur(2015, True), (2015, 9, 22))

        sukkots = [
            (2016, 10, 17),
            (2015, 9, 28),
        ]
        for y, m, d in sukkots:
            self.assertEqual(holidays.sukkot(y, eve=0), (y, m, d))

        shavuots = [(2016, 6, 12), (2015, 5, 24)]
        for y, m, d in shavuots:
            self.assertEqual(holidays.shavuot(y, eve=0), (y, m, d))

        purims = [(2017, 3, 12), (2016, 3, 24)]
        for y, m, d in purims:
            self.assertEqual(holidays.purim(y, eve=0), (y, m, d))

        tisha_bavs = [
            (2019, 8, 11),
            (2020, 7, 30),
            (2021, 7, 18),
            (2022, 8, 7),
            (2023, 7, 27),
        ]
        for y, m, d in tisha_bavs:
            self.assertEqual(holidays.tisha_bav(y, eve=0), (y, m, d))

        assert self.h.hanukkah == (2015, 12, 7)
        assert self.h.rosh_hashanah == (2015, 9, 14)
        assert self.h.yom_kippur == (2015, 9, 23)
        assert self.h.passover == (2015, 4, 4)

        assert self.h.tisha_bav == (2015, 7, 26)
        assert self.h.shemini_azeret == (2015, 10, 5)
        assert self.h.lag_baomer == (2015, 5, 7)
        assert self.h.tu_beshvat == (2015, 2, 4)
Ejemplo n.º 2
0
    def test_jewish_holidays(self):
        # http://www.chabad.org/holidays/passover/pesach_cdo/aid/671901/jewish/When-is-Passover-in-2013-2014-2015-2016-and-2017.htm
        # the date here is the start of the holiday, so the eve=1 option is used
        passovers = [
            (2013, 3, 25),
            (2014, 4, 14),
            (2015, 4, 3),
            (2016, 4, 22),
            (2017, 4, 10)
        ]
        for y, m, d in passovers:
            self.assertEqual(holidays.passover(y, eve=1), (y, m, d))

        rosh_hashanahs = [
            (2014, 9, 24),
            (2015, 9, 13),
            (2016, 10, 2),
            (2017, 9, 20),
        ]
        for y, m, d in rosh_hashanahs:
            self.assertEqual(holidays.rosh_hashanah(y, eve=1), (y, m, d))

        self.assertEqual(holidays.hanukkah(2015, True), (2015, 12, 6))
        self.assertEqual(holidays.hanukkah(2015), (2015, 12, 7))

        self.assertEqual(holidays.yom_kippur(2015), (2015, 9, 23))
        self.assertEqual(holidays.yom_kippur(2015, True), (2015, 9, 22))

        sukkots = [
            (2016, 10, 17),
            (2015, 9, 28),
        ]
        for y, m, d in sukkots:
            self.assertEqual(holidays.sukkot(y, eve=0), (y, m, d))

        shavuots = [
            (2016, 6, 12),
            (2015, 5, 24)
        ]
        for y, m, d in shavuots:
            self.assertEqual(holidays.shavuot(y, eve=0), (y, m, d))

        purims = [
            (2017, 3, 12),
            (2016, 3, 24)
        ]
        for y, m, d in purims:
            self.assertEqual(holidays.purim(y, eve=0), (y, m, d))

        assert self.h.hanukkah == (2015, 12, 7)
        assert self.h.rosh_hashanah == (2015, 9, 14)
        assert self.h.yom_kippur == (2015, 9, 23)
        assert self.h.passover == (2015, 4, 4)
Ejemplo n.º 3
0
    def _populate(self, year):
        # Passover
        name = "Passover I"
        year, month, day = passover(year, eve=True)
        passover_start_dt = date(year, month, day)
        self[passover_start_dt] = name + " - Eve"
        self[passover_start_dt + rd(days=1)] = name

        name = "Passover"
        for offset in range(2, 6):
            self[passover_start_dt + rd(days=offset)] = name + " - Chol HaMoed"

        name = "Passover VII"
        self[passover_start_dt + rd(days=6)] = name + " - Eve"
        self[passover_start_dt + rd(days=7)] = name

        # Memorial Day
        name = "Memorial Day"
        year, month, day = gregorian.from_jd(
            hebrew.to_jd_gregorianyear(year, hebrew.IYYAR, 3))
        self[date(year, month, day) + rd(days=1)] = name

        observed_delta = 0
        if self.observed:
            day_in_week = date(year, month, day).weekday()
            if day_in_week in (2, 3):
                observed_delta = -(day_in_week - 1)
            elif 2004 <= year and day_in_week == 5:
                observed_delta = 1

            if observed_delta != 0:
                self[date(year, month, day) +
                     rd(days=observed_delta + 1)] = (name + " (Observed)")

        # Independence Day
        name = "Independence Day"
        self[date(year, month, day) + rd(days=2)] = name

        if self.observed and observed_delta != 0:
            self[date(year, month, day) +
                 rd(days=observed_delta + 2)] = (name + " (Observed)")

        # Lag Baomer
        name = "Lag B'Omer"
        year, month, day = lag_baomer(year, eve=False)
        self[date(year, month, day)] = name

        # Shavuot
        name = "Shavuot"
        year, month, day = shavuot(year, eve=True)
        self[date(year, month, day)] = name + " - Eve"
        self[date(year, month, day) + rd(days=1)] = name

        # Rosh Hashana
        name = "Rosh Hashanah"
        year, month, day = rosh_hashanah(year, eve=True)
        self[date(year, month, day)] = name + " - Eve"
        self[date(year, month, day) + rd(days=1)] = name
        self[date(year, month, day) + rd(days=2)] = name

        # Yom Kippur
        name = "Yom Kippur"
        year, month, day = yom_kippur(year, eve=True)
        self[date(year, month, day)] = name + " - Eve"
        self[date(year, month, day) + rd(days=1)] = name

        # Sukkot
        name = "Sukkot I"
        year, month, day = sukkot(year, eve=True)
        sukkot_start_dt = date(year, month, day)
        self[sukkot_start_dt] = name + " - Eve"
        self[sukkot_start_dt + rd(days=1)] = name

        name = "Sukkot"
        for offset in range(2, 7):
            self[sukkot_start_dt + rd(days=offset)] = name + " - Chol HaMoed"

        name = "Sukkot VII"
        self[sukkot_start_dt + rd(days=7)] = name + " - Eve"
        self[sukkot_start_dt + rd(days=8)] = name

        # Hanukkah
        name = "Hanukkah"
        year, month, day = hanukkah(year, eve=False)
        for offset in range(8):
            self[date(year, month, day) + rd(days=offset)] = name

        # Purim
        name = "Purim"
        year, month, day = purim(year, eve=True)
        self[date(year, month, day)] = name + " - Eve"
        self[date(year, month, day) + rd(days=1)] = name
        self[date(year, month, day) + rd(days=2)] = "Shushan Purim"