Skip to content

Commit

Permalink
Fix timezone error with events homepage block
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelmdLow committed Aug 24, 2024
1 parent 4cf1454 commit 0bb240b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions home/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ def get_context(self, value, parent_context=None):
context = super().get_context(value, parent_context)
context['events'] = Event.objects.filter(hidden=False, end_time__gte=timezone.now()).exclude(category='seminar').order_by("start_time")[:5]

today = timezone.now().astimezone(timezone.get_current_timezone())
for i in range(len(context['events'])):
today = timezone.now()

if context['events'][i].start_time < today:
pubdate = context['events'][i].end_time.astimezone(timezone.get_current_timezone())
display = "Ends "
Expand All @@ -99,7 +100,6 @@ def get_context(self, value, parent_context=None):
delta = abs(today - pubdate)

day = ""

if pubdate.date() == today.date():
day = "Today"
elif (pubdate - timedelta(days=1)).date() == today.date():
Expand Down

0 comments on commit 0bb240b

Please sign in to comment.