Show time and timezone in separate columns

This commit is contained in:
Edward Betts 2023-10-29 16:08:17 +00:00
parent a9cad3c749
commit ec1694fc84
2 changed files with 26 additions and 1 deletions

View file

@ -32,6 +32,24 @@ class Event:
self.date.date() if isinstance(self.date, datetime.datetime) else self.date
)
@property
def display_time(self) -> str | None:
"""Time for display on web page."""
return (
self.date.strftime("%H:%M")
if isinstance(self.date, datetime.datetime)
else None
)
@property
def display_timezone(self) -> str | None:
"""Timezone for display on web page."""
return (
self.date.strftime("%z")
if isinstance(self.date, datetime.datetime)
else None
)
def delta_days(self, today: datetime.date) -> str:
"""Return number of days from today as a string."""
delta = (self.as_date - today).days

View file

@ -61,8 +61,15 @@
{% for event in events %}
<tr>
<td class="text-end">
{{event.display_date}}
{{event.as_date.strftime("%a, %d, %b %Y")}}
</td>
<td class="text-end">
{{event.display_time or ""}}
</td>
<td class="text-end">
{{event.display_timezone or ""}}
</td>
<td class="text-start {% if event.name in class_map %} {{ class_map[event.name]}}{% endif %}">
{% if event.url %}<a href="{{ event.url }}">{% endif %}
{{ event_labels.get(event.name) or event.name }}