This commit is contained in:
@@ -47,10 +47,12 @@ def get_datetime(day: str) -> datetime:
|
||||
day = int(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.DECEMBER:
|
||||
# TODO(imcompiling): replace with Calendar.DECEMBER when updating to python 3.12
|
||||
# https://gitea.cheezers.org/imcompiling/dakiny-bot/issues/52
|
||||
if today.month == 12 and month < 12:
|
||||
year += 1
|
||||
|
||||
if today.month == calendar.JANUARY and month > calendar.JANUARY:
|
||||
if today.month == 1 and month > 1:
|
||||
year -= 1
|
||||
|
||||
return datetime(year, month, day, tzinfo=UTC)
|
||||
@@ -97,7 +99,7 @@ def get_current_election_cycle(config: DakinyConfig) -> int:
|
||||
Returns:
|
||||
int: cycle index for active election. None for no active cycle
|
||||
"""
|
||||
today = datetime.now(tz=UTC).date()
|
||||
today = datetime.now(tz=UTC)
|
||||
|
||||
for cycle, election in enumerate(config.election_cycles):
|
||||
if (
|
||||
@@ -120,7 +122,7 @@ def get_quarter_cycle(config: DakinyConfig) -> int:
|
||||
Returns:
|
||||
int: cycle index for current cycle.
|
||||
"""
|
||||
today = datetime.now(tz=UTC).date()
|
||||
today = datetime.now(tz=UTC)
|
||||
for cycle, election in enumerate(config.election_cycles):
|
||||
if (
|
||||
today.date() >= get_datetime(election.term_start).date()
|
||||
|
||||
Reference in New Issue
Block a user