Пример #1
0
 def itermonthdates(year, month):
     """
     Return an iterator for one month. The iterator will yield datetime.date
     values and will always iterate through complete weeks, so it will yield
     dates outside the specified month.
     """
     date = JDate(year, month, 1)
     # Go back to the beginning of the week
     days = date.getdow() % 7
     date -= days
     oneday = 1
     while True:
         yield date
         try:
             date += oneday
         except OverflowError:
             # Adding one day could fail after datetime.MAXYEAR
             break
         if date.month != month and date.getdow() == 0:
             break
Пример #2
0
def ellul(jd, israel):
    praklist = ()
    jyear = jd.year
    jday = jd.day
    # The first day of Ellul.
    # The year/month/day/ordinal constructor is used for efficiency.
    day1 = JDate(jyear, 6, 1, jd.ordinal - jd.day + 1)
    day1dow = day1.getdow()
    shabbos1day = 1 if day1dow == 6 else ((6 - (day1dow + 6) % 6) + 1)
    shabbos1date = JDate(jyear, 6, shabbos1day, day1.ordinal + shabbos1day - 1)
    # Which shabbos in Ellul are we working out now?
    cshb = 1 if jday == shabbos1day else int((jday - shabbos1day) / 7) + 1

    perek1 = get_first_perek(shabbos1date, israel)
    if perek1 == 1:
        if cshb == 1:
            praklist = 1,
        elif cshb == 2:
            praklist = 2,
        elif cshb == 3:
            praklist = 3, 4
        elif cshb == 4:
            praklist = 5, 6
    elif perek1 == 2:
        if cshb == 1:
            praklist = 2,
        elif cshb == 2:
            praklist = 3,
        elif cshb == 3:
            praklist = 4,
        elif cshb == 4:
            praklist = 5, 6
    elif perek1 == 3:
        if cshb == 1:
            praklist = 3,
        elif cshb == 2:
            praklist = 4,
        elif cshb == 3:
            praklist = 5,
        elif cshb == 4:
            praklist = 6,
    elif perek1 == 4:
        # This can only happen in Chutz La'aretz
        if cshb == 1:
            praklist = 4, 5
        elif cshb == 2:
            praklist = 6, 1
        elif cshb == 3:
            praklist = 2, 3
        elif cshb == 4:
            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