* src/DateParser.py: try to detect illegal numerical dates

* src/Utils.py: not_too_old moved over from RelLib.py
* src/WriteGedcom.py: fix call to probably_alive


svn: r3618
This commit is contained in:
Don Allingham 2004-10-10 23:22:12 +00:00
parent e6783320cb
commit 6078827986
5 changed files with 37 additions and 9 deletions

View File

@ -1,4 +1,5 @@
2004-10-10 Don Allingham <dallingham@users.sourceforge.net>
* src/DateParser.py: try to detect illegal numerical dates
* src/GrampsInMemDB.py: handle null handle
* src/GrampsXMLDB.py: disable undo during normal read of database
* src/ReadGedcom.py: handle lines shorter than 50 lines, disable undo during
@ -6,6 +7,8 @@
* src/ReadXML.py: disable undo during normal read of databas
* src/RelLib.py: revert Name.__cmp__ to Name.is_equal
* src/docgen/HTMLDoc.py: drop deprecated gnome.ui dialogs
* src/Utils.py: not_too_old moved over from RelLib.py
* src/WriteGedcom.py: fix call to probably_alive
2004-10-10 Eero Tamminen <eerot@sf>
* TestPlan.txt: Add test for reports like in stable version

View File

@ -337,7 +337,10 @@ class DateParser:
y = self._get_int(groups[0])
m = self._get_int(groups[1])
d = self._get_int(groups[2])
return (d,m,y,False)
if gregorian_valid((d,m)):
return (d,m,y,False)
else:
return Date.EMPTY
match = self._rfc.match(text)
if match:
@ -345,7 +348,10 @@ class DateParser:
d = self._get_int(groups[2])
m = self._rfc_mons_to_int[groups[3]]
y = self._get_int(groups[4])
return (d,m,y,False)
if gregorian_valid((d,m)):
return (d,m,y,False)
else:
return Date.EMPTY
match = self._numeric.match(text)
if match:
@ -353,7 +359,10 @@ class DateParser:
m = self._get_int(groups[1])
d = self._get_int(groups[3])
y = self._get_int(groups[4])
return (d,m,y,False)
if gregorian_valid((d,m)):
return (d,m,y,False)
else:
return Date.EMPTY
return Date.EMPTY
@ -451,3 +460,15 @@ class DateParser:
new_date = Date.Date()
self.set_date(new_date,text)
return new_date
_max_days = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
def gregorian_valid(date_tuple):
day = date_tuple[0]
month = date_tuple[1]
valid = True
if month > 12:
valid = False
elif day > _max_days[month]:
valid = False
return valid

View File

@ -2243,8 +2243,3 @@ class GenderStats:
return Person.unknown
def not_too_old(date):
time_struct = time.localtime(time.time())
current_year = time_struct[0]
year = date.get_year()
return not( year != 0 and current_year - year > 110)

View File

@ -45,6 +45,7 @@ import gnome
import const
import RelImage
import GrampsMime
import Date
#-------------------------------------------------------------------------
#
@ -664,6 +665,12 @@ def probably_alive(person,db):
return False
return True
def not_too_old(date):
time_struct = time.localtime(time.time())
current_year = time_struct[0]
year = date.get_year()
return not( year != 0 and current_year - year > 110)
#-------------------------------------------------------------------------
#
#

View File

@ -51,6 +51,8 @@ import Date
import GedcomInfo
import Errors
import ansel_utf8
import Utils
import Date
from gettext import gettext as _
from QuestionDialog import ErrorDialog
@ -750,7 +752,7 @@ class GedcomWriter:
def write_person(self,person):
self.writeln("0 @%s@ INDI" % person.get_gramps_id())
restricted = self.restrict and probably_alive (person,self.db)
restricted = self.restrict and Utils.probably_alive (person,self.db)
self.prefn(person)
primaryname = person.get_primary_name ()
if restricted and self.living: