further fixes for slash dates and updates to unit tests
svn: r10588
This commit is contained in:
parent
3373062274
commit
465e950888
@ -328,8 +328,8 @@ class DateParser:
|
|||||||
s = False
|
s = False
|
||||||
else:
|
else:
|
||||||
d = self._get_int(groups[1])
|
d = self._get_int(groups[1])
|
||||||
if groups[4] != None: # slash year digit
|
if groups[4] != None: # slash year "/80"
|
||||||
y = int(groups[3][:-1] + groups[4])
|
y = int(groups[3]) + 1 # fullyear + 1
|
||||||
s = True
|
s = True
|
||||||
else: # regular, non-slash date
|
else: # regular, non-slash date
|
||||||
y = int(groups[3])
|
y = int(groups[3])
|
||||||
@ -354,7 +354,7 @@ class DateParser:
|
|||||||
s = False
|
s = False
|
||||||
else:
|
else:
|
||||||
if groups[4] != None: # slash year digit
|
if groups[4] != None: # slash year digit
|
||||||
y = int(groups[3][:-1] + groups[4])
|
y = int(groups[3]) + 1 # fullyear + 1
|
||||||
s = True
|
s = True
|
||||||
else:
|
else:
|
||||||
y = int(groups[3])
|
y = int(groups[3])
|
||||||
@ -517,7 +517,7 @@ class DateParser:
|
|||||||
try:
|
try:
|
||||||
text = match.group(1) + match.group(3)
|
text = match.group(1) + match.group(3)
|
||||||
except:
|
except:
|
||||||
print "MATCH:", match.groups()
|
print "ERROR MATCH:", match.groups()
|
||||||
bc = True
|
bc = True
|
||||||
return (text, bc)
|
return (text, bc)
|
||||||
|
|
||||||
|
@ -87,7 +87,9 @@ class Span:
|
|||||||
|
|
||||||
def __int__(self):
|
def __int__(self):
|
||||||
return int(self.diff_tuple[0] * 12 + self.diff_tuple[1]) # months
|
return int(self.diff_tuple[0] * 12 + self.diff_tuple[1]) # months
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return self.diff_tuple == other.diff_tuple
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -511,14 +513,14 @@ class Date:
|
|||||||
comparison >> :
|
comparison >> :
|
||||||
Returns True if all parts of other_date > all parts of self
|
Returns True if all parts of other_date > all parts of self
|
||||||
"""
|
"""
|
||||||
if (self.sortval == 0 or other_date.sortval == 0):
|
if (other_date.modifier == Date.MOD_TEXTONLY or
|
||||||
return False
|
|
||||||
elif (other_date.modifier == Date.MOD_TEXTONLY or
|
|
||||||
self.modifier == Date.MOD_TEXTONLY):
|
self.modifier == Date.MOD_TEXTONLY):
|
||||||
if comparison in ["=", "=="]:
|
if comparison in ["=", "=="]:
|
||||||
return (self.text.upper().find(other_date.text.upper()) != -1)
|
return (self.text.upper().find(other_date.text.upper()) != -1)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
if (self.sortval == 0 or other_date.sortval == 0):
|
||||||
|
return False
|
||||||
|
|
||||||
# Obtain minimal start and maximal stop in Gregorian calendar
|
# Obtain minimal start and maximal stop in Gregorian calendar
|
||||||
other_start, other_stop = other_date.get_start_stop_range()
|
other_start, other_stop = other_date.get_start_stop_range()
|
||||||
|
@ -49,7 +49,7 @@ import Config
|
|||||||
import DateHandler
|
import DateHandler
|
||||||
from DateHandler import parser as _dp
|
from DateHandler import parser as _dp
|
||||||
from DateHandler import displayer as _dd
|
from DateHandler import displayer as _dd
|
||||||
from gen.lib import Date
|
from gen.lib.date import Date, Span
|
||||||
|
|
||||||
gettext.textdomain("gramps")
|
gettext.textdomain("gramps")
|
||||||
gettext.install("gramps",loc,unicode=1)
|
gettext.install("gramps",loc,unicode=1)
|
||||||
@ -228,12 +228,6 @@ class Tester(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
if expected2 == None:
|
if expected2 == None:
|
||||||
expected2 = expected1
|
expected2 = expected1
|
||||||
pos1 = 1
|
|
||||||
if expected1 :
|
|
||||||
pos1 = 0
|
|
||||||
pos2 = 1
|
|
||||||
if expected2 :
|
|
||||||
pos2 = 0
|
|
||||||
date1 = _dp.parse(d1)
|
date1 = _dp.parse(d1)
|
||||||
date2 = _dp.parse(d2)
|
date2 = _dp.parse(d2)
|
||||||
if part == 1:
|
if part == 1:
|
||||||
@ -358,12 +352,12 @@ def suite2():
|
|||||||
("Date(2000, 1, 1) - 1", "Date(1999, 1, 1)"),
|
("Date(2000, 1, 1) - 1", "Date(1999, 1, 1)"),
|
||||||
("Date(2000) - 1", "Date(1999)"),
|
("Date(2000) - 1", "Date(1999)"),
|
||||||
("Date(2000) + 1", "Date(2001)"),
|
("Date(2000) + 1", "Date(2001)"),
|
||||||
# Date +/- Date -> tuple
|
# Date +/- Date -> Span
|
||||||
("Date(1876,5,7) - Date(1876,5,1)", "(0, 0, 6)"),
|
("Date(1876,5,7) - Date(1876,5,1)", "Span(0, 0, 6)"),
|
||||||
("Date(1876,5,7) - Date(1876,4,30)", "(0, 0, 7)"),
|
("Date(1876,5,7) - Date(1876,4,30)", "Span(0, 0, 7)"),
|
||||||
("Date(2000,1,1) - Date(1999,2,1)", "(0, 11, 0)"),
|
("Date(2000,1,1) - Date(1999,2,1)", "Span(0, 11, 0)"),
|
||||||
("Date(2000,1,1) - Date(1999,12,1)", "(0, 1, 0)"),
|
("Date(2000,1,1) - Date(1999,12,1)", "Span(0, 1, 0)"),
|
||||||
("Date(2007, 12, 23) - Date(1963, 12, 4)", "(44, 0, 19)"),
|
("Date(2007, 12, 23) - Date(1963, 12, 4)", "Span(44, 0, 19)"),
|
||||||
]
|
]
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
count = 1
|
count = 1
|
||||||
|
Loading…
Reference in New Issue
Block a user