コード例 #1
0
def proper_jmonth_name(jyear, jmonth, hebrew=False):
    from jcal.jdate import JDate
    if jmonth == 12 and JDate.isleap_jyear(jyear):
        return "Adar Rishon" if not hebrew else "אדר ראשון"
    else:
        return jmonths_eng[jmonth] if not hebrew else jmonths_heb[jmonth]
コード例 #2
0
def isleap(year):
    """Return True for leap years, False for non-leap years."""
    return JDate.isleap_jyear(year)
コード例 #3
0
    def get_sedra_order(cls, year, israel):
        # If the last call is within the same year as this one, we reuse the data.
        # If memory is an issue, remove these next few lines
        if cls._lastcalculatedyear is not None and cls._lastcalculatedyear['year'] == year and \
                        cls._lastcalculatedyear['israel'] == israel:
            return cls._lastcalculatedyear

        long_cheshvon = JDate.has_long_cheshvan(year)
        short_kislev = JDate.has_short_kislev(year)
        rosh_hashana = JDate.toordinal(year, 7, 1)
        rosh_hashana_dow = abs(rosh_hashana % 7)
        first_sat_in_year = cls.get_day_on_or_before(6, rosh_hashana + 6)
        year_type = 'regular'
        s_array = None

        if long_cheshvon and not short_kislev:
            year_type = 'complete'
        elif not long_cheshvon and short_kislev:
            year_type = 'incomplete'

        if not JDate.isleap_jyear(year):
            if rosh_hashana_dow == 6:
                if year_type == "incomplete":
                    s_array = cls._shabbos_short
                elif year_type == 'complete':
                    s_array = cls._shabbos_long
            elif rosh_hashana_dow == 1:
                if year_type == 'incomplete':
                    s_array = cls._mon_short
                elif year_type == 'complete':
                    s_array = cls._mon_short if israel else cls._mon_long
            elif rosh_hashana_dow == 2:
                if year_type == 'regular':
                    s_array = cls._mon_short if israel else cls._mon_long
            elif rosh_hashana_dow == 4:
                if year_type == 'regular':
                    s_array = cls._thu_normal_Israel if israel else cls._thu_normal
                elif year_type == 'complete':
                    s_array = cls._thu_long
            else:
                raise ValueError("improper sedra year type calculated.")
        # leap year
        else:
            if rosh_hashana_dow == 6:
                if year_type == 'incomplete':
                    s_array = cls._shabbos_short_leap
                elif year_type == 'complete':
                    s_array = cls._shabbos_short_leap if israel else cls._shabbos_long_leap
            elif rosh_hashana_dow == 1:
                if year_type == 'incomplete':
                    s_array = cls._mon_short_leap_Israel if israel else cls._mon_short_leap
                elif year_type == 'complete':
                    s_array = cls._mon_long_leap_Israel if israel else cls._mon_long_leap
            elif rosh_hashana_dow == 2:
                if year_type == 'regular':
                    s_array = cls._mon_long_leap_Israel if israel else cls._mon_long_leap
            elif rosh_hashana_dow == 4:
                if year_type == 'incomplete':
                    s_array = cls._thu_short_leap
                elif year_type == 'complete':
                    s_array = cls._thu_long_leap
            else:
                raise ValueError("improper sedra year type calculated.")

        retobj = dict(first_sat_in_year=first_sat_in_year, sedra_array=s_array, year=year, israel=israel)

        # Save the data in case the next call is for the same year
        cls._lastcalculatedyear = retobj

        return retobj