From d9e98c32fed67e1c01cd496341ef196bba88ca32 Mon Sep 17 00:00:00 2001 From: Sebastiaan Zeeff Date: Tue, 1 Dec 2020 23:12:26 +0100 Subject: Clarify time_left_until_est_midnight function The helper function calculates the time left until the next midnight in the EST timezone, not necessarily the next midnight during and Advent of Code event. To prevent confusion, I've clarified its function by changing the name of the function and its docstring. --- bot/exts/christmas/advent_of_code/_cog.py | 2 +- bot/exts/christmas/advent_of_code/_helpers.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'bot') diff --git a/bot/exts/christmas/advent_of_code/_cog.py b/bot/exts/christmas/advent_of_code/_cog.py index 902391b5..2f60e512 100644 --- a/bot/exts/christmas/advent_of_code/_cog.py +++ b/bot/exts/christmas/advent_of_code/_cog.py @@ -108,7 +108,7 @@ class AdventOfCode(commands.Cog): f"The next event will start in {delta_str}.") return - tomorrow, time_left = _helpers.time_left_to_aoc_midnight() + tomorrow, time_left = _helpers.time_left_to_est_midnight() hours, minutes = time_left.seconds // 3600, time_left.seconds // 60 % 60 diff --git a/bot/exts/christmas/advent_of_code/_helpers.py b/bot/exts/christmas/advent_of_code/_helpers.py index 1c4a01ed..c75f47fa 100644 --- a/bot/exts/christmas/advent_of_code/_helpers.py +++ b/bot/exts/christmas/advent_of_code/_helpers.py @@ -353,8 +353,8 @@ def is_in_advent() -> bool: return datetime.datetime.now(EST).day in range(1, 25) and datetime.datetime.now(EST).month == 12 -def time_left_to_aoc_midnight() -> Tuple[datetime.datetime, datetime.timedelta]: - """Calculates the amount of time left until midnight in UTC-5 (Advent of Code maintainer timezone).""" +def time_left_to_est_midnight() -> Tuple[datetime.datetime, datetime.timedelta]: + """Calculate the amount of time left until midnight EST/UTC-5.""" # Change all time properties back to 00:00 todays_midnight = datetime.datetime.now(EST).replace( microsecond=0, @@ -423,7 +423,7 @@ async def countdown_status(bot: Bot) -> None: end = last_challenge + datetime.timedelta(hours=1) while datetime.datetime.now(EST) < end: - _, time_left = time_left_to_aoc_midnight() + _, time_left = time_left_to_est_midnight() aligned_seconds = int(math.ceil(time_left.seconds / COUNTDOWN_STEP)) * COUNTDOWN_STEP hours, minutes = aligned_seconds // 3600, aligned_seconds // 60 % 60 @@ -481,7 +481,7 @@ async def day_countdown(bot: Bot) -> None: end = datetime.datetime(AdventOfCode.year, 12, 25, tzinfo=EST) while datetime.datetime.now(EST) < end: log.trace("Started puzzle notification loop.") - tomorrow, time_left = time_left_to_aoc_midnight() + tomorrow, time_left = time_left_to_est_midnight() # Use fractional `total_seconds` to wake up very close to our target, with # padding of 0.1 seconds to ensure that we actually pass midnight. -- cgit v1.2.3