From 1044f8a521432c03a24f75d3b6a31e67138f0e24 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Sun, 2 Jul 2023 10:18:53 -0400 Subject: [PATCH] Change get_datetime to handle year changes. --- utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 7a2fc75..b0f0d92 100644 --- a/utils.py +++ b/utils.py @@ -1,3 +1,7 @@ +""" +File contains util functions. +""" + from datetime import datetime @@ -11,8 +15,12 @@ def get_datetime(day: str) -> datetime: Returns: datetime: Datetime representation of Month/Day. """ - today = datetime.today() + year = datetime.today().year month = int(day.split("/")[0]) day = int(day.split("/")[1]) - return datetime(today.year, month, day) + # ensure that year rolls over if current month is December and the next month is less than 12. + if datetime.today().month == 12 & month < 12: + year += 1 + + return datetime(year, month, day)