2008-02-25 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/gen/lib/test/date_test.py: new slash date tests * src/gen/lib/date.py: new get_slash(), fix slash conversions * src/DateHandler/_DateParser.py: parser sets slash date to Julian svn: r10114
This commit is contained in:
parent
e801786edb
commit
6103ed9539
@ -1,3 +1,8 @@
|
|||||||
|
2008-02-25 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||||
|
* src/gen/lib/test/date_test.py: new slash date tests
|
||||||
|
* src/gen/lib/date.py: new get_slash(), fix slash conversions
|
||||||
|
* src/DateHandler/_DateParser.py: parser sets slash date to Julian
|
||||||
|
|
||||||
2008-02-24 Brian Matherly <brian@gramps-project.org>
|
2008-02-24 Brian Matherly <brian@gramps-project.org>
|
||||||
* src/GrampsDbUtils/_ReadXML.py:
|
* src/GrampsDbUtils/_ReadXML.py:
|
||||||
* src/GrampsDbUtils/_GrmapsDbWriteXML.py:
|
* src/GrampsDbUtils/_GrmapsDbWriteXML.py:
|
||||||
|
@ -593,6 +593,10 @@ class DateParser:
|
|||||||
else:
|
else:
|
||||||
date.set(qual, Date.MOD_NONE, cal, subdate)
|
date.set(qual, Date.MOD_NONE, cal, subdate)
|
||||||
|
|
||||||
|
if date.get_slash():
|
||||||
|
date.set_calendar(Date.CAL_JULIAN)
|
||||||
|
date.set_year(date.get_year()) # forces recalc
|
||||||
|
|
||||||
def invert_year(self, subdate):
|
def invert_year(self, subdate):
|
||||||
return (subdate[0], subdate[1], -subdate[2], subdate[3])
|
return (subdate[0], subdate[1], -subdate[2], subdate[3])
|
||||||
|
|
||||||
|
@ -384,11 +384,9 @@ class Date:
|
|||||||
|
|
||||||
Slash date is given as year1/year2, where year1 is Julian year,
|
Slash date is given as year1/year2, where year1 is Julian year,
|
||||||
and year2=year1+1 the Gregorian year.
|
and year2=year1+1 the Gregorian year.
|
||||||
|
|
||||||
|
Slash date is already taken care of.
|
||||||
"""
|
"""
|
||||||
if dateval[Date._POS_SL] :
|
|
||||||
return (dateval[Date._POS_YR]+1, dateval[Date._POS_MON],
|
|
||||||
dateval[Date._POS_DAY])
|
|
||||||
else :
|
|
||||||
return (dateval[Date._POS_YR], dateval[Date._POS_MON],
|
return (dateval[Date._POS_YR], dateval[Date._POS_MON],
|
||||||
dateval[Date._POS_DAY])
|
dateval[Date._POS_DAY])
|
||||||
def date_offset(dateval, offset):
|
def date_offset(dateval, offset):
|
||||||
@ -733,8 +731,17 @@ class Date:
|
|||||||
"""
|
"""
|
||||||
Return a Date copy based on year, month, and day offset.
|
Return a Date copy based on year, month, and day offset.
|
||||||
"""
|
"""
|
||||||
retval = Date(self)
|
orig_cal = self.calendar
|
||||||
|
if self.calendar != 0:
|
||||||
|
new_date = self.to_calendar("gregorian")
|
||||||
|
else:
|
||||||
|
new_date = self
|
||||||
|
retval = Date(new_date)
|
||||||
retval.set_yr_mon_day_offset(year, month, day)
|
retval.set_yr_mon_day_offset(year, month, day)
|
||||||
|
if orig_cal == 0:
|
||||||
|
return retval
|
||||||
|
else:
|
||||||
|
retval.convert_calendar(orig_cal)
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
def copy_ymd(self, year=0, month=0, day=0):
|
def copy_ymd(self, year=0, month=0, day=0):
|
||||||
@ -915,6 +922,13 @@ class Date:
|
|||||||
"""
|
"""
|
||||||
if calendar == self.calendar:
|
if calendar == self.calendar:
|
||||||
return
|
return
|
||||||
|
if self.get_slash():
|
||||||
|
if (self.calendar == Date.CAL_JULIAN and
|
||||||
|
calendar == Date.CAL_GREGORIAN):
|
||||||
|
self.set_year(self.get_year() + 1)
|
||||||
|
elif (self.calendar == Date.CAL_GREGORIAN and
|
||||||
|
calendar == Date.CAL_JULIAN):
|
||||||
|
self.set_year(self.get_year() - 1)
|
||||||
(year, month, day) = Date._calendar_change[calendar](self.sortval)
|
(year, month, day) = Date._calendar_change[calendar](self.sortval)
|
||||||
if self.is_compound():
|
if self.is_compound():
|
||||||
ryear = max(self.dateval[Date._POS_RYR], 1)
|
ryear = max(self.dateval[Date._POS_RYR], 1)
|
||||||
@ -1040,3 +1054,11 @@ class Date:
|
|||||||
retval = Date(self)
|
retval = Date(self)
|
||||||
retval.convert_calendar(cal)
|
retval.convert_calendar(cal)
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
def get_slash(self):
|
||||||
|
"""
|
||||||
|
Return true if the date is a slash-date.
|
||||||
|
"""
|
||||||
|
return self._get_low_item_valid(Date._POS_SL)
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,7 +298,9 @@ def suite():
|
|||||||
("aft jan 1, 2000", "before dec 31, 1999", False),
|
("aft jan 1, 2000", "before dec 31, 1999", False),
|
||||||
("before jan 1, 2000", "after dec 31, 1999", False),
|
("before jan 1, 2000", "after dec 31, 1999", False),
|
||||||
("jan 1, 2000/1", "jan 1, 2000", False),
|
("jan 1, 2000/1", "jan 1, 2000", False),
|
||||||
("jan 1, 2000/1", "jan 1, 2001", True),
|
("jan 1, 2000/1", "jan 1, 2001", False),
|
||||||
|
("jan 1, 2000/1", "jan 1, 2000/1", True),
|
||||||
|
("jan 1, 2000/1", "jan 14, 2001", True),
|
||||||
("about 1984", "about 2005", False),
|
("about 1984", "about 2005", False),
|
||||||
("about 1990", "about 2005", True),
|
("about 1990", "about 2005", True),
|
||||||
("about 2007", "about 2006", True),
|
("about 2007", "about 2006", True),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user