Improved dates display by checking span in backend

This commit is contained in:
Edgar P. Burkhart 2022-01-28 10:06:13 +01:00
parent f53cc405f5
commit 3cf532072d
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 16 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import re
import datetime
class Event:
@ -50,3 +51,12 @@ class Event:
self._rrule,
).group(1)
def is_full_day(self):
return type(self._dtstart) is datetime.date
def is_one_day(self):
if self.is_full_day():
return self._dtend - self._dtstart <= datetime.timedelta(days=1)
return (self._dtend.time() == datetime.time.min \
and self._dtend - self._dtstart <= datetime.timedelta(days=1)) \
or self._dtend.date() == self._dtstart.date()

View file

@ -24,27 +24,31 @@
<span class="month">
{{ event.dtstart.strftime('%B').capitalize() }}
</span>
{% if not event.is_full_day() %}
<span class="time">
{{ event.dtstart.strftime('%H:%M') }}
</span>
{% endif %}
</div>
<div class="end-date">
{% if not event.dtend.date or event.dtend.date() != event.dtstart.date() %}
{% if not event.is_one_day() %}
<span class="weekday">
{{ event.dtend.strftime('%A').capitalize() }}
</span>
<span class="day">
{{ event.dtend.strftime('%d') }}
</span>
{% endif %}
{% if event.dtend.month != event.dtstart.month %}
<span class="month">
{{ event.dtend.strftime('%B').capitalize() }}
</span>
{% endif %}
{% endif %}
{% if not event.is_full_day() %}
<span class="time">
{{ event.dtend.strftime('%H:%M') }}
</span>
{% endif %}
</div>
</div>
<div class="info">