Improved dates display by checking span in backend
This commit is contained in:
parent
f53cc405f5
commit
3cf532072d
2 changed files with 16 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
import re
|
import re
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
class Event:
|
class Event:
|
||||||
|
@ -50,3 +51,12 @@ class Event:
|
||||||
self._rrule,
|
self._rrule,
|
||||||
).group(1)
|
).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()
|
||||||
|
|
|
@ -24,27 +24,31 @@
|
||||||
<span class="month">
|
<span class="month">
|
||||||
{{ event.dtstart.strftime('%B').capitalize() }}
|
{{ event.dtstart.strftime('%B').capitalize() }}
|
||||||
</span>
|
</span>
|
||||||
|
{% if not event.is_full_day() %}
|
||||||
<span class="time">
|
<span class="time">
|
||||||
{{ event.dtstart.strftime('%H:%M') }}
|
{{ event.dtstart.strftime('%H:%M') }}
|
||||||
</span>
|
</span>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="end-date">
|
<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">
|
<span class="weekday">
|
||||||
{{ event.dtend.strftime('%A').capitalize() }}
|
{{ event.dtend.strftime('%A').capitalize() }}
|
||||||
</span>
|
</span>
|
||||||
<span class="day">
|
<span class="day">
|
||||||
{{ event.dtend.strftime('%d') }}
|
{{ event.dtend.strftime('%d') }}
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
|
||||||
{% if event.dtend.month != event.dtstart.month %}
|
{% if event.dtend.month != event.dtstart.month %}
|
||||||
<span class="month">
|
<span class="month">
|
||||||
{{ event.dtend.strftime('%B').capitalize() }}
|
{{ event.dtend.strftime('%B').capitalize() }}
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if not event.is_full_day() %}
|
||||||
<span class="time">
|
<span class="time">
|
||||||
{{ event.dtend.strftime('%H:%M') }}
|
{{ event.dtend.strftime('%H:%M') }}
|
||||||
</span>
|
</span>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
|
|
Reference in a new issue