@@ -1,5 +1,6 @@
|
||||
"""File contains util functions."""
|
||||
|
||||
import calendar
|
||||
import os
|
||||
from collections.abc import Sequence
|
||||
from datetime import UTC, datetime
|
||||
@@ -46,12 +47,10 @@ 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.
|
||||
# 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:
|
||||
if today.month == calendar.DECEMBER and month < calendar.DECEMBER:
|
||||
year += 1
|
||||
|
||||
if today.month == 1 and month > 1:
|
||||
if today.month == calendar.JANUARY and month > calendar.JANUARY:
|
||||
year -= 1
|
||||
|
||||
return datetime(year, month, day, tzinfo=UTC)
|
||||
|
||||
Reference in New Issue
Block a user