aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/events/hacktoberfest/timeleft.py
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2023-05-09 16:01:01 +0100
committerGravatar GitHub <[email protected]>2023-05-09 16:01:01 +0100
commitc3e23e60278d34658f801bd7d7ed721d5a272637 (patch)
treee159a0fae7850d706d713cf2b49dfed2140ce655 /bot/exts/events/hacktoberfest/timeleft.py
parentBump sentry-sdk from 1.21.1 to 1.22.1 (#1273) (diff)
parentMove unshared contants inside modules (diff)
Merge pull request #1270 from python-discord/migrate-to-ruff
Migrate to ruff
Diffstat (limited to 'bot/exts/events/hacktoberfest/timeleft.py')
-rw-r--r--bot/exts/events/hacktoberfest/timeleft.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/bot/exts/events/hacktoberfest/timeleft.py b/bot/exts/events/hacktoberfest/timeleft.py
index f470e932..8f46d798 100644
--- a/bot/exts/events/hacktoberfest/timeleft.py
+++ b/bot/exts/events/hacktoberfest/timeleft.py
@@ -1,5 +1,5 @@
import logging
-from datetime import datetime
+from datetime import UTC, datetime
from discord.ext import commands
@@ -9,25 +9,25 @@ log = logging.getLogger(__name__)
class TimeLeft(commands.Cog):
- """A Cog that tells you how long left until Hacktober is over!"""
+ """A Cog that tells users how long left until Hacktober is over!"""
def in_hacktober(self) -> bool:
"""Return True if the current time is within Hacktoberfest."""
_, end, start = self.load_date()
- now = datetime.utcnow()
+ now = datetime.now(tz=UTC)
return start <= now <= end
@staticmethod
def load_date() -> tuple[datetime, datetime, datetime]:
- """Return of a tuple of the current time and the end and start times of the next October."""
- now = datetime.utcnow()
+ """Return of a tuple of the current time and the end and start times of the next Hacktober."""
+ now = datetime.now(tz=UTC)
year = now.year
if now.month > 10:
year += 1
- end = datetime(year, 11, 1, 12) # November 1st 12:00 (UTC-12:00)
- start = datetime(year, 9, 30, 10) # September 30th 10:00 (UTC+14:00)
+ end = datetime(year, 11, 1, 12, tzinfo=UTC) # November 1st 12:00 (UTC-12:00)
+ start = datetime(year, 9, 30, 10, tzinfo=UTC) # September 30th 10:00 (UTC+14:00)
return now, end, start
@commands.command()