예제 #1
0
    def format_yom_tov(self, jewish_calendar: JewishCalendar) -> str:
        """
        Formats the Yom Tov (holiday) name

        Depndent on hebrew_format, returns the name in Hebrew or transliterated
        Latin characters.
        """
        yom_tov = jewish_calendar.significant_day()

        if yom_tov is None:
            return ""

        index = jewish_calendar.SIGNIFICANT_DAYS[yom_tov].value

        _LOGGER.debug("Detected Yom Tov: %s (%d)", yom_tov, index)

        if index == JewishCalendar.SIGNIFICANT_DAYS.chanukah.value:
            day_of_chanukah = jewish_calendar.day_of_chanukah()

            _LOGGER.debug("Day of Chanukah: %d", day_of_chanukah)
            if self.hebrew_format:
                return (f"{self.format_hebrew_number(day_of_chanukah)} "
                        f"{self.HEBREW_HOLIDAYS[index]}")
            else:
                return (f"{self.TRANSLITERATED_HOLIDAYS[index]} "
                        f"{day_of_chanukah}")

        return (self.HEBREW_HOLIDAYS[index]
                if self.hebrew_format else self.TRANSLITERATED_HOLIDAYS[index])
 def test_day_of_chanukah_for_non_chanukah_date(self):
     calendar = JewishCalendar(test.test_helper.standard_monday_chaseirim(),
                               7, 1)
     self.assertIsNone(calendar.day_of_chanukah())