aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar wookie184 <[email protected]>2024-05-23 13:34:50 +0100
committerGravatar GitHub <[email protected]>2024-05-23 12:34:50 +0000
commitfe7887d33c4fa274f71d3c7baff31694a9b8ab5e (patch)
tree954287cc8c7f04ab735e495815eb68b05ab4c1b8
parentMerge pull request #3063 from python-discord/jb3/nom-post-changes (diff)
Support events that span from one year to another (#3065)
-rw-r--r--bot/exts/backend/branding/_repository.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/bot/exts/backend/branding/_repository.py b/bot/exts/backend/branding/_repository.py
index db2061faa..20cad0a5d 100644
--- a/bot/exts/backend/branding/_repository.py
+++ b/bot/exts/backend/branding/_repository.py
@@ -230,7 +230,17 @@ class BrandingRepository:
for event in available_events:
meta = event.meta
- if not meta.is_fallback and (meta.start_date <= lookup_now <= meta.end_date):
+ if meta.is_fallback:
+ continue
+
+ start_date, end_date = meta.start_date, meta.end_date
+
+ # Case where the event starts and ends in the same year.
+ if start_date <= lookup_now <= end_date:
+ return event, available_events
+
+ # Case where the event spans across two years.
+ if start_date > end_date and (lookup_now >= start_date or lookup_now <= end_date):
return event, available_events
log.trace("No active event found. Looking for fallback event.")