From 22841c3f410176a4a4cc902538c8c0cb8731ff50 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 19 May 2001 18:41:47 +0000 Subject: [PATCH] Fixed merge problem with date ranges svn: r42 --- gramps/src/Date.py | 6 ++++++ gramps/src/plugins/Merge.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/gramps/src/Date.py b/gramps/src/Date.py index 26c370952..7883a1775 100644 --- a/gramps/src/Date.py +++ b/gramps/src/Date.py @@ -138,6 +138,12 @@ class Date: return 0 else: return 1 + + def isRange(self): + if self.range == -1: + return 0 + else: + return 1 #-------------------------------------------------------------------- # diff --git a/gramps/src/plugins/Merge.py b/gramps/src/plugins/Merge.py index febb0f5ea..8bf9fc4a4 100644 --- a/gramps/src/plugins/Merge.py +++ b/gramps/src/plugins/Merge.py @@ -710,6 +710,12 @@ class Merge: if date1.getDate() == date2.getDate(): 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.getMonth() == date2.getMonth(): return 0.75 @@ -720,6 +726,37 @@ class Merge: else: 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 + #----------------------------------------------------------------- # #