From 523a3b394394b3d06a41a31f35b201e702bdc062 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Tue, 21 Sep 2004 02:10:23 +0000 Subject: [PATCH] * src/Date.py (get_high_year): Add method to return upper estimate. * src/AddSpouse.py: Correctly use upper and lower date estimates. * src/ChooseParents: Correctly use upper and lower date estimates. svn: r3565 --- gramps2/ChangeLog | 4 ++++ gramps2/src/AddSpouse.py | 6 +++--- gramps2/src/ChooseParents.py | 10 +++++----- gramps2/src/Date.py | 13 +++++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index e06a89931..b2c086e00 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -19,6 +19,10 @@ * src/DateEdit.py: Use new Date's set() method. Enable help. + * src/Date.py (get_high_year): Add method to return upper estimate. + * src/AddSpouse.py: Correctly use upper and lower date estimates. + * src/ChooseParents: Correctly use upper and lower date estimates. + 2004-09-19 Alex Roitman * src/Date.py (is_equal): Add method -- needed to compare dates for being identical, since __cmp__ only compares the sorting value diff --git a/gramps2/src/AddSpouse.py b/gramps2/src/AddSpouse.py index 8e782c74a..3b58d7e09 100644 --- a/gramps2/src/AddSpouse.py +++ b/gramps2/src/AddSpouse.py @@ -312,19 +312,19 @@ class AddSpouse: if pdday.get_year_valid(): # reject if person birthdate is after the spouse deathdate - if self.bday.get_low_year() + 10 > pdday.get_high_year(): + if self.bday.get_year() + 10 > pdday.get_high_year(): return 0 # reject if person birthdate is more than 100 years # before the spouse deathdate - if self.bday.get_high_year() + 100 < pdday.get_low_year(): + if self.bday.get_high_year() + 100 < pdday.get_year(): return 0 if self.dday.get_year_valid(): if pbday.get_year_valid(): # reject if person deathdate was prior to # the spouse birthdate - if self.dday.get_high_year() < pbday.get_low_year() + 10: + if self.dday.get_high_year() < pbday.get_year() + 10: return 0 if pdday.get_year_valid(): diff --git a/gramps2/src/ChooseParents.py b/gramps2/src/ChooseParents.py index 5c35680b8..a07289d47 100644 --- a/gramps2/src/ChooseParents.py +++ b/gramps2/src/ChooseParents.py @@ -279,27 +279,27 @@ class ChooseParents: if self.bday and self.bday.get_year_valid(): if pbday and pbday.get_year_valid(): # reject if parents birthdate + 10 > child birthdate - if pbday.get_low_year()+10 > self.bday.get_high_year(): + if pbday.get_year()+10 > self.bday.get_high_year(): return 0 # reject if parents birthdate + 90 < child birthdate - if pbday.get_high_year()+90 < self.bday.get_low_year(): + if pbday.get_high_year()+90 < self.bday.get_year(): return 0 if pdday and pdday.get_year_valid(): # reject if parents birthdate + 10 > child deathdate - if self.dday and pbday.get_low_year()+10 > self.dday.get_high_year(): + if self.dday and pbday.get_year()+10 > self.dday.get_high_year(): return 0 if self.dday and self.dday.get_year_valid(): if pbday and pbday.get_year_valid(): # reject if parents deathday + 3 < childs birth date - if pdday and self.bday and pdday.get_high_year()+3 < self.bday.get_low_year(): + if pdday and self.bday and pdday.get_high_year()+3 < self.bday.get_year(): return 0 if pdday and pdday.get_year_valid(): # reject if parents deathday + 150 < childs death date - if pdday.get_high_year() + 150 < self.dday.get_low_year(): + if pdday.get_high_year() + 150 < self.dday.get_year(): return 0 return 1 diff --git a/gramps2/src/Date.py b/gramps2/src/Date.py index 03261e321..1668b2ff6 100644 --- a/gramps2/src/Date.py +++ b/gramps2/src/Date.py @@ -367,6 +367,19 @@ class Date: """ return self._get_high_item(_POS_RDAY) + def get_high_year(self): + """ + Returns the high year estimate. For compound dates with non-zero + stop year, the stop year is returned. Otherwise, the start year + is returned. + """ + if self.is_compound(): + ret = self.get_stop_year() + if ret: + return ret + else: + return self.get_year() + def get_text(self): """ Returns the text value associated with an invalid date.