From 0e48e521e03978b2da0ccf7126c8a4694f9d0a6f Mon Sep 17 00:00:00 2001 From: Luca <87448287+LUCA-PYTHON@users.noreply.github.com> Date: Sat, 14 Mar 2026 20:27:04 +0100 Subject: [PATCH] Refactor date initialization and formatting Refactor date handling to improve clarity and correctness. --- datein/calendar.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/datein/calendar.py b/datein/calendar.py index b1f87ac..d24d5a4 100644 --- a/datein/calendar.py +++ b/datein/calendar.py @@ -60,10 +60,11 @@ async def today(self, interaction: discord.Interaction, button: discord.ui.Butto "You cannot control this calendar.", ephemeral=True ) - today = date.today() - self.year = today.year - self.month = today.month - self.day = None + today_date = date.today() + self.year = today_date.year + self.month = today_date.month + if self.day is not None: + self.day = today_date.day await self.update_calendar(interaction) @@ -194,7 +195,7 @@ async def generate_calendar_image(self, interaction, scope, month, year, day): if day: draw.text( (width // 2, 80 * scale), - f"{calendar.day_name[date(year, month, day).weekday()]}, {month}.{day}.{year}", + f"{calendar.day_name[date(year, month, day).weekday()]}, {day:02d}.{month:02d}.{year}", fill=text_color, font=font_title, anchor="mm"