7089: same bug was pasted into BirthdayReport!
Moved the utility function gregorian to gen.lib.date, and use it like in WebCal. svn: r23211
This commit is contained in:
parent
ae670af71e
commit
01a83099ae
@ -1863,3 +1863,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
|
||||
|
||||
|
@ -40,6 +40,7 @@ import datetime, time
|
||||
from gen.display.name import displayer as global_name_display
|
||||
from Errors import ReportError
|
||||
from gen.lib import NameType, EventType, Name, Date, Person, Surname
|
||||
from gen.lib.date import gregorian
|
||||
import Relationship
|
||||
from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle,
|
||||
FONT_SERIF, PARA_ALIGN_RIGHT,
|
||||
@ -232,6 +233,8 @@ class CalendarReport(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()
|
||||
@ -316,6 +319,8 @@ class CalendarReport(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()
|
||||
|
@ -69,6 +69,8 @@ from libhtml import Html
|
||||
from libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
|
||||
from gui.pluginmanager import GuiPluginManager
|
||||
|
||||
from gen.lib.date import gregorian
|
||||
|
||||
# import styled notes from
|
||||
# src/plugins/lib/libhtmlbackend.py
|
||||
from libhtmlbackend import HtmlBackend
|
||||
@ -1713,11 +1715,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() != gen.lib.Date.CAL_GREGORIAN:
|
||||
date = gen.lib.Date(date)
|
||||
date.convert_calendar(gen.lib.Date.CAL_GREGORIAN)
|
||||
return date
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user