Skip to content

Commit

Permalink
fix dates on hacksburg.org posts
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterirving committed Jul 17, 2024
1 parent fb1abd0 commit 9f40659
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions extensions/hacksburg/hacksburg.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,19 @@ def handle_get(req):
title_and_subtitle += f"<br><span>{post['subtitle']}</span>"

description = f"<span>{post['description']}</span><br><br>"
event_datetime = datetime.strptime(f"{post['date']} {post['start_time']}", "%Y-%m-%d %I:%M%p")

# Normalize time format
start_time = datetime.strptime(post['start_time'], '%I:%M%p').strftime('%-I:%M%p')
start_time = event_datetime.strftime('%-I:%M%p')
end_time = datetime.strptime(post['end_time'], '%I:%M%p').strftime('%-I:%M%p')
if start_time[-2:] != end_time[-2:]:
time_string = f"{start_time} - {end_time}"
else:
time_string = f"{start_time[:-2]} - {end_time}"
event_date = event_datetime.strftime('%A, %B %d')

# Format the date without leading zero for single-digit days
event_date = event_datetime.strftime('%A, %B ') + str(event_datetime.day)

event_time = f"<span><b>Time</b>: {event_date} from {time_string}</span><br>"

# Generate location string
Expand Down Expand Up @@ -293,4 +297,4 @@ def handle_request(req):
elif req.method == 'GET':
return handle_get(req)
else:
return "Not Found", 404
return "Not Found", 404

0 comments on commit 9f40659

Please sign in to comment.