aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar Joseph <[email protected]>2018-12-26 15:28:35 +0000
committerGravatar GitHub <[email protected]>2018-12-26 15:28:35 +0000
commit73bfb73b858ee6ebc63e0a2eda47a3131310cbe3 (patch)
tree0b2bfe6fd391f317a6b574fabb9f01aad6d7b205 /bot
parentMerge pull request #88 from scragly/si_2 (diff)
parentAddress flake8 complaints (diff)
Merge pull request #92 from python-discord/fix-advent-of-code-countdown
Fix advent of code countdown
Diffstat (limited to 'bot')
-rw-r--r--bot/seasons/christmas/adventofcode.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py
index 458eb19f..486d3b18 100644
--- a/bot/seasons/christmas/adventofcode.py
+++ b/bot/seasons/christmas/adventofcode.py
@@ -29,7 +29,8 @@ def is_in_advent() -> bool:
Utility function to check if we are between December 1st
and December 25th.
"""
- return datetime.now(EST).day in range(1, 26) and datetime.now(EST).month == 12
+ # Run the code from the 1st to the 24th
+ return datetime.now(EST).day in range(1, 25) and datetime.now(EST).month == 12
def time_left_to_aoc_midnight() -> Tuple[datetime, timedelta]:
@@ -179,6 +180,14 @@ class AdventOfCode:
"""
Return time left until next day
"""
+ if not is_in_advent():
+ datetime_now = datetime.datetime.now(EST)
+ december_first = datetime.datetime(datetime_now.year + 1, 12, 1, tzinfo=EST)
+ delta = december_first - datetime_now
+ await ctx.send(f"The Advent of Code event is not currently running. "
+ f"The next event will start in {delta.days} days.")
+ return
+
tomorrow, time_left = time_left_to_aoc_midnight()
hours, minutes = time_left.seconds // 3600, time_left.seconds // 60 % 60