From d76757ddb4b6c4cfe00b29ec7df036aab401ca58 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Mon, 17 Aug 2015 19:21:27 +0100 Subject: [PATCH] 8775: Avoid using person-centric date matching for places --- gramps/gen/lib/date.py | 19 +++++++++++++++++++ gramps/gen/utils/location.py | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gramps/gen/lib/date.py b/gramps/gen/lib/date.py index 0b026d185..4939571e9 100644 --- a/gramps/gen/lib/date.py +++ b/gramps/gen/lib/date.py @@ -941,6 +941,25 @@ class Date(object): # return tuples not lists, for comparisons return (tuple(startmin), tuple(stopmax)) + def match_exact(self, other_date): + """ + Perform an extact match between two dates. The dates are not treated + as being person-centric. This is used to match date ranges in places. + """ + if other_date.modifier == Date.MOD_NONE: + return other_date.sortval == self.sortval + elif other_date.modifier == Date.MOD_BEFORE: + return other_date.sortval > self.sortval + elif other_date.modifier == Date.MOD_AFTER: + return other_date.sortval < self.sortval + elif other_date.is_compound(): + start, stop = other_date.get_start_stop_range() + start = Date(*start) + stop = Date(*stop) + return start.sortval <= self.sortval <= stop.sortval + else: + return False + def match(self, other_date, comparison="="): """ Compare two dates using sophisticated techniques looking for any match diff --git a/gramps/gen/utils/location.py b/gramps/gen/utils/location.py index ab7b803f9..181406274 100644 --- a/gramps/gen/utils/location.py +++ b/gramps/gen/utils/location.py @@ -40,7 +40,7 @@ def get_location_list(db, place, date=None, lang=''): handle = None for placeref in place.get_placeref_list(): ref_date = placeref.get_date_object() - if ref_date.is_empty() or date.match(ref_date): + if ref_date.is_empty() or date.match_exact(ref_date): handle = placeref.ref break if handle is None or handle in visited: @@ -56,7 +56,7 @@ def __get_name(place, date, lang): local_name = '?' for place_name in place.get_all_names(): name_date = place_name.get_date_object() - if name_date.is_empty() or date.match(name_date): + if name_date.is_empty() or date.match_exact(name_date): name_lang = place_name.get_language() if name_lang == '': local_name = place_name.get_value()