4teamwork/ftw.contentpage — pull request #53 by maethu (2013-04-26 08:40:03+00:00)
Title: Eventpage: getDate function

https://github.com/4teamwork/ftw.contentpage/blob/master/ftw/contentpage/content/eventpage.py#L85
Function `getDate` has a strange behavior:
- Whole day events only displays the start date
- Unused time is shown

Do something like:
```python
def getDate(self):
start = DT2dt(self.start())
start_date = start.date().strftime('%d.%m.%Y')
start_time = start.time().strftime('%H:%M')
end = DT2dt(self.end())
end_date = end.date().strftime('%d.%m.%Y')
end_time = end.time().strftime('%H:%M')

if self.getWholeDay():
if start_date == end_date:
return start_date
return '%s - %s' % (start_date, end_date)

if start_date == end_date:
return '%s %s - %s ' % (start_date, start_time, end_time)
return '%s %s - %s %s ' % (
start_date, start_time, end_date, end_time)
```

or

```python
def pretty_date(self, brain):
context = aq_inner(self.context)
ttool = getToolByName(context, 'translation_service')

start = brain.start
end = brain.end

startYear = start.year()
endYear = end.year()
startMonth = ttool.utranslate(domain='plonelocales', msgid=ttool.month_msgid(start.month()),context=context)
endMonth = ttool.utranslate(domain='plonelocales', msgid=ttool.month_msgid(end.month()),context=context)
startDay = start.day()
endDay = end.day()

datestr = ''
# multi day event
if startYear != endYear or startMonth != endMonth or startDay != endDay:
# multi year
if startYear != endYear:
datestr = _(u'pretty_date_multi_year',
default=u'${sday}. ${smonth} ${syear} - ${eday}. ${emonth} ${eyear}',
mapping={'sday':startDay,'smonth':startMonth, 'syear':startYear,
'eday':endDay, 'emonth':endMonth, 'eyear':endYear})
# multi Month
elif startMonth != endMonth:
datestr = _(u'pretty_date_multi_month',
default=u'${sday}. ${smonth} - ${eday}. ${emonth} ${eyear}',
mapping={'sday':startDay,'smonth':startMonth,
'eday':endDay, 'emonth':endMonth, 'eyear':endYear})
# multi day
else:
datestr = _(u'pretty_date_multi_day',
default=u'${sday}. - ${eday}. ${emonth} ${eyear}',
mapping={'sday':startDay,'eday':endDay,
'emonth':endMonth, 'eyear':endYear})
# same day
else:
datestr = _(u'pretty_date_same_day',
default=u'${day}. ${month} ${year}',
mapping={'day':startDay,'month':startMonth,'year': startYear},)

return datestr
```