date fallback
This commit is contained in:
parent
6f997abde2
commit
b65e2d940f
1 changed files with 27 additions and 24 deletions
|
@ -32,6 +32,7 @@ class Event(models.Model):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def display_date(self):
|
def display_date(self):
|
||||||
|
if self.date:
|
||||||
date = self.date.split(' ')
|
date = self.date.split(' ')
|
||||||
start = date[0].split('-')
|
start = date[0].split('-')
|
||||||
if len(date) > 1:
|
if len(date) > 1:
|
||||||
|
@ -49,14 +50,16 @@ class Event(models.Model):
|
||||||
start = [int(p) for p in start]
|
start = [int(p) for p in start]
|
||||||
end = [int(p) for p in end]
|
end = [int(p) for p in end]
|
||||||
|
|
||||||
display_date = datetime(*start).strftime('%d %B, %Y')
|
display_date = datetime(*start).strftime('%e %B, %Y')
|
||||||
if start_only_month:
|
if start_only_month:
|
||||||
display_date = ' '.join(display_date.split(' ')[1:])
|
display_date = ' '.join(display_date.split(' ')[1:])
|
||||||
if end != start:
|
if end != start:
|
||||||
end_date = datetime(*end).strftime('%d %B, %Y')
|
end_date = datetime(*end).strftime('%e %B, %Y')
|
||||||
if end_only_month:
|
if end_only_month:
|
||||||
end_date = ' '.join(end_date.split(' ')[1:])
|
end_date = ' '.join(end_date.split(' ')[1:])
|
||||||
display_date += ' — ' + end_date
|
display_date += ' — ' + end_date
|
||||||
|
else:
|
||||||
|
display_date = ''
|
||||||
return display_date
|
return display_date
|
||||||
|
|
||||||
def media_html(self):
|
def media_html(self):
|
||||||
|
|
Loading…
Reference in a new issue