diff --git a/start_day.py b/start_day.py index 2f72812..25fb9ee 100644 --- a/start_day.py +++ b/start_day.py @@ -5,13 +5,14 @@ from os.path import exists from platform import system from subprocess import call from time import sleep +from tools.tools import human_readable_time_from_delta import webbrowser YEAR = 2023 CHARMS = { - 'Linux': '/usr/local/bin/charm', - 'Windows': r'C:\Users\pennywise\AppData\Local\JetBrains\Toolbox\scripts\pycharm.cmd' + "Linux": "/usr/local/bin/charm", + "Windows": r"C:\Users\pennywise\AppData\Local\JetBrains\Toolbox\scripts\pycharm.cmd", } arg_parser = ArgumentParser() @@ -37,9 +38,14 @@ if start > now: print("Do you really want to wait %d days?" % time_wait.days) exit() - for x in range(time_wait.seconds, -1, -1): - print("Day starts in %02ds.\r" % x) - sleep(1) + while time_wait.seconds > 0: + print("Day %d starts in %s.\r" % (DAY, human_readable_time_from_delta(time_wait))) + if time_wait.seconds > 70: + wait = min(1, time_wait.seconds // 3600) * 3600 + min(1, time_wait.seconds // 60) * 60 + sleep(wait) + else: + sleep(1) + time_wait = start - datetime.now() webbrowser.open("https://adventofcode.com/%d/day/%d" % (YEAR, DAY))