|
30 | 30 | from collections.abc import Callable |
31 | 31 | from collections.abc import Generator |
32 | 32 | from contextlib import contextmanager |
33 | | -from datetime import datetime |
34 | 33 | from pathlib import Path |
35 | 34 | from typing import Any |
36 | 35 |
|
37 | 36 | import pebble |
38 | | -from dateutil.tz import gettz |
| 37 | + |
| 38 | +from aoc import calendar |
39 | 39 |
|
40 | 40 | from . import Result |
41 | 41 | from .aocd import AocdHelper |
|
55 | 55 | from .rust import Rust |
56 | 56 |
|
57 | 57 | DEFAULT_TIMEOUT = config.default_timeout |
58 | | -AOC_TZ = gettz("America/New_York") |
59 | 58 | log = logging.getLogger(__name__) |
60 | 59 | all_plugins = OrderedDict( |
61 | 60 | { |
|
70 | 69 |
|
71 | 70 |
|
72 | 71 | def main() -> None: |
73 | | - aoc_now = datetime.now(tz=AOC_TZ) |
74 | | - years = range(2015, aoc_now.year + int(aoc_now.month == 12)) |
| 72 | + years = calendar.valid_years() |
75 | 73 | days = range(1, 26) |
76 | 74 | users = AocdHelper.load_users() |
77 | 75 | parser = ArgumentParser(description="AoC runner") |
@@ -102,7 +100,7 @@ def main() -> None: |
102 | 100 | nargs="+", |
103 | 101 | choices=days, |
104 | 102 | default=days, |
105 | | - help="AoC days to run. Runs all 1-25 by default.", |
| 103 | + help="AoC days to run. Runs all days by default.", |
106 | 104 | ) |
107 | 105 | parser.add_argument( |
108 | 106 | "-u", |
@@ -274,11 +272,10 @@ def run_for( |
274 | 272 | autosubmit: bool, |
275 | 273 | listener: Listener, |
276 | 274 | ) -> int: |
277 | | - aoc_now = datetime.now(tz=AOC_TZ) |
278 | 275 | it = itertools.product(years, days, plugins.items(), datasets) |
279 | 276 | n_incorrect = 0 |
280 | 277 | for year, day, plugin, user_id in it: |
281 | | - if year == aoc_now.year and day > aoc_now.day: |
| 278 | + if not calendar.is_valid_day(year, day): |
282 | 279 | continue |
283 | 280 | token = datasets[user_id] |
284 | 281 | puzzle = Puzzle.create(token, year, day, autosubmit) |
|
0 commit comments