diff --git a/src/DataViews/RelationView.py b/src/DataViews/RelationView.py index 41e40aa4c..0d6348cae 100644 --- a/src/DataViews/RelationView.py +++ b/src/DataViews/RelationView.py @@ -567,11 +567,34 @@ class RelationshipView(PageView.PersonNavView): else: death_title = _("Death") - subtbl.attach(widgets.BasicLabel("%s:" % death_title), - 1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0) - subtbl.attach(widgets.BasicLabel(self.format_event(death)), - 2, 3, 2, 3, yoptions=0) + showed_death = False + if birth: + birth_date = birth.get_date_object() + if (birth_date and birth_date.get_valid()): + if death: + death_date = death.get_date_object() + if (death_date and death_date.get_valid()): + age = death_date - birth_date + subtbl.attach(widgets.BasicLabel("%s:" % death_title), + 1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0) + subtbl.attach(widgets.BasicLabel("%s (%s)" % + (self.format_event(death), + age)), + 2, 3, 2, 3, yoptions=0) + showed_death = True + if not showed_death: + age = gen.lib.date.Today() - birth_date + subtbl.attach(widgets.BasicLabel("%s:" % death_title), + 1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0) + subtbl.attach(widgets.BasicLabel("(%s)" % age), + 2, 3, 2, 3, yoptions=0) + showed_death = True + if not showed_death: + subtbl.attach(widgets.BasicLabel("%s:" % death_title), + 1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0) + subtbl.attach(widgets.BasicLabel(self.format_event(death)), + 2, 3, 2, 3, yoptions=0) mbox = gtk.HBox() mbox.add(table) diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py index 3b65ccb85..1ff3ab343 100644 --- a/src/gen/lib/date.py +++ b/src/gen/lib/date.py @@ -1140,4 +1140,12 @@ class Date: """ return self._get_low_item_valid(Date._POS_SL) +def Today(): + """ + Returns a Date object set to the current date. + """ + import time + current_date = Date() + current_date.set_yr_mon_day(*time.localtime(time.time())[0:3]) + return current_date