Example #1
0
def WeekendPsalms(daily_readings, year):  # Weekend Worship (Psalms)
    def get_num_extra_readings():
        num_extra_readings = 0
        if get_weekday(datetime.datetime(year, 12, 31)) in ("Sat", "Sun"):
            extra_readings += 1  # Increment if December 31 is on a weekend
        if calendar.isleap(year) and (get_weekday(
                datetime.datetime(year, 12, 30)) in ("Sat", "Sun")):
            extra_readings += 1  # Increment if leap year & December 30 is on a weekend
        # print(f'For {year}, {num_extra_readings} extra WeekendPsalms() readings are needed.')
        return num_extra_readings

    date = datetime.datetime(year, 1, 1)  # January 1
    while get_weekday(date) not in ("Sat", "Sun"):
        date += datetime.timedelta(days=1)  # Increment until first weekend day

    for psalm_ref in rmm_original_104_psalm_readings:
        datedelta = 6 if (get_weekday(date) == "Sun") else 1
        # If date is a Lord's Day, then increment date to the following Saturday
        # Else {date is a Saturday} increment date to the next day (a Lord's Day)
        (daily_readings, date) = process_reading(daily_readings, date, "Psa",
                                                 psalm_ref, datedelta)

    extra_psalm_refs = ["23", "100"]  # Up to 2 extra readings
    for i in range(get_num_extra_readings()):
        datedelta = 6 if (get_weekday(date) == "Sun") else 1
        (daily_readings, date) = process_reading(daily_readings, date, "Psa",
                                                 extra_psalm_refs[i],
                                                 datedelta)
Example #2
0
def WeekdayPsalms(daily_readings, year):  # Weekday Worship (Psalms)
    def get_num_extra_readings():
        num_extra_readings = 0
        if get_weekday(datetime.datetime(year, 12, 31)) not in ("Sat", "Sun"):
            num_extra_readings += 1  # Increment if December 31 is a weekday
        if calendar.isleap(year) and (
            get_weekday(datetime.datetime(year, 12, 30)) not in ("Sat", "Sun")
        ):
            num_extra_readings += 1  # Increment if leap year & December 30 is a weekday
        print(
            f"For {year}, {num_extra_readings} extra WeekdayPsalms() readings are needed."
        )
        return num_extra_readings

    date = datetime.datetime(year, 1, 1)  # January 1
    while date.strftime("%a") in ("Sat", "Sun"):
        date += datetime.timedelta(days=1)  # Increment until first weekday

    extra_psalm_refs = ["23", "100"]  # Up to 2 extra readings

    for psalm_ref in rmm_modified_260_psalm_readings:
        datedelta = get_weekday_delta(date)
        (daily_readings, date) = process_reading(
            daily_readings, date, "Psa", psalm_ref, datedelta
        )

    extra_psalm_refs = ["23", "100"]  # Up to 2 extra readings
    for i in range(get_num_extra_readings()):
        datedelta = get_weekday_delta(date)
        (daily_readings, date) = process_reading(
            daily_readings, date, "Psa", extra_psalm_refs[i], datedelta
        )
Example #3
0
def LordsDayNT(daily_readings, year):

    date = datetime.datetime(year, 1, 1)  # January 1
    while date.strftime("%a") != "Sun":
        date += datetime.timedelta(days=1)  # Increment until Lord's Day

    def get_readings():

        readings = []

        nt_books = bible_books_list[
            bible_books_list.index("Matthew") : bible_books_list.index("Revelation") + 1
        ]
        for book in nt_books:
            book_abbr, book_chapters = bible_books[book]
            for chapter in range(1, book_chapters + 1):
                readings.append(book_abbr + " " + str(chapter))

        return readings

    chapter_count = 0
    for reading in get_readings():
        chapter_count += 1
        book_abbr, chapter = reading.split()
        datedelta = 0 if (chapter_count % 5) else 7
        # Every 5th chapter, increment to next Lord's Day

        # TODO: Properly handle merging of up to 5 references
        # (5 NT chapters each Lord's Day)
        (daily_readings, date) = process_reading(
            daily_readings, date, book_abbr, chapter, datedelta
        )
Example #4
0
def DailyOTDuo(daily_readings, year):
    # Daily OT Duo (OT without Psalms and without Solomon's Writings)

    # TODO: Move into separate file.

    date = datetime.datetime(year, 1, 1)  # January 1

    def get_readings():
        def get_num_extra_readings():
            num_extra_readings = 4 if calendar.isleap(year) else 2
            # print(f"{num_extra_readings} extra OTMain readings needed for {year}.")
            return num_extra_readings

        readings = []

        ot_without_psalms_and_solomon = bible_books_list[
            bible_books_list.index("Genesis"
                                   ):bible_books_list.index("Malachi") + 1]
        ot_without_psalms_and_solomon.remove("Psalms")
        for book in solomon:
            ot_without_psalms_and_solomon.remove(book)
        for book in ot_without_psalms_and_solomon:
            book_abbr, book_chapters = bible_books[book]
            for chapter in range(1, book_chapters + 1):
                readings.append(book_abbr + " " + str(chapter))

        substitutions = [
            ["Num 7", ["Num 7:1-47", "Num 7:48-89"]],
            ["1Ch 6", ["1Ch 6:1-48", "1Ch 6:49-81"]],
            ["Neh 7", ["Neh 7:1-38", "Neh 7:39-73"]],
            ["Ezr 2", ["Ezr 2:1-36", "Ezr 2:37-70"]],
        ]  # Split (when needed) 1-4 of the 4 longest OT chapters
        #    (excluding Psalms and Solomon's writings)

        for _ in range(get_num_extra_readings()):
            substitution = substitutions.pop(0)
            index = readings.index(substitution[0])
            readings[index:index + 1] = substitution[1]

        return readings

    chapter_count = 0
    for reading in get_readings():
        chapter_count += 1
        book_abbr, chapter = reading.split()
        datedelta = 0 if (chapter_count %
                          2) else 1  # Increment on every other chapter
        merge_refs = not (chapter_count % 2
                          )  # Merge references on every other chapter
        (daily_readings, date) = process_reading(daily_readings, date,
                                                 book_abbr, chapter, datedelta,
                                                 merge_refs)
