From 6dbab993303661312275b213603d4d8c5675d8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Wed, 12 Oct 2011 14:42:54 +0000 Subject: [PATCH] 5293: return year only with 'about' calculation svn: r18294 --- src/gen/lib/date.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py index 7bff4a6eb..6cef8e7fd 100644 --- a/src/gen/lib/date.py +++ b/src/gen/lib/date.py @@ -313,7 +313,8 @@ class Span(object): #v = self.date1.sortval - self.date2.sortval #self.sort = (v, -Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT) - self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)) + (year, month, day) = self._diff(self.date1, self.date2) + self.repr = _("age|about") + " " + self._format((year, 0 ,0)) elif (self.date2.get_modifier() == Date.MOD_RANGE or self.date2.get_modifier() == Date.MOD_SPAN): start, stop = self.date2.get_start_stop_range() @@ -335,7 +336,7 @@ class Span(object): #v = self.date1.sortval - self.date2.sortval #self.sort = (v, -Span.BEFORE) #self.minmax = (v, v + Span.BEFORE) - self.repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2)) + self.repr = _("more than about") + " " + self._format(self._diff(self.date1, self.date2)) elif self.date2.get_modifier() == Date.MOD_AFTER: #v = self.date1.sortval - self.date2.sortval #self.sort = (v, -Span.AFTER) @@ -345,7 +346,8 @@ class Span(object): #v = self.date1.sortval - self.date2.sortval #self.sort = (v, -Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT) - self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)) + (year, month, day) = self._diff(self.date1, self.date2) + self.repr = _("age|about") + " " + self._format((year, 0 ,0)) elif (self.date2.get_modifier() == Date.MOD_RANGE or self.date2.get_modifier() == Date.MOD_SPAN): #v = self.date1.sortval - self.date2.sortval @@ -372,7 +374,8 @@ class Span(object): #v = self.date1.sortval - self.date2.sortval #self.sort = (v, -Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.AFTER) - self.repr = _("more than about") + " " + self._format(self._diff(self.date1, self.date2)) + (year, month, day) = self._diff(self.date1, self.date2) + self.repr = _("more than about") + " " + self._format((year, 0 ,0)) elif (self.date2.get_modifier() == Date.MOD_RANGE or self.date2.get_modifier() == Date.MOD_SPAN): #v = self.date1.sortval - self.date2.sortval @@ -384,28 +387,33 @@ class Span(object): #v = self.date1.sortval - self.date2.sortval #self.sort = (v, -Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT) - self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)) + (year, month, day) = (self._diff(self.date1, self.date2)) + self.repr = _("age|about") + " " + self._format((year, 0 ,0)) elif self.date2.get_modifier() == Date.MOD_BEFORE: #v = self.date1.sortval - self.date2.sortval #self.sort = (v, -Span.BEFORE) #self.minmax = (v - Span.BEFORE, v + Span.ABOUT) - self.repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2)) + (year, month, day) = self._diff(self.date1, self.date2) + self.repr = _("more than") + " " + self._format((year, 0 ,0)) elif self.date2.get_modifier() == Date.MOD_AFTER: #v = self.date1.sortval - self.date2.sortval #self.sort = (v, Span.AFTER) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT) - self.repr = _("less than about") + " " + self._format(self._diff(self.date1, self.date2)) + (year, month, day) = self._diff(self.date1, self.date2) + self.repr = _("less than about") + " " + self._format((year, 0 ,0)) elif self.date2.get_modifier() == Date.MOD_ABOUT: #v = self.date1.sortval - self.date2.sortval #self.sort = (v, -Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT) - self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)) + (year, month, day) = self._diff(self.date1, self.date2) + self.repr = _("age|about") + " " + self._format((year, 0 ,0)) elif (self.date2.get_modifier() == Date.MOD_RANGE or self.date2.get_modifier() == Date.MOD_SPAN): #v = self.date1.sortval - self.date2.sortval #self.sort = (v, -Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT) - self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)) + (year, month, day) = self._diff(self.date1, self.date2) + self.repr = _("age|about") + " " + self._format((year, 0 ,0)) elif (self.date1.get_modifier() == Date.MOD_RANGE or self.date1.get_modifier() == Date.MOD_SPAN): # SPAN---------------------------- if self.date2.get_modifier() == Date.MOD_NONE: @@ -432,7 +440,8 @@ class Span(object): #v = self.date1.sortval - self.date2.sortval #self.sort = (v, -Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT) - self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)) + (year, month, day) = self._diff(self.date1, self.date2) + self.repr = _("age|about") + " " + self._format((year, 0 ,0)) elif (self.date2.get_modifier() == Date.MOD_RANGE or self.date2.get_modifier() == Date.MOD_SPAN): start1, stop1 = self.date1.get_start_stop_range()