コード例 #1
0
def get_first_perek(jd, israel):
    jyear = jd.year
    jmonth = jd.month
    jday = jd.day
    pes1 = JDate.create(jyear, 1, 15)
    # How many days after the first day of pesach was the first shabbos after pesach
    shb1 = (7 if israel else 8) + (6 - pes1.getdow())
    # What number shabbos after pesach is the current date
    cshb = (1 if (jmonth == 1 and jday == (shb1 + 15)) else int(
        (jd.ordinal - (pes1.ordinal + shb1)) / 7) + 1)
    prk = cshb % 6
    if prk == 0:
        prk = 6
    # If the second day of Shavuos was on Shabbos, we missed a week.
    # The second day of Pesach is always the same day as the first day of Shavuos.
    # So if Pesach was on Thursday, Shavuos will be on Friday and Shabbos in Chu"l.
    # Pesach can never come out on Friday, so in E. Yisroel Shavuos is never on Shabbos.
    if (not israel) and pes1.getdow() == 4 and (jmonth > 3 or
                                                (jmonth == 3 and jday > 6)):
        prk = 6 if prk == 1 else prk - 1
    # If Tisha B'Av was on Shabbos, we missed a week.
    # The first day of Pesach is always the same day of the week as Tisha b'av.
    if pes1.getdow() == 6 and (jmonth > 5 or (jmonth == 5 and jday > 9)):
        prk = 6 if prk == 1 else prk - 1
    return prk
コード例 #2
0
            praklist = 4, 5, 6
    elif perek1 == 5:
        if cshb == 1:
            praklist = 5, 6
        elif cshb == 2:
            praklist = 1, 2
        elif cshb == 3:
            praklist = 3, 4
        elif cshb == 4:
            praklist = 5, 6
    elif perek1 == 6:
        if cshb == 1:
            praklist = 6,
        elif cshb == 2:
            praklist = 1, 2
        elif cshb == 3:
            praklist = 3, 4
        elif cshb == 4:
            praklist = 5, 6
    return praklist


if __name__ == '__main__':
    import jcal.utils as utils

    chukas5776 = JDate.create(5776, 4, 10)
    prakim = get_pirkeiavos(chukas5776, True)
    text = 'Pirkei Avos: ' + ' and '.join(
        [utils.to_suffixed(p) + ' Perek' for p in prakim])
    print(text)