Added to display age at death if dead, or current age if alive

svn: r11471
This commit is contained in:
Doug Blank 2008-12-14 14:52:54 +00:00
parent ab98ce5d88
commit 246f76621a
2 changed files with 35 additions and 4 deletions

View File

@ -567,12 +567,35 @@ class RelationshipView(PageView.PersonNavView):
else:
death_title = _("Death")
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)

View File

@ -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