7089: same bug in 3 more reports

Port r23211-r23213 from gramps34.

svn: r23214
This commit is contained in:
Vassilii Khachaturov 2013-09-27 23:57:49 +00:00
parent 08dc8ffc53
commit 659f1bec17
5 changed files with 27 additions and 10 deletions

View File

@ -1869,3 +1869,10 @@ def lookup_calendar(calendar):
return pos return pos
raise AttributeError("invalid calendar: '%s'" % calendar) 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

View File

@ -54,6 +54,7 @@ from gramps.gen.plug.report import stdoptions
from gramps.gen.utils.alive import probably_alive from gramps.gen.utils.alive import probably_alive
from gramps.gen.datehandler import displayer as _dd, long_days 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 import Date, EventRoleType, EventType, Name, NameType, Person, Surname
from gramps.gen.lib.date import gregorian
import gramps.plugins.lib.libholiday as libholiday import gramps.plugins.lib.libholiday as libholiday
from gramps.plugins.lib.libholiday import g2iso from gramps.plugins.lib.libholiday import g2iso
@ -285,6 +286,8 @@ class Calendar(Report):
birth_date = birth_event.get_date_object() birth_date = birth_event.get_date_object()
if (self.birthdays and birth_date is not None and birth_date.is_valid()): if (self.birthdays and birth_date is not None and birth_date.is_valid()):
birth_date = gregorian(birth_date)
year = birth_date.get_year() year = birth_date.get_year()
month = birth_date.get_month() month = birth_date.get_month()
day = birth_date.get_day() day = birth_date.get_day()
@ -366,6 +369,8 @@ class Calendar(Report):
event_obj = event.get_date_object() event_obj = event.get_date_object()
if event_obj.is_valid(): if event_obj.is_valid():
event_obj = gregorian(event_obj)
year = event_obj.get_year() year = event_obj.get_year()
month = event_obj.get_month() month = event_obj.get_month()
day = event_obj.get_day() day = event_obj.get_day()

View File

@ -46,7 +46,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
# Person and relation types # Person and relation types
from gramps.gen.lib import Person, FamilyRelType, EventType, EventRoleType 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 # gender and report type names
from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle,
FONT_SANS_SERIF, FONT_SERIF, FONT_SANS_SERIF, FONT_SERIF,
@ -669,6 +669,8 @@ class Extract(object):
if birth: if birth:
birthdate = birth.get_date_object() birthdate = birth.get_date_object()
if birthdate.get_year_valid(): if birthdate.get_year_valid():
birthdate = gregorian(birthdate)
year = birthdate.get_year() year = birthdate.get_year()
if not (year >= year_from and year <= year_to): if not (year >= year_from and year <= year_to):
continue continue
@ -677,7 +679,10 @@ class Extract(object):
death = self.get_death(person) death = self.get_death(person)
if death: if death:
deathdate = death.get_date_object() deathdate = death.get_date_object()
if deathdate.get_year_valid() and deathdate.get_year() < year_from: if deathdate.get_year_valid():
deathdate = gregorian(deathdate)
if deathdate.get_year() < year_from:
continue continue
if not no_years: if not no_years:
# do not accept people who are not known to be in range # do not accept people who are not known to be in range

View File

@ -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.display.name import displayer as global_name_display
from gramps.gen.errors import ReportError from gramps.gen.errors import ReportError
from gramps.gen.lib import NameType, EventType, Name, Date, Person, Surname 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.relationship import get_relationship_calculator
from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle,
FONT_SERIF, PARA_ALIGN_RIGHT, FONT_SERIF, PARA_ALIGN_RIGHT,
@ -277,6 +278,8 @@ class BirthdayReport(Report):
birth_date = birth_event.get_date_object() birth_date = birth_event.get_date_object()
if (self.birthdays and birth_date is not None and birth_date.is_valid()): if (self.birthdays and birth_date is not None and birth_date.is_valid()):
birth_date = gregorian(birth_date)
year = birth_date.get_year() year = birth_date.get_year()
month = birth_date.get_month() month = birth_date.get_month()
day = birth_date.get_day() day = birth_date.get_day()
@ -364,6 +367,8 @@ class BirthdayReport(Report):
for event_ref in fam.get_event_ref_list(): for event_ref in fam.get_event_ref_list():
event = self.database.get_event_from_handle(event_ref.ref) event = self.database.get_event_from_handle(event_ref.ref)
event_obj = event.get_date_object() 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() year = event_obj.get_year()
month = event_obj.get_month() month = event_obj.get_month()
day = event_obj.get_day() day = event_obj.get_day()

View File

@ -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.plugins.lib.libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
from gramps.gui.pluginmanager import GuiPluginManager from gramps.gui.pluginmanager import GuiPluginManager
from gramps.gen.lib.date import gregorian
# import styled notes from # import styled notes from
# src/plugins/lib/libhtmlbackend.py # src/plugins/lib/libhtmlbackend.py
from gramps.plugins.lib.libhtmlbackend import HtmlBackend 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 to its caller calendar_build()
return day_list 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