Also add environment variable to launch settings.
This commit is contained in:
+8
-6
@@ -35,20 +35,20 @@ VoteType = StrEnum("VoteType", ["COUNCIL", "DISCORDMANAGER", "CLANLEADER"])
|
||||
PointType = StrEnum("PointType", ["CLAN", "EVENT"])
|
||||
|
||||
|
||||
def get_datetime(day: str) -> datetime:
|
||||
def get_datetime(month_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.
|
||||
month_day (str): Month/Day in that format.
|
||||
|
||||
Returns:
|
||||
datetime: Datetime representation of Month/Day.
|
||||
"""
|
||||
today = datetime.now(tz=UTC).date()
|
||||
year = today.year
|
||||
month = int(day.split("/")[0])
|
||||
day = int(day.split("/")[1])
|
||||
month = int(month_day.split("/")[0])
|
||||
day = int(month_day.split("/")[1])
|
||||
|
||||
# ensure that year rolls over if current month is December and the next month is less than 12.
|
||||
if today.month == calendar.DECEMBER and month < calendar.OCTOBER:
|
||||
@@ -56,8 +56,10 @@ def get_datetime(day: str) -> datetime:
|
||||
|
||||
if today.month == calendar.JANUARY and month > calendar.MARCH:
|
||||
year -= 1
|
||||
|
||||
return datetime(year, month, day, tzinfo=UTC)
|
||||
try:
|
||||
return datetime(year, month, day, tzinfo=UTC)
|
||||
except ValueError:
|
||||
dakiny_logger.warning("Invalid month day: %s.", month_day)
|
||||
|
||||
|
||||
def get_election_name() -> str:
|
||||
|
||||
Reference in New Issue
Block a user