diff --git a/events/README.md b/events/README.md index 8e2e5fa..7536594 100644 --- a/events/README.md +++ b/events/README.md @@ -23,7 +23,7 @@ start_date: July 10 end_date: July 20 ``` -There must be exactly 1 fallback event, and 0 or more non-fallback events. Events cannot collide in time, and the end date must either be equal to the start date (1 day event) or chronologically subsequent. Both bounds are inclusive, and the format shown in the example above must be followed. +There must be exactly 1 fallback event, and 0 or more non-fallback events. For single-day events, `end_date` must be equal to `start_date`. If `start_date` is a later day in the year than `end_date`, the event is interpreted as starting in one year and ending in the next. Both bounds are inclusive, and the format shown in the example above must be followed. The markdown section of the meta file then contains the event's description. Descriptions are made available directly in the Discord guild as embeds sent by the Python bot. For formatting, use Discord's watered down Markdown ~ keep in mind that e.g. the `#` symbol does not create a heading. diff --git a/events/new_year/meta.md b/events/new_year/meta.md index 2cb552a..e096cca 100644 --- a/events/new_year/meta.md +++ b/events/new_year/meta.md @@ -1,6 +1,6 @@ --- -start_date: December 26 -end_date: December 31 +start_date: December 29 +end_date: January 3 --- **New Year** diff --git a/events/validation.py b/events/validation.py index 15c46b1..c99dd8c 100644 --- a/events/validation.py +++ b/events/validation.py @@ -9,7 +9,6 @@ We check that each event directory satisfies the following: * Contains 'meta.md', `banners/` and 'server_icons/' with at least 1 file inside each * The 'meta.md' file either registers the event as fallback, or specifies the start and end dates -* The end date must either be the same as the start date, or chronologically subsequent * The 'meta.md' file contains an event description between 1 and 2048 characters in length If all events are set up correctly, we also validate that: @@ -123,8 +122,6 @@ def make_event(name: str, from_dir: Path) -> Event: except Exception as exc: raise Misconfiguration(f"Attribute 'end_date' with value '{end_date}' failed to parse: {exc}") - if not start_date <= end_date: - raise Misconfiguration("End date must be equal or subsequent to start date") return Event(name=name, fallback=False, start_date=start_date, end_date=end_date, description=description) @@ -133,20 +130,21 @@ def active_days(event: Event) -> t.Iterator[date]: """ Generate all days in which `event` is active. + All dates returned will be in the same year. + This can only be called for non-fallback events. The fallback event does not have start and end dates. """ if None in (event.start_date, event.end_date): raise RuntimeError("Cannot generate days: event does not have start and date!") - if not event.start_date <= event.end_date: - raise RuntimeError("Cannot generate days: start date does not precede end date!") - state = event.start_date while True: yield state if state == event.end_date: break state += timedelta(days=1) + # Wrap around to the same year, so comparisons only compare day and month. + state = state.replace(year=ARBITRARY_YEAR) def find_collisions(events: t.List[Event]) -> t.Dict[date, t.List[Event]]: