From a702a815b385565376acd053a8d96ceccda0f44d Mon Sep 17 00:00:00 2001 From: Vassilii Khachaturov Date: Sun, 8 Sep 2013 19:23:23 +0000 Subject: [PATCH] consistency between offset and non-offset setters added ugly parameter _update2 to set_yr_mon_day, needs refactoring svn: r23058 --- gramps/gen/lib/date.py | 8 ++++---- gramps/gen/lib/test/date_test.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gramps/gen/lib/date.py b/gramps/gen/lib/date.py index ffca6263e..647f01e87 100644 --- a/gramps/gen/lib/date.py +++ b/gramps/gen/lib/date.py @@ -1280,13 +1280,15 @@ class Date(object): dv[pos_day] = day self.dateval = tuple(dv) - def set_yr_mon_day(self, year, month, day): + def set_yr_mon_day(self, year, month, day, _update2 = True): """ Set the year, month, and day values. """ self.__set_yr_mon_day(year, month, day, Date._POS_YR, Date._POS_MON, Date._POS_DAY) self._calc_sort_value() + if _update2 and self.is_compound(): + self.set2_yr_mon_day(year, month, day) def _assert_compound(self): if not self.is_compound(): @@ -1331,7 +1333,7 @@ class Date(object): self.dateval = tuple(dv) self._calc_sort_value() if day != 0 or dv[Date._POS_DAY] > 28: - self.set_yr_mon_day(*self.offset(day)) + self.set_yr_mon_day(*self.offset(day), _update2 = False) if self.is_compound(): self.set2_yr_mon_day_offset(year, month, day) @@ -1392,8 +1394,6 @@ class Date(object): """ retval = Date(self) retval.set_yr_mon_day(year, month, day) - if self.is_compound(): - retval.set2_yr_mon_day(year, month, day) return retval def set_year(self, year): diff --git a/gramps/gen/lib/test/date_test.py b/gramps/gen/lib/test/date_test.py index 5681d3ad3..7cc92ea77 100644 --- a/gramps/gen/lib/test/date_test.py +++ b/gramps/gen/lib/test/date_test.py @@ -444,10 +444,10 @@ class Test_set2(BaseDateTest): self.assertEqual(start, (2000, 1, 1)) self.assertEqual(stop, (2013, 2, 2)) - def test_set2_ymd_overrides_stop_date(self): - self.date.set2_yr_mon_day(2013, 2, 2) + def test_set_ymd_overrides_both_dates(self): + self.date.set_yr_mon_day(2013, 2, 2) start,stop = self.date.get_start_stop_range() - self.assertEqual(start, (2000, 1, 1)) + self.assertEqual(start, stop) self.assertEqual(stop, (2013, 2, 2)) def test_set_ymd_offset_updates_both_ends(self):