From 659f1bec1787bb0ae32b84a96d9b67b882413237 Mon Sep 17 00:00:00 2001 From: Vassilii Khachaturov Date: Fri, 27 Sep 2013 23:57:49 +0000 Subject: [PATCH] 7089: same bug in 3 more reports Port r23211-r23213 from gramps34. svn: r23214 --- gramps/gen/lib/date.py | 7 +++++++ gramps/plugins/drawreport/calendarreport.py | 5 +++++ gramps/plugins/drawreport/statisticschart.py | 11 ++++++++--- gramps/plugins/textreport/birthdayreport.py | 5 +++++ gramps/plugins/webreport/webcal.py | 9 ++------- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/gramps/gen/lib/date.py b/gramps/gen/lib/date.py index 1db1d62de..e61caba1d 100644 --- a/gramps/gen/lib/date.py +++ b/gramps/gen/lib/date.py @@ -1869,3 +1869,10 @@ def lookup_calendar(calendar): return pos raise AttributeError("invalid calendar: '%s'" % calendar) +def gregorian(date): + """Convert given date to gregorian. Doesn't modify the original object.""" + if date.get_calendar() != Date.CAL_GREGORIAN: + date = Date(date) + date.convert_calendar(Date.CAL_GREGORIAN) + return date + diff --git a/gramps/plugins/drawreport/calendarreport.py b/gramps/plugins/drawreport/calendarreport.py index 53ddabd9c..fe774e867 100644 --- a/gramps/plugins/drawreport/calendarreport.py +++ b/gramps/plugins/drawreport/calendarreport.py @@ -54,6 +54,7 @@ from gramps.gen.plug.report import stdoptions from gramps.gen.utils.alive import probably_alive from gramps.gen.datehandler import displayer as _dd, long_days from gramps.gen.lib import Date, EventRoleType, EventType, Name, NameType, Person, Surname +from gramps.gen.lib.date import gregorian import gramps.plugins.lib.libholiday as libholiday from gramps.plugins.lib.libholiday import g2iso @@ -285,6 +286,8 @@ class Calendar(Report): birth_date = birth_event.get_date_object() if (self.birthdays and birth_date is not None and birth_date.is_valid()): + birth_date = gregorian(birth_date) + year = birth_date.get_year() month = birth_date.get_month() day = birth_date.get_day() @@ -366,6 +369,8 @@ class Calendar(Report): event_obj = event.get_date_object() if event_obj.is_valid(): + event_obj = gregorian(event_obj) + year = event_obj.get_year() month = event_obj.get_month() day = event_obj.get_day() diff --git a/gramps/plugins/drawreport/statisticschart.py b/gramps/plugins/drawreport/statisticschart.py index 1625a50e5..6c5ddf8b0 100644 --- a/gramps/plugins/drawreport/statisticschart.py +++ b/gramps/plugins/drawreport/statisticschart.py @@ -46,7 +46,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.sgettext # Person and relation types from gramps.gen.lib import Person, FamilyRelType, EventType, EventRoleType -from gramps.gen.lib.date import Date +from gramps.gen.lib.date import Date, gregorian # gender and report type names from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, FONT_SANS_SERIF, FONT_SERIF, @@ -669,6 +669,8 @@ class Extract(object): if birth: birthdate = birth.get_date_object() if birthdate.get_year_valid(): + birthdate = gregorian(birthdate) + year = birthdate.get_year() if not (year >= year_from and year <= year_to): continue @@ -677,8 +679,11 @@ class Extract(object): death = self.get_death(person) if death: deathdate = death.get_date_object() - if deathdate.get_year_valid() and deathdate.get_year() < year_from: - continue + if deathdate.get_year_valid(): + deathdate = gregorian(deathdate) + + if deathdate.get_year() < year_from: + continue if not no_years: # do not accept people who are not known to be in range continue diff --git a/gramps/plugins/textreport/birthdayreport.py b/gramps/plugins/textreport/birthdayreport.py index 365e28f15..32451a573 100644 --- a/gramps/plugins/textreport/birthdayreport.py +++ b/gramps/plugins/textreport/birthdayreport.py @@ -42,6 +42,7 @@ from gramps.gen.const import URL_HOMEPAGE from gramps.gen.display.name import displayer as global_name_display from gramps.gen.errors import ReportError from gramps.gen.lib import NameType, EventType, Name, Date, Person, Surname +from gramps.gen.lib.date import gregorian from gramps.gen.relationship import get_relationship_calculator from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, FONT_SERIF, PARA_ALIGN_RIGHT, @@ -277,6 +278,8 @@ class BirthdayReport(Report): birth_date = birth_event.get_date_object() if (self.birthdays and birth_date is not None and birth_date.is_valid()): + birth_date = gregorian(birth_date) + year = birth_date.get_year() month = birth_date.get_month() day = birth_date.get_day() @@ -364,6 +367,8 @@ class BirthdayReport(Report): for event_ref in fam.get_event_ref_list(): event = self.database.get_event_from_handle(event_ref.ref) event_obj = event.get_date_object() + if event_obj is not Date.EMPTY and event_obj.is_valid(): + event_obj = gregorian(event_obj) year = event_obj.get_year() month = event_obj.get_month() day = event_obj.get_day() diff --git a/gramps/plugins/webreport/webcal.py b/gramps/plugins/webreport/webcal.py index ecf2773fe..6c43db40b 100644 --- a/gramps/plugins/webreport/webcal.py +++ b/gramps/plugins/webreport/webcal.py @@ -71,6 +71,8 @@ from gramps.plugins.lib.libhtml import Html, xml_lang from gramps.plugins.lib.libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS from gramps.gui.pluginmanager import GuiPluginManager +from gramps.gen.lib.date import gregorian + # import styled notes from # src/plugins/lib/libhtmlbackend.py from gramps.plugins.lib.libhtmlbackend import HtmlBackend @@ -1727,10 +1729,3 @@ def get_day_list(event_date, holiday_list, bday_anniv_list): # return to its caller calendar_build() return day_list - -def gregorian(date): - """Convert given date to gregorian. Doesn't modify the original object.""" - if date.get_calendar() != Date.CAL_GREGORIAN: - date = Date(date) - date.convert_calendar(Date.CAL_GREGORIAN) - return date