diff --git a/gramps/gen/utils/location.py b/gramps/gen/utils/location.py index d5d016e66..cd4feaa4b 100644 --- a/gramps/gen/utils/location.py +++ b/gramps/gen/utils/location.py @@ -21,7 +21,7 @@ """ Location utility functions """ -from ..lib.date import Today +from ..lib.date import Date, Today #------------------------------------------------------------------------- # @@ -33,7 +33,7 @@ def get_location_list(db, place, date=None, lang=''): Return a list of place names for display. """ if date is None: - date = Today() + date = __get_latest_date(place) visited = [place.handle] lines = [(__get_name(place, date, lang), place.get_type())] while True: @@ -63,6 +63,22 @@ def __get_name(place, date, lang): endonym = place_name.get_value() return endonym if endonym is not None else '?' +def __get_latest_date(place): + latest_date = None + for place_name in place.get_all_names(): + date = place_name.get_date_object() + if date.is_empty() or date.modifier == Date.MOD_AFTER: + return Today() + else: + if date.is_compound(): + date1, date2 = date.get_start_stop_range() + date = Date(*date2) + if date.modifier == Date.MOD_BEFORE: + date = date - 1 + if latest_date is None or date > latest_date: + latest_date = date + return latest_date + #------------------------------------------------------------------------- # # get_main_location