diff --git a/src/plugins/drawreport/Calendar.py b/src/plugins/drawreport/Calendar.py index c06038178..2fe332a9b 100644 --- a/src/plugins/drawreport/Calendar.py +++ b/src/plugins/drawreport/Calendar.py @@ -42,7 +42,8 @@ import gen.lib from Utils import probably_alive, ProgressMeter from FontScale import string_trim -import libholiday +import libholiday +from libholiday import _make_date #------------------------------------------------------------------------ # @@ -58,14 +59,6 @@ def g2iso(dow): # ISO: MON = 1 return (dow + 5) % 7 + 1 -def make_date(year, month, day): - """ - Return a Date object of the particular year/month/day. - """ - retval = gen.lib.Date() - retval.set_yr_mon_day(year, month, day) - return retval - #------------------------------------------------------------------------ # # Calendar @@ -292,7 +285,7 @@ class Calendar(Report): father_lastname = father.get_primary_name().get_surname() short_name = self.get_name(person, father_lastname) if age >= 0: - alive = probably_alive(person, self.database, make_date(self.year, month, day)) + alive = probably_alive(person, self.database, _make_date(self.year, month, day)) if ((self.alive and alive) or not self.alive): self.add_day_item("%s, %d%s" % (short_name, age, ""), month, day) if self.anniversaries: @@ -337,8 +330,8 @@ class Calendar(Report): 'person' : short_name, 'nyears' : years, } - alive1 = probably_alive(person, self.database, make_date(self.year, month, day)) - alive2 = probably_alive(spouse, self.database, make_date(self.year, month, day)) + alive1 = probably_alive(person, self.database, _make_date(self.year, month, day)) + alive2 = probably_alive(spouse, self.database, _make_date(self.year, month, day)) if ((self.alive and alive1 and alive2) or not self.alive): self.add_day_item(text, month, day) diff --git a/src/plugins/lib/libholiday.py b/src/plugins/lib/libholiday.py index 434c8eeba..66a5cd277 100644 --- a/src/plugins/lib/libholiday.py +++ b/src/plugins/lib/libholiday.py @@ -35,13 +35,22 @@ import os # GRAMPS modules # #------------------------------------------------------------------------ -from gen.plug import PluginManager, Plugin +from gen.plug import PluginManager, Plugin +import gen.lib #------------------------------------------------------------------------ # # Support functions # #------------------------------------------------------------------------ +def _make_date(year, month, day): + """ + Return a Date object of the particular year/month/day. + """ + retval = gen.lib.Date() + retval.set_yr_mon_day(year, month, day) + return retval + def easter(year): """ Computes the year/month/day of easter. Based on work by diff --git a/src/plugins/textreport/BirthdayReport.py b/src/plugins/textreport/BirthdayReport.py index 0c0325ad1..2a6514e56 100644 --- a/src/plugins/textreport/BirthdayReport.py +++ b/src/plugins/textreport/BirthdayReport.py @@ -41,20 +41,8 @@ import GrampsLocale import gen.lib from Utils import probably_alive, ProgressMeter -import libholiday - -#------------------------------------------------------------------------ -# -# Support functions -# -#------------------------------------------------------------------------ -def make_date(year, month, day): - """ - Return a Date object of the particular year/month/day. - """ - retval = gen.lib.Date() - retval.set_yr_mon_day(year, month, day) - return retval +import libholiday +from libholiday import _make_date #------------------------------------------------------------------------ # @@ -239,7 +227,7 @@ class CalendarReport(Report): father_lastname = father.get_primary_name().get_surname() short_name = self.get_name(person, father_lastname) if age >= 0: - alive = probably_alive(person, self.database, make_date(self.year, month, day)) + alive = probably_alive(person, self.database, _make_date(self.year, month, day)) if ((self.alive and alive) or not self.alive): comment = "" if self.relationships: @@ -292,8 +280,8 @@ class CalendarReport(Report): 'person' : short_name, 'nyears' : years, } - alive1 = probably_alive(person, self.database, make_date(self.year, month, day)) - alive2 = probably_alive(spouse, self.database, make_date(self.year, month, day)) + alive1 = probably_alive(person, self.database, _make_date(self.year, month, day)) + alive2 = probably_alive(spouse, self.database, _make_date(self.year, month, day)) if ((self.alive and alive1 and alive2) or not self.alive): self.add_day_item(text, month, day) diff --git a/src/plugins/webreport/WebCal.py b/src/plugins/webreport/WebCal.py index d3145fd5a..65e7f984d 100644 --- a/src/plugins/webreport/WebCal.py +++ b/src/plugins/webreport/WebCal.py @@ -78,6 +78,7 @@ from DateHandler import displayer as _dd from DateHandler import parser as _dp import libholiday +from libholiday import _make_date #------------------------------------------------------------------------ # @@ -168,14 +169,6 @@ _COPY_OPTIONS = [ _('No copyright notice'), ] -def _make_date(year, month, day): - """ - Return a Date object of the particular year/month/day. - """ - retval = gen.lib.Date() - retval.set_yr_mon_day(year, month, day) - return retval - # Compute the first day to display for this month. # It can also be a day in the previous month. def get_first_day(year, month): @@ -463,14 +456,13 @@ class WebCalReport(Report): # each year will link to January, unless self.partyear is True, # then it will link to current month. # this will always need an extension added - lng_month = _get_long_month_name(1) - if self.partyear: - if cal_year == self.today.year: - lng_month = _get_long_month_name(self.today.month) + full_month_name = _get_long_month_name(1) + if self.partyear and cal_year == self.today.year: + full_month_name = _get_long_month_name(self.today.month) # Note. We use '/' here because it is a URL, not a OS dependent # pathname. - url = '/'.join(subdirs + [lng_month]) + self.ext + url = '/'.join(subdirs + [full_month_name]) + self.ext # determine if we need to highlight??? if str(cal_year) == currentsection: @@ -534,8 +526,8 @@ class WebCalReport(Report): """ # define names for long and short month names - lng_month = _get_long_month_name(month) - shrt_month = _get_short_month_name(month) + full_month_name = _get_long_month_name(month) + abbr_month_name = _get_short_month_name(month) # dow (day-of-week) uses Gramps numbering, sunday => 1, etc start_dow = self.start_dow @@ -560,7 +552,7 @@ class WebCalReport(Report): # Begin calendar head. We'll use the capitalized name, because here it # seems appropriate for most countries. - month_name = lng_month.capitalize() + month_name = full_month_name.capitalize() th_txt = month_name if cal == 'wc': # normal_cal() if not self.multiyear: @@ -611,7 +603,7 @@ class WebCalReport(Report): else: # normal day number in current month thisday = datetime.date.fromordinal(current_ord) - of.write('\t\t\t