diff --git a/src/plugins/drawreport/Calendar.py b/src/plugins/drawreport/Calendar.py index 759b32085..233516822 100644 --- a/src/plugins/drawreport/Calendar.py +++ b/src/plugins/drawreport/Calendar.py @@ -256,7 +256,7 @@ class Calendar(Report): birth_event = self.database.get_event_from_handle(birth_ref.ref) birth_date = birth_event.get_date_object() - if self.birthdays and birth_date is not None: + if (self.birthdays and birth_date is not None and birth_date.is_valid()): year = birth_date.get_year() month = birth_date.get_month() day = birth_date.get_day() @@ -329,31 +329,33 @@ class Calendar(Report): for event_ref in fam.get_event_ref_list(): event = self.database.get_event_from_handle(event_ref.ref) event_obj = event.get_date_object() - year = event_obj.get_year() - month = event_obj.get_month() - day = event_obj.get_day() - prob_alive_date = gen.lib.Date(self.year, month, day) + if event_obj.is_valid(): + year = event_obj.get_year() + month = event_obj.get_month() + day = event_obj.get_day() - nyears = self.year - year - if nyears == 0: - text = _("%(spouse)s and\n %(person)s, wedding") % { - 'spouse' : spouse_name, - 'person' : short_name, - } - else: - text = (ngettext("%(spouse)s and\n %(person)s, %(nyears)d", - "%(spouse)s and\n %(person)s, %(nyears)d", nyears) - % {'spouse' : spouse_name, - 'person' : short_name, - 'nyears' : nyears}) + prob_alive_date = gen.lib.Date(self.year, month, day) + + nyears = self.year - year + if nyears == 0: + text = _('%(spouse)s and\n %(person)s, wedding') % { + 'spouse' : spouse_name, + 'person' : short_name, + } + else: + text = (ngettext("%(spouse)s and\n %(person)s, %(nyears)d", + "%(spouse)s and\n %(person)s, %(nyears)d", nyears) + % {'spouse' : spouse_name, + 'person' : short_name, + 'nyears' : nyears}) - alive1 = probably_alive(person, self.database, \ - prob_alive_date) - alive2 = probably_alive(spouse, self.database, \ - prob_alive_date) - if ((self.alive and alive1 and alive2) or not self.alive): - self.add_day_item(text, month, day) + alive1 = probably_alive(person, self.database, \ + prob_alive_date) + alive2 = probably_alive(spouse, self.database, \ + prob_alive_date) + if ((self.alive and alive1 and alive2) or not self.alive): + self.add_day_item(text, month, day) #------------------------------------------------------------------------ # diff --git a/src/plugins/textreport/BirthdayReport.py b/src/plugins/textreport/BirthdayReport.py index 98efd8582..cc69d2723 100644 --- a/src/plugins/textreport/BirthdayReport.py +++ b/src/plugins/textreport/BirthdayReport.py @@ -203,7 +203,7 @@ class CalendarReport(Report): birth_event = self.database.get_event_from_handle(birth_ref.ref) birth_date = birth_event.get_date_object() - if self.birthdays and birth_date is not None: + if (self.birthdays and birth_date is not None and birth_date.is_valid()): year = birth_date.get_year() month = birth_date.get_month() day = birth_date.get_day() @@ -290,24 +290,26 @@ class CalendarReport(Report): month = event_obj.get_month() day = event_obj.get_day() nyears = self.year - year - if nyears == 0: - text = _("%(spouse)s and\n %(person)s, wedding") % { - 'spouse' : spouse_name, - 'person' : short_name} - else: - text = (ngettext("%(spouse)s and\n %(person)s, %(nyears)d", - "%(spouse)s and\n %(person)s, %(nyears)d", nyears) - % {'spouse' : spouse_name, - 'person' : short_name, - 'nyears' : nyears}) + + if event_obj.is_valid(): + if nyears == 0: + text = _("%(spouse)s and\n %(person)s, wedding") % { + 'spouse' : spouse_name, + 'person' : short_name} + else: + text = (ngettext("%(spouse)s and\n %(person)s, %(nyears)d", + "%(spouse)s and\n %(person)s, %(nyears)d", nyears) + % {'spouse' : spouse_name, + 'person' : short_name, + 'nyears' : nyears}) - prob_alive_date = gen.lib.Date(self.year, month, day) - alive1 = probably_alive(person, self.database, \ - prob_alive_date) - alive2 = probably_alive(spouse, self.database, \ - prob_alive_date) - if (self.alive and alive1 and alive2) or not self.alive: - self.add_day_item(text, month, day) + prob_alive_date = gen.lib.Date(self.year, month, day) + alive1 = probably_alive(person, self.database, \ + prob_alive_date) + alive2 = probably_alive(spouse, self.database, \ + prob_alive_date) + if (self.alive and alive1 and alive2) or not self.alive: + self.add_day_item(text, month, day) #------------------------------------------------------------------------ # diff --git a/src/plugins/webreport/WebCal.py b/src/plugins/webreport/WebCal.py index 293ad9ef0..fa0b48f0b 100644 --- a/src/plugins/webreport/WebCal.py +++ b/src/plugins/webreport/WebCal.py @@ -402,7 +402,6 @@ class WebCalReport(Report): nav_text = get_short_month_name(nav_text) # Figure out if we need