@@ -23,7 +23,7 @@ def _ensure_intermediate_dirs(fname):
2323 raise
2424
2525
26- def blocker (quiet = False , dt = 0.1 , datefmt = "%-I:%M %p" , until = None ):
26+ def blocker (quiet = False , dt = 0.1 , datefmt = None , until = None ):
2727 """
2828 This function just blocks until the next puzzle unlocks.
2929 Pass `quiet=True` to disable the spinner etc.
@@ -48,13 +48,18 @@ def blocker(quiet=False, dt=0.1, datefmt="%-I:%M %p", until=None):
4848 return
4949 spinner = cycle (r"\|/-" )
5050 localzone = tzlocal .get_localzone ()
51+ local_unlock = unlock .astimezone (tz = localzone )
52+ if datefmt is None :
53+ # %-I does not work on Windows, strip leading zeros manually
54+ local_unlock = local_unlock .strftime ("%I:%M %p" ).lstrip ("0" )
55+ else :
56+ local_unlock = local_unlock .strftime (datefmt )
57+ msg = "{} Unlock day %s at %s ({} remaining)" % (unlock .day , local_unlock )
5158 while datetime .now (tz = AOC_TZ ) < unlock :
52- local_unlock = unlock .astimezone (tz = localzone )
53- msg = "{} Unlock day {} at {:%s} ({} remaining)" % datefmt
5459 remaining = unlock - datetime .now (tz = AOC_TZ )
5560 remaining = str (remaining ).split ("." )[0 ] # trim microseconds
5661 if not quiet :
57- sys .stdout .write (msg .format (next (spinner ), unlock . day , local_unlock , remaining ))
62+ sys .stdout .write (msg .format (next (spinner ), remaining ))
5863 sys .stdout .flush ()
5964 time .sleep (dt )
6065 if not quiet :
0 commit comments