27 lines
656 B
Python
27 lines
656 B
Python
"""
|
|
File contains util functions.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
def get_datetime(day: str) -> datetime:
|
|
"""
|
|
Takes in a string month and day and returns a datetime object of that Month/Day this year.
|
|
|
|
Args:
|
|
day (str): Month/Day in that format.
|
|
|
|
Returns:
|
|
datetime: Datetime representation of Month/Day.
|
|
"""
|
|
year = datetime.today().year
|
|
month = int(day.split("/")[0])
|
|
day = int(day.split("/")[1])
|
|
|
|
# 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)
|