From bc0d239a1f0c5d724b0f3e517c3d5ff03f18c9bc Mon Sep 17 00:00:00 2001 From: "Fredrick W. Warren" Date: Tue, 31 May 2022 09:51:53 -0700 Subject: [PATCH] Format subtitle to current/next Wednesday --- hcatitles.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hcatitles.py b/hcatitles.py index 891f709..5d2531c 100644 --- a/hcatitles.py +++ b/hcatitles.py @@ -1,5 +1,6 @@ import os import PySimpleGUI as sg +from datetime import date, timedelta from pathlib import Path from PIL import Image, ImageDraw, ImageEnhance, ImageFilter, ImageFont, ImageOps from io import BytesIO @@ -20,6 +21,15 @@ def save_filename(): return folder / 'Title.png' return Path.home() / 'Pictures' / 'Title.png' +def get_subtitle(): + """find Wednesday of the current/next week""" + today = date.today() + if today.weekday() > 2: + wednesday = today + tiemdelta(9 - today.weekday()) + else: + wednesday = today + timedelta(2 - today.weekday()) + return wednesday.strftime('Bible Study %A %B %#d, %Y') + def update_image(original, title, subtitle): """Render new title and title preview renders text on full sized slide @@ -93,7 +103,7 @@ def build_layout(title, subtitle, thumbnail): def main(): title = 'Pastor Shane Wallis' - subtitle = 'Bible Stduy Wednesday June 1st, 2022' + subtitle = get_subtitle() image_path = resource_path('blank_title.png') original = Image.open(image_path) image = update_image(original, title, subtitle)