From d07dd3208d61cd5d9636bc950026bb0a911ec5ac Mon Sep 17 00:00:00 2001 From: asc Date: Fri, 12 Aug 2022 15:40:00 -0500 Subject: [PATCH] fix long month names to abbreviations --- instagen/utils/gen_image.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/instagen/utils/gen_image.py b/instagen/utils/gen_image.py index dfa2f40..6ac699b 100644 --- a/instagen/utils/gen_image.py +++ b/instagen/utils/gen_image.py @@ -133,7 +133,10 @@ def gen_image( # First line: Date font = ImageFont.truetype(font_regular_path, 62) - text = f"{date:%a, %B %-d %-I:%M %p}".upper() + if len(f"{date:%B}") <= 4: + text = f"{date:%a, %B %-d %-I:%M %p}".upper() + else: + text = f"{date:%a, %b %-d %-I:%M %p}".upper() # text = date loc = (1050, 280) section_info_draw.text(loc, text, (14, 42, 28), font=font, anchor="ra") @@ -267,7 +270,10 @@ def gen_results_image( ) # Second line: Date - text = f"{date:%a, %B %-d %-I:%M %p}".upper() + if len(f"{date:%B}") <= 4: + text = f"{date:%a, %B %-d %-I:%M %p}".upper() + else: + text = f"{date:%a, %b %-d %-I:%M %p}".upper() # text = date font = ImageFont.truetype(font_condensed_path, 34) loc = (1050, 355)