Example #5
0
def Rest_OT(daily_readings, year):
    # 3 OT chapters on every day other than the Lord's Day

    date = datetime.datetime(year, 1, 1)  # January 1
    if date.strftime("%a") == "Sun":
        date += datetime.timedelta(days=1)  # Skip Lord's Day

    def get_readings():

        readings = []

        ot_books = bible_books_list[
            bible_books_list.index("Genesis") : bible_books_list.index("Malachi") + 1
        ]
        for book in ot_books:
            book_abbr, book_chapters = bible_books[book]
            for chapter in range(1, book_chapters + 1):
                readings.append(book_abbr + " " + str(chapter))

        ps119_index = readings.index("Psa 119")
        readings[ps119_index : ps119_index + 1] = [
            "Psa 119:1-24",
            "Psa 119:25-48",
            "Psa 119:49-72",
            "Psa 119:73-96",
            "Psa 119:97-120",
            "Psa 119:121-144",
            "Psa 119:145-160",
            "Psa 119:161-176",
        ]  # Split Psalm 119 for 52*6=312 total readings

        return readings

    chapter_count = 0
    for reading in get_readings():
        chapter_count += 1
        book_abbr, chapter = reading.split()
        datedelta = 0
        if not (chapter_count % 3):  # Increment on every third chapter
            datedelta = (
                2 if (get_weekday(date) == "Sat") else 1
            )  # Skip over Lord's Days
        # TODO: Merge similar references
        (daily_readings, date) = process_reading(
            daily_readings, date, book_abbr, chapter, datedelta
        )

    return daily_readings
Example #6
0
def WeekdayNT(daily_readings, year):  # Weekday New Testament
    date = datetime.datetime(year, 1, 1)  # January 1
    while date.strftime("%a") in ("Sat", "Sun"):
        date += datetime.timedelta(days=1)  # Increment until first weekday

    # TODO: Change this and similar functions to use classes/subclasses.

    def get_readings():
        def get_num_extra_readings():
            num_extra_readings = 0
            if get_weekday(datetime.datetime(year, 12,
                                             31)) not in ("Sat", "Sun"):
                num_extra_readings += 1  # Increment if December 31 is a weekday
            if calendar.isleap(year) and (get_weekday(
                    datetime.datetime(year, 12, 30)) not in ("Sat", "Sun")):
                num_extra_readings += (
                    1  # Increment if leap year & December 30 is a weekday
                )
            # print(f'{num_extra_readings} extra WeekdayNT readings needed for {year}')
            return num_extra_readings

        readings = []
        for book in bible_books_list[bible_books_list.index("Matthew"):
                                     bible_books_list.index("Revelation") + 1]:
            book_abbr, book_chapters = bible_books[book]
            for chapter in range(1, book_chapters + 1):
                readings.append(book_abbr + " " + str(chapter))

        substitutions = [
            ["Luk 1", ["Luk 1:1-38", "Luk 1:39-80"]],
            ["Mat 26", ["Mat 26:1-35", "Mat 26:36-75"]],
        ]  # Split (when needed) 1 or 2 of the 2 longest NT chapters
        for i in range(get_num_extra_readings()):
            substitution = substitutions.pop(0)
            index = readings.index(substitution[0])
            readings[index:index + 1] = substitution[1]

        return readings

    readings = get_readings()
    for reading in readings:
        book_abbr, chapter = reading.split()
        datedelta = get_weekday_delta(date)
        (daily_readings, date) = process_reading(daily_readings, date,
                                                 book_abbr, chapter, datedelta)
Example #7
0
def WeeklySolomon(daily_readings, year,
                  day_of_week):  # Weekly Solomon's Readings
    # Proverbs, Ecclesiastes, and SongOfSolomon

    date = datetime.datetime(year, 1, 1)  # January 1
    while date.strftime("%a") != day_of_week:
        date += datetime.timedelta(
            days=1)  # Increment until specified day_of_week

    def get_readings():
        def get_num_extra_readings():
            num_extra_readings = 1  # There are only 51 chapters in Pro thru Ecc
            if (date + datetime.timedelta(days=52 * 7)) <= datetime.datetime(
                    year, 12, 31):
                # if (52 weeks from start date) is before or on December 31, then ...
                num_extra_readings += 1
            # print(f'{num_extra_readings} extra WeeklyWisdom readings are needed for {year} ({day_of_week})')
            return num_extra_readings

        readings = []
        for book in solomon:
            book_abbr, book_chapters = bible_books[book]
            for chapter in range(1, book_chapters + 1):
                readings.append(book_abbr + " " + str(chapter))

        substitutions = [
            ["Pro 8", ["Pro 8:1-18", "Pro 8:19-36"]],
            ["Pro 23", ["Pro 23:1-18", "Pro 23:19-35"]],
        ]  # Split (when needed) 1 or 2 of the 2 longest Weekly Wisdom chapters
        for i in range(get_num_extra_readings()):
            substitution = substitutions.pop(0)
            index = readings.index(substitution[0])
            readings[index:index + 1] = substitution[1]

        return readings

    readings = get_readings()
    for reading in readings:
        book_abbr, chapter = reading.split()
        (daily_readings, date) = process_reading(daily_readings, date,
                                                 book_abbr, chapter, 7)