Reverted to use regular dates (no partial or inexact), but with a setting to change to include any valid date

svn: r11531
This commit is contained in:
Doug Blank 2008-12-27 23:56:02 +00:00
parent 423633796c
commit c96bf68ee2

View File

@ -55,6 +55,13 @@ MODE_CLI = PluginManager.REPORT_MODE_CLI
# Global functions # Global functions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
def good_date(date):
if RecordsReportOptions.REGULAR_DATES_ONLY:
return date.is_regular()
else:
return date.is_valid()
def _find_records(db, filter, callname): def _find_records(db, filter, callname):
today = datetime.date.today() today = datetime.date.today()
@ -98,7 +105,7 @@ def _find_records(db, filter, callname):
else: else:
death_date = None death_date = None
if not birth_date.is_valid(): if not good_date(birth_date):
# Birth date unknown or incomplete, so we can't calculate any age. # Birth date unknown or incomplete, so we can't calculate any age.
continue continue
@ -108,7 +115,7 @@ def _find_records(db, filter, callname):
# Still living, look for age records # Still living, look for age records
_record(person_youngestliving, person_oldestliving, _record(person_youngestliving, person_oldestliving,
today_date - birth_date, name, 'Person', person_handle) today_date - birth_date, name, 'Person', person_handle)
elif death_date.is_valid(): elif good_date(death_date):
# Already died, look for age records # Already died, look for age records
_record(person_youngestdied, person_oldestdied, _record(person_youngestdied, person_oldestdied,
death_date - birth_date, name, 'Person', person_handle) death_date - birth_date, name, 'Person', person_handle)
@ -125,12 +132,12 @@ def _find_records(db, filter, callname):
elif event.get_type() == EventType.DIVORCE: elif event.get_type() == EventType.DIVORCE:
divorce_date = event.get_date_object() divorce_date = event.get_date_object()
if marriage_date is not None and marriage_date.is_valid(): if marriage_date is not None and good_date(marriage_date):
_record(person_youngestmarried, person_oldestmarried, _record(person_youngestmarried, person_oldestmarried,
marriage_date - birth_date, marriage_date - birth_date,
name, 'Person', person_handle) name, 'Person', person_handle)
if divorce_date is not None and divorce_date.is_valid(): if divorce_date is not None and good_date(divorce_date):
_record(person_youngestdivorced, person_oldestdivorced, _record(person_youngestdivorced, person_oldestdivorced,
divorce_date - birth_date, divorce_date - birth_date,
name, 'Person', person_handle) name, 'Person', person_handle)
@ -145,7 +152,7 @@ def _find_records(db, filter, callname):
child_birth = db.get_event_from_handle(child_birth_ref.ref) child_birth = db.get_event_from_handle(child_birth_ref.ref)
child_birth_date = child_birth.get_date_object() child_birth_date = child_birth.get_date_object()
if not child_birth_date.is_valid(): if not good_date(child_birth_date):
continue continue
if person.get_gender() == person.MALE: if person.get_gender() == person.MALE:
@ -218,19 +225,19 @@ def _find_records(db, filter, callname):
mother_death = db.get_event_from_handle(mother_death_ref.ref) mother_death = db.get_event_from_handle(mother_death_ref.ref)
mother_death_date = mother_death.get_date_object() mother_death_date = mother_death.get_date_object()
if not marriage or not marriage_date.is_valid(): if not marriage or not good_date(marriage_date):
# Not married or marriage date unknown # Not married or marriage date unknown
continue continue
if divorce and not divorce_date.is_valid(): if divorce and not good_date(divorce_date):
# Divorced, but divorce date unknown # Divorced, but divorce date unknown
continue continue
if father_death and (not father_death_date or not father_death_date.is_valid()): if father_death and (not father_death_date or not good_date(father_death_date)):
# Father dead, but death date unknown # Father dead, but death date unknown
continue continue
if mother_death and (not mother_death_date or not mother_death_date.is_valid()): if mother_death and (not mother_death_date or not good_date(mother_death_date)):
# Mother dead, but death date unknown # Mother dead, but death date unknown
continue continue
@ -435,6 +442,7 @@ class RecordsReportOptions(MenuReportOptions):
CALLNAME_DONTUSE = 0 CALLNAME_DONTUSE = 0
CALLNAME_REPLACE = 1 CALLNAME_REPLACE = 1
CALLNAME_UNDERLINE_ADD = 2 CALLNAME_UNDERLINE_ADD = 2
REGULAR_DATES_ONLY = True
def __init__(self, name, dbase): def __init__(self, name, dbase):