From c2eea99d3a9ee97620a8bbf7aaf1e4ae60a94c49 Mon Sep 17 00:00:00 2001 From: selina <selina.baehr@stud.uni-goettingen.de> Date: Sun, 3 Dec 2023 14:28:00 +0100 Subject: [PATCH 1/2] hopefully fixed bug where site doesnt update day --- aocp/aoc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aocp/aoc.py b/aocp/aoc.py index de60996..152b722 100755 --- a/aocp/aoc.py +++ b/aocp/aoc.py @@ -135,8 +135,9 @@ def init_app(app): """ app.cli.add_command(test_aoc_py_command) -def get_aoc_day(timestamp : datetime = datetime.now(tz=timezone.utc), year : int|None = None)-> Tuple[int, int]: +def get_aoc_day(timestamp : datetime|None = None, year : int|None = None)-> Tuple[int, int]: """ + Gets the current day in the appropriate AOC timezone. If timestamp is None, the current time is used. Returns a tuple: - The current AOC Day (1-25), or 0 if the event hasn't started yet, or 26 if the event is already over. - The hour (0-23) of the AOC Day of the timestamp. @@ -145,6 +146,8 @@ def get_aoc_day(timestamp : datetime = datetime.now(tz=timezone.utc), year : int timestamp -- Overwrite the "current" timestamp. Must be timezone aware. year -- Overwrite the AOC year. If None the YEAR from the config is used. """ + if timestamp is None: + timestamp = datetime.now(tz=timezone.utc) timestamp = timestamp.astimezone(ZoneInfo("EST")) # convert to EST time hour = timestamp.hour if year is None: -- GitLab From 5703a956f00f4c2db7ec3e1c364e77f60f5a3114 Mon Sep 17 00:00:00 2001 From: selina <selina.baehr@stud.uni-goettingen.de> Date: Sun, 3 Dec 2023 14:30:46 +0100 Subject: [PATCH 2/2] documentation update --- aocp/aoc.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/aocp/aoc.py b/aocp/aoc.py index 152b722..0224470 100755 --- a/aocp/aoc.py +++ b/aocp/aoc.py @@ -137,13 +137,12 @@ def init_app(app): def get_aoc_day(timestamp : datetime|None = None, year : int|None = None)-> Tuple[int, int]: """ - Gets the current day in the appropriate AOC timezone. If timestamp is None, the current time is used. Returns a tuple: - The current AOC Day (1-25), or 0 if the event hasn't started yet, or 26 if the event is already over. - The hour (0-23) of the AOC Day of the timestamp. Parameters: - timestamp -- Overwrite the "current" timestamp. Must be timezone aware. + timestamp -- Overwrite the "current" timestamp. Must be timezone aware. If timestamp is None, the current time is used. year -- Overwrite the AOC year. If None the YEAR from the config is used. """ if timestamp is None: -- GitLab