Fixed merge problem with date ranges

svn: r42
This commit is contained in:
Don Allingham 2001-05-19 18:41:47 +00:00
parent f9a4096ee6
commit 22841c3f41
2 changed files with 43 additions and 0 deletions

View File

@ -138,6 +138,12 @@ class Date:
return 0 return 0
else: else:
return 1 return 1
def isRange(self):
if self.range == -1:
return 0
else:
return 1
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# #

View File

@ -710,6 +710,12 @@ class Merge:
if date1.getDate() == date2.getDate(): if date1.getDate() == date2.getDate():
return 1 return 1
if date1.isRange() or date2.isRange():
return self.range_compare(date1,date2)
date1 = date1.get_start_date()
date2 = date2.get_start_date()
if date1.getYear() == date2.getYear(): if date1.getYear() == date2.getYear():
if date1.getMonth() == date2.getMonth(): if date1.getMonth() == date2.getMonth():
return 0.75 return 0.75
@ -720,6 +726,37 @@ class Merge:
else: else:
return -1 return -1
#-----------------------------------------------------------------
#
#
#
#-----------------------------------------------------------------
def range_compare(self,date1,date2):
if date1.isRange() and date2.isRange():
if date1.get_start_date() >= date2.get_start_date() and \
date1.get_start_date() <= date2.get_stop_date() or \
date2.get_start_date() >= date1.get_start_date() and \
date2.get_start_date() <= date1.get_stop_date() or \
date1.get_stop_date() >= date2.get_start_date() and \
date1.get_stop_date() <= date2.get_stop_date() or \
date2.get_stop_date() >= date1.get_start_date() and \
date2.get_stop_date() <= date1.get_stop_date():
return 0.5
else:
return -1
elif date2.isRange():
if date1.get_start_date() >= date2.get_start_date() and \
date1.get_start_date() <= date2.get_stop_date():
return 0.5
else:
return -1
else:
if date2.get_start_date() >= date1.get_start_date() and \
date2.get_start_date() <= date1.get_stop_date():
return 0.5
else:
return -1
#----------------------------------------------------------------- #-----------------------------------------------------------------
# #
# #