コード例 #1
0
def _gentable(year, israel=False):
    """Return OrderedDict mapping date of Shabbos to list of parsha numbers.

    The numbers start with Beraishis as 0. Double parshios are represented
    as a list of the two numbers. If there is no Parsha the value is None.
    """
    parshalist = deque([51, 52] + list(range(52)))
    table = OrderedDict()
    leap = HebrewDate._is_leap(year)
    pesachday = HebrewDate(year, 1, 15).weekday()
    rosh_hashana = HebrewDate(year, 7, 1)
    shabbos = rosh_hashana.shabbos()
    if rosh_hashana.weekday() > 4:
        parshalist.popleft()

    while shabbos.year == year:
        if _parshaless(shabbos, israel):
            table[shabbos] = None
        else:
            parsha = parshalist.popleft()
            table[shabbos] = [
                parsha,
            ]
            if ((parsha == 21 and (HebrewDate(year, 1, 14) - shabbos) // 7 < 3)
                    or (parsha in [26, 28] and not leap) or
                (parsha == 31 and not leap and (not israel or pesachday != 7))
                    or (parsha == 38 and not israel and pesachday == 5) or
                (parsha == 41 and (HebrewDate(year, 5, 9) - shabbos) // 7 < 2)
                    or (parsha == 50 and HebrewDate(year + 1, 7, 1).weekday() >
                        4)):  #  If any of that then it's a double parsha.
                table[shabbos].append(parshalist.popleft())
        shabbos += 7
    return table
コード例 #2
0
ファイル: parshios.py プロジェクト: simlist/pyluach
def _gentable(year, israel=False):
    """Return OrderedDict mapping date of Shabbos to list of parsha numbers.

    The numbers start with Beraishis as 0. Double parshios are represented
    as a list of the two numbers. If there is no Parsha the value is None.
    """
    parshalist = deque([51, 52] + list(range(52)))
    table = OrderedDict()
    leap = HebrewDate._is_leap(year)
    pesachday = HebrewDate(year, 1, 15).weekday()
    rosh_hashana = HebrewDate(year, 7, 1)
    shabbos = (rosh_hashana + 2).shabbos()
    if rosh_hashana.weekday() > 4:
        parshalist.popleft()

    while shabbos.year == year:
        if _parshaless(shabbos, israel):
            table[shabbos] = None
        else:
            parsha = parshalist.popleft()
            table[shabbos] = [parsha,]
            if(
               (parsha == 21 and (HebrewDate(year, 1, 14)-shabbos) // 7 < 3) or
               (parsha in [26, 28] and not leap) or
               (parsha == 31 and not leap and (
                                               not israel or pesachday != 7
                                               )) or
               (parsha == 38 and not israel and pesachday == 5) or
               (parsha == 41 and (HebrewDate(year, 5, 9)-shabbos) // 7 < 2)  or
               (parsha == 50 and HebrewDate(year+1, 7, 1).weekday() > 4)
               ):  #  If any of that then it's a double parsha.
                table[shabbos].append(parshalist.popleft())
        shabbos += 7
    return table
コード例 #3
0
ファイル: hebrewcal.py プロジェクト: simlist/pyluach
    def __init__(self, year):

        """
        The initializer for a Year object.
        """
        if year < 1:
            raise ValueError('Year {0} is before creation.'.format(year))
        self.year = year
        self.leap = HebrewDate._is_leap(year)
コード例 #4
0
 def __init__(self, year, month):
     if year < 1:
         raise ValueError('Year is before creation.')
     self.year = year
     leap = HebrewDate._is_leap(self.year)
     yearlength = 13 if leap else 12
     if month < 1 or month > yearlength:
         raise ValueError('''Month must be between 1 and 12 for a normal
         year and 13 for a leap year.''')
     self.month = month
     self._monthnames[12] = 'Adar Rishon' if leap else 'Adar'
     self.name = self._monthnames[self.month]
コード例 #5
0
ファイル: hebrewcal.py プロジェクト: simlist/pyluach
 def __init__(self, year, month):
     if year < 1:
         raise ValueError('Year is before creation.')
     self.year = year
     leap = HebrewDate._is_leap(self.year)
     yearlength = 13 if leap else 12
     if month < 1 or month > yearlength:
         raise ValueError('''Month must be between 1 and 12 for a normal
         year and 13 for a leap year.''')
     self.month = month
     self._monthnames[12] = 'Adar Rishon' if leap else 'Adar'
     self.name = self._monthnames[self.month]
コード例 #6
0
def festival(date, israel=False):
    """Return Jewish festival of given day.

    This method will return all major and minor religous
    Jewish holidays not including fast days.

    Parameters
    ----------
    date : ``HebrewDate``, ``GregorianDate``, or ``JulianDay``
      Any date that implements a ``to_heb()`` method which returns a
      ``HebrewDate`` can be used.

    israel : bool, optional
      ``True`` if you want the holidays according to the Israel
      schedule. Defaults to ``False``.

    Returns
    -------
    str or ``None``
      The name of the festival or ``None`` if the given date is not
      a Jewish festival.
    """
    date = date.to_heb()
    year = date.year
    month = date.month
    day = date.day
    if month == 7:
        if day in [1, 2]:
            return 'Rosh Hashana'
        elif day == 10:
            return 'Yom Kippur'
        elif day in range(15, 22):
            return 'Succos'
        elif day == 22:
            return 'Shmini Atzeres'
        elif day == 23 and israel == False:
            return 'Simchas Torah'
    elif ((month == 9 and day in range(25, 30))
          or date in [(HebrewDate(year, 9, 29) + n) for n in range(1, 4)]):
        return 'Chanuka'
    elif month == 11 and day == 15:
        return "Tu B'shvat"
    elif month == 12:
        leap = HebrewDate._is_leap(year)
        if day == 14:
            return 'Purim Katan' if leap else 'Purim'
        if day == 15 and not leap:
            return 'Shushan Purim'
    elif month == 13:
        if day == 14:
            return 'Purim'
        elif day == 15:
            return 'Shushan Purim'
    elif month == 1 and day in range(15, 22 if israel else 23):
        return 'Pesach'
    elif month == 2 and day == 14:
        return 'Pesach Sheni'
    elif month == 2 and day == 18:
        return "Lag Ba'omer"
    elif month == 3 and (day == 6 if israel else day in (6, 7)):
        return 'Shavuos'
    elif month == 5 and day == 15:
        return "Tu B'av"
コード例 #7
0
 def __init__(self, year):
     if year < 1:
         raise ValueError('Year {0} is before creation.'.format(year))
     self.year = year
     self.leap = HebrewDate._is_leap(year)
コード例 #8
0
ファイル: israel.py プロジェクト: novafloss/workalendar
    def get_variable_days(self, year):
        days = super(Israel, self).get_variable_days(year)

        delta = timedelta(days=1)
        current_date = date(year, 1, 1)

        while current_date.year == year:
            hebrew_date = GregorianDate(
                year=current_date.year,
                month=current_date.month,
                day=current_date.day,
            ).to_heb()

            jewish_year = hebrew_date.year
            month = hebrew_date.month
            day = hebrew_date.day

            if month == 7:
                if day in {1, 2, 3}:
                    days.append((current_date, "Rosh Hashana"))
                elif day == 10:
                    days.append((current_date, "Yom Kippur"))
                elif day in range(15, 22):
                    days.append((current_date, "Sukkot"))
                elif day == 22:
                    days.append((current_date, "Shmini Atzeres"))
            elif month == 12:
                leap = HebrewDate._is_leap(jewish_year)
                if day == 14:
                    days.append((current_date, "Purim"))
                if day == 15 and not leap:
                    days.append((current_date, "Purim"))
            elif month == 13:
                if day == 14:
                    days.append((current_date, "Purim"))
                elif day == 15:
                    days.append((current_date, "Shushan Purim"))
            elif month == 1 and day in {15, 21}:
                days.append((current_date, "Pesach"))
            elif month == 2:
                if day == 5:
                    if hebrew_date.weekday() == 6:
                        days.append(
                            (
                                HebrewDate(jewish_year, month, 4).to_pydate(),
                                "Independence Day",
                            )
                        )
                    elif hebrew_date.weekday() == 7:
                        days.append(
                            (
                                HebrewDate(jewish_year, month, 3).to_pydate(),
                                "Independence Day",
                            )
                        )
                    elif hebrew_date.weekday() == 2:
                        days.append(
                            (
                                HebrewDate(jewish_year, month, 6).to_pydate(),
                                "Independence Day",
                            )
                        )
                    else:
                        days.append((current_date, "Independence Day"))
            elif month == 3 and day == 6:
                days.append((current_date, "Shavout"))

            current_date += delta

        return days
コード例 #9
0
    def get_variable_days(self, year):
        days = super().get_variable_days(year)

        delta = timedelta(days=1)
        current_date = date(year, 1, 1)

        while current_date.year == year:
            hebrew_date = GregorianDate(
                year=current_date.year,
                month=current_date.month,
                day=current_date.day,
            ).to_heb()

            jewish_year = hebrew_date.year
            month = hebrew_date.month
            day = hebrew_date.day

            if month == 7:
                if day in {1, 2, 3}:
                    days.append((current_date, "Rosh Hashana"))
                elif day == 10:
                    days.append((current_date, "Yom Kippur"))
                elif day in range(15, 22):
                    days.append((current_date, "Sukkot"))
                elif day == 22:
                    days.append((current_date, "Shmini Atzeres"))
            elif month == 12 and not HebrewDate._is_leap(jewish_year):
                if day == 14:
                    days.append((current_date, "Purim"))
                if day == 15:
                    days.append((current_date, "Shushan Purim"))
            elif month == 13:
                if day == 14:
                    days.append((current_date, "Purim"))
                elif day == 15:
                    days.append((current_date, "Shushan Purim"))
            elif month == 1 and day in {15, 21}:
                days.append((current_date, "Pesach"))
            elif month == 2:
                if day == 5:
                    if hebrew_date.weekday() == 6:
                        days.append((
                            HebrewDate(jewish_year, month, 4).to_pydate(),
                            "Independence Day",
                        ))
                    elif hebrew_date.weekday() == 7:
                        days.append((
                            HebrewDate(jewish_year, month, 3).to_pydate(),
                            "Independence Day",
                        ))
                    elif hebrew_date.weekday() == 2:
                        days.append((
                            HebrewDate(jewish_year, month, 6).to_pydate(),
                            "Independence Day",
                        ))
                    else:
                        days.append((current_date, "Independence Day"))
            elif month == 3 and day == 6:
                days.append((current_date, "Shavout"))

            current_date += delta

        return days
コード例 #10
0
ファイル: hebrewcal.py プロジェクト: simlist/pyluach
def holiday(date, israel=False):
    """Return Jewish holiday of given date.

    The holidays include the major and minor religious Jewish
    holidays including fast days.

    Parameters
    ----------
    date : ``HebrewDate``, ``GregorianDate``, or ``JulianDay``
      Any date that implements a ``to_heb()`` method which returns a
      ``HebrewDate`` can be used.

    israel : boolian, optional
      ``True`` if you want the holidays according to the israel
      schedule. Defaults to ``False``.

    Returns
    -------
    str or ``None``
      The name of the holiday or ``None`` if the given date is not
      a Jewish holiday.
    """
    date = date.to_heb()
    year = date.year
    month = date.month
    day = date.day
    table = _fast_day_table(year)
    if date in table:
        return table[date]
    if month == 7:
        if day in range(1, 3):
            return 'Rosh Hashana'
        elif day == 10:
            return 'Yom Kippur'
        elif day in range(15, 22):
            return 'Succos'
        elif day == 22:
            return 'Shmini Atzeres'
        elif day == 23 and israel == False:
            return 'Simchas Torah'
    elif(
         (month == 9 and day in range(25, 30)) or
         date in [(HebrewDate(year, 9, 29) + n) for n in range(1, 4)]
         ):
        return 'Chanuka'
    elif month == 11 and day == 15:
        return "Tu B'shvat"
    elif month == 12:
        leap = HebrewDate._is_leap(year)
        if day == 14:
            return 'Purim Katan' if leap else 'Purim'
        if day == 15 and not leap:
            return 'Shushan Purim'
    elif month == 13:
        if day == 14:
                return 'Purim'
        elif day == 15:
            return 'Shushan Purim'
    elif month == 1 and day in range(15, 22 if israel else 23):
        return 'Pesach'
    elif month == 2 and day == 18:
        return "Lag Ba'omer"
    elif month == 3 and (day == 6 if israel else day in (6, 7)):
        return 'Shavuos'
    elif month == 5 and day == 15:
        return "Tu B'av"