Newyear import/export changes and fix
svn: r15027
This commit is contained in:
parent
e740d374a9
commit
c551d6beb1
@ -340,7 +340,7 @@ class DateEditorDialog(ManagedWindow.ManagedWindow):
|
||||
self.start_year.get_value_as_int(),
|
||||
self.dual_dated.get_active())
|
||||
calendar = self.calendar_box.get_active()
|
||||
newyear = self.date.newyear_to_code(self.new_year.get_text())
|
||||
newyear = Date.newyear_to_code(self.new_year.get_text())
|
||||
return (quality, modifier, calendar, value, text, newyear)
|
||||
|
||||
def switch_type(self, obj):
|
||||
|
@ -1062,18 +1062,20 @@ class Date(object):
|
||||
ny = "Err"
|
||||
return ny
|
||||
|
||||
def newyear_to_code(self, string):
|
||||
@staticmethod
|
||||
def newyear_to_code(string):
|
||||
"""
|
||||
Return the code of a newyear string.
|
||||
Return newyear code of string, where string is:
|
||||
'', 'Jan1', 'Mar1', '3-25', '9-1', etc.
|
||||
"""
|
||||
string = string.strip().lower()
|
||||
if string == "" or string == "jan1":
|
||||
code = Date.NEWYEAR_JAN1
|
||||
elif string == "mar1":
|
||||
code = Date.NEWYEAR_MAR1
|
||||
elif self.newyear == "mar25":
|
||||
elif string == "mar25":
|
||||
code = Date.NEWYEAR_MAR25
|
||||
elif self.newyear == "sep1":
|
||||
elif string == "sep1":
|
||||
code = Date.NEWYEAR_SEP1
|
||||
elif "-" in string:
|
||||
try:
|
||||
@ -1762,3 +1764,4 @@ def lookup_calendar(calendar):
|
||||
if calendar.lower() == calendar_name.lower():
|
||||
return pos
|
||||
raise AttributeError("invalid calendar: '%s'" % calendar)
|
||||
|
||||
|
@ -804,9 +804,9 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
else:
|
||||
dualdated_str = ''
|
||||
|
||||
newyear = date.get_new_year()
|
||||
if newyear != gen.lib.Date.NEWYEAR_JAN1:
|
||||
newyear_str = ' newyear="%d"' % newyear
|
||||
newyear = date.newyear_to_str()
|
||||
if newyear:
|
||||
newyear_str = ' newyear="%s"' % newyear
|
||||
else:
|
||||
newyear_str = ''
|
||||
|
||||
|
@ -1771,7 +1771,11 @@ class GrampsParser(UpdateCallback):
|
||||
|
||||
newyear = gen.lib.Date.NEWYEAR_JAN1
|
||||
if 'newyear' in attrs:
|
||||
newyear = int(attrs['newyear'])
|
||||
newyear = attrs['newyear']
|
||||
if newyear.isdigit():
|
||||
newyear = int(newyear)
|
||||
else:
|
||||
newyear = gen.lib.Date.newyear_to_code(newyear)
|
||||
|
||||
date_value.set(qual, mode, cal,
|
||||
(day, month, year, dualdated,
|
||||
@ -1848,7 +1852,11 @@ class GrampsParser(UpdateCallback):
|
||||
|
||||
newyear = gen.lib.Date.NEWYEAR_JAN1
|
||||
if 'newyear' in attrs:
|
||||
newyear = int(attrs['newyear'])
|
||||
newyear = attrs['newyear']
|
||||
if newyear.isdigit():
|
||||
newyear = int(newyear)
|
||||
else:
|
||||
newyear = gen.lib.Date.newyear_to_code(newyear)
|
||||
|
||||
date_value.set(qual, mod, cal, (day, month, year, dualdated),
|
||||
newyear=newyear)
|
||||
|
Loading…
Reference in New Issue
Block a user