Statistics Charts crashes with IndexError (#627)

Fixes #010626

In statistics charts, get_month is only localized and the calendar is unused.
If we have an Extra (Sansculottides) month in the french republican calendar
(index 13), we have this IndexError because the gregorian calendar is always
used and contains only 12 values.
This commit is contained in:
Serge Noiraud authored and Sam Manzi committed 2018-06-22 10:48:02 +10:00
1 parent 1f3e516780
commit 5df6ad564b
1 file changed
+12 -1
+12 -1
View File
@@ -426,11 +426,22 @@ class Extract:
def get_month(self, event):
"return month for given event"
date_displayer = self._locale.date_displayer
CAL_TO_LONG_MONTHS_NAMES = {
Date.CAL_GREGORIAN : date_displayer.long_months,
Date.CAL_JULIAN : date_displayer.long_months,
Date.CAL_HEBREW : date_displayer.hebrew,
Date.CAL_FRENCH : date_displayer.french,
Date.CAL_PERSIAN : date_displayer.persian,
Date.CAL_ISLAMIC : date_displayer.islamic,
Date.CAL_SWEDISH : date_displayer.swedish }
date = event.get_date_object()
if date:
month = date.get_month()
if month:
return [self._locale.date_displayer.long_months[month]]
month_names = CAL_TO_LONG_MONTHS_NAMES[date.get_calendar()]
return [month_names[month]]
return [_T_("Date(s) missing")]
def get_place(self, event):