5293: age='unknown' for after/after and before/before dates (age calculation)

svn: r18298
This commit is contained in:
Jérôme Rapinat 2011-10-12 16:30:18 +00:00
parent 1740803a58
commit 1bc8f8a79c

View File

@ -314,7 +314,7 @@ class Span(object):
#self.sort = (v, -Span.ABOUT) #self.sort = (v, -Span.ABOUT)
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
(year, month, day) = self._diff(self.date1, self.date2) (year, month, day) = self._diff(self.date1, self.date2)
self.repr = _("age|about") + " " + self._format((year, 0 ,0)) self.repr = _("age|about") + " " + self._format((year, 0 , 0))
elif (self.date2.get_modifier() == Date.MOD_RANGE or elif (self.date2.get_modifier() == Date.MOD_RANGE or
self.date2.get_modifier() == Date.MOD_SPAN): self.date2.get_modifier() == Date.MOD_SPAN):
start, stop = self.date2.get_start_stop_range() start, stop = self.date2.get_start_stop_range()
@ -336,7 +336,7 @@ class Span(object):
#v = self.date1.sortval - self.date2.sortval #v = self.date1.sortval - self.date2.sortval
#self.sort = (v, -Span.BEFORE) #self.sort = (v, -Span.BEFORE)
#self.minmax = (v, v + Span.BEFORE) #self.minmax = (v, v + Span.BEFORE)
self.repr = _("more than about") + " " + self._format(self._diff(self.date1, self.date2)) self.repr = self._format((-1, -1 , -1))
elif self.date2.get_modifier() == Date.MOD_AFTER: elif self.date2.get_modifier() == Date.MOD_AFTER:
#v = self.date1.sortval - self.date2.sortval #v = self.date1.sortval - self.date2.sortval
#self.sort = (v, -Span.AFTER) #self.sort = (v, -Span.AFTER)
@ -347,7 +347,7 @@ class Span(object):
#self.sort = (v, -Span.ABOUT) #self.sort = (v, -Span.ABOUT)
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
(year, month, day) = self._diff(self.date1, self.date2) (year, month, day) = self._diff(self.date1, self.date2)
self.repr = _("age|about") + " " + self._format((year, 0 ,0)) self.repr = _("age|about") + " " + self._format((year, 0 , 0))
elif (self.date2.get_modifier() == Date.MOD_RANGE or elif (self.date2.get_modifier() == Date.MOD_RANGE or
self.date2.get_modifier() == Date.MOD_SPAN): self.date2.get_modifier() == Date.MOD_SPAN):
#v = self.date1.sortval - self.date2.sortval #v = self.date1.sortval - self.date2.sortval
@ -369,13 +369,13 @@ class Span(object):
#v = self.date1.sortval - self.date2.sortval #v = self.date1.sortval - self.date2.sortval
#self.sort = (v, Span.AFTER) #self.sort = (v, Span.AFTER)
#self.minmax = (v, v + Span.AFTER) #self.minmax = (v, v + Span.AFTER)
self.repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2)) self.repr = self._format((-1, -1 , -1))
elif self.date2.get_modifier() == Date.MOD_ABOUT: elif self.date2.get_modifier() == Date.MOD_ABOUT:
#v = self.date1.sortval - self.date2.sortval #v = self.date1.sortval - self.date2.sortval
#self.sort = (v, -Span.ABOUT) #self.sort = (v, -Span.ABOUT)
#self.minmax = (v - Span.ABOUT, v + Span.AFTER) #self.minmax = (v - Span.ABOUT, v + Span.AFTER)
(year, month, day) = 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)) self.repr = _("more than about") + " " + self._format((year, 0 , 0))
elif (self.date2.get_modifier() == Date.MOD_RANGE or elif (self.date2.get_modifier() == Date.MOD_RANGE or
self.date2.get_modifier() == Date.MOD_SPAN): self.date2.get_modifier() == Date.MOD_SPAN):
#v = self.date1.sortval - self.date2.sortval #v = self.date1.sortval - self.date2.sortval
@ -388,32 +388,32 @@ class Span(object):
#self.sort = (v, -Span.ABOUT) #self.sort = (v, -Span.ABOUT)
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
(year, month, day) = (self._diff(self.date1, self.date2)) (year, month, day) = (self._diff(self.date1, self.date2))
self.repr = _("age|about") + " " + self._format((year, 0 ,0)) self.repr = _("age|about") + " " + self._format((year, 0 , 0))
elif self.date2.get_modifier() == Date.MOD_BEFORE: elif self.date2.get_modifier() == Date.MOD_BEFORE:
#v = self.date1.sortval - self.date2.sortval #v = self.date1.sortval - self.date2.sortval
#self.sort = (v, -Span.BEFORE) #self.sort = (v, -Span.BEFORE)
#self.minmax = (v - Span.BEFORE, v + Span.ABOUT) #self.minmax = (v - Span.BEFORE, v + Span.ABOUT)
(year, month, day) = self._diff(self.date1, self.date2) (year, month, day) = self._diff(self.date1, self.date2)
self.repr = _("more than") + " " + self._format((year, 0 ,0)) self.repr = _("more than") + " " + self._format((year, 0 , 0))
elif self.date2.get_modifier() == Date.MOD_AFTER: elif self.date2.get_modifier() == Date.MOD_AFTER:
#v = self.date1.sortval - self.date2.sortval #v = self.date1.sortval - self.date2.sortval
#self.sort = (v, Span.AFTER) #self.sort = (v, Span.AFTER)
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
(year, month, day) = 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)) self.repr = _("less than about") + " " + self._format((year, 0 , 0))
elif self.date2.get_modifier() == Date.MOD_ABOUT: elif self.date2.get_modifier() == Date.MOD_ABOUT:
#v = self.date1.sortval - self.date2.sortval #v = self.date1.sortval - self.date2.sortval
#self.sort = (v, -Span.ABOUT) #self.sort = (v, -Span.ABOUT)
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
(year, month, day) = self._diff(self.date1, self.date2) (year, month, day) = self._diff(self.date1, self.date2)
self.repr = _("age|about") + " " + self._format((year, 0 ,0)) self.repr = _("age|about") + " " + self._format((year, 0 , 0))
elif (self.date2.get_modifier() == Date.MOD_RANGE or elif (self.date2.get_modifier() == Date.MOD_RANGE or
self.date2.get_modifier() == Date.MOD_SPAN): self.date2.get_modifier() == Date.MOD_SPAN):
#v = self.date1.sortval - self.date2.sortval #v = self.date1.sortval - self.date2.sortval
#self.sort = (v, -Span.ABOUT) #self.sort = (v, -Span.ABOUT)
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
(year, month, day) = self._diff(self.date1, self.date2) (year, month, day) = self._diff(self.date1, self.date2)
self.repr = _("age|about") + " " + self._format((year, 0 ,0)) self.repr = _("age|about") + " " + self._format((year, 0 , 0))
elif (self.date1.get_modifier() == Date.MOD_RANGE or elif (self.date1.get_modifier() == Date.MOD_RANGE or
self.date1.get_modifier() == Date.MOD_SPAN): # SPAN---------------------------- self.date1.get_modifier() == Date.MOD_SPAN): # SPAN----------------------------
if self.date2.get_modifier() == Date.MOD_NONE: if self.date2.get_modifier() == Date.MOD_NONE:
@ -441,7 +441,7 @@ class Span(object):
#self.sort = (v, -Span.ABOUT) #self.sort = (v, -Span.ABOUT)
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT) #self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
(year, month, day) = self._diff(self.date1, self.date2) (year, month, day) = self._diff(self.date1, self.date2)
self.repr = _("age|about") + " " + self._format((year, 0 ,0)) self.repr = _("age|about") + " " + self._format((year, 0 , 0))
elif (self.date2.get_modifier() == Date.MOD_RANGE or elif (self.date2.get_modifier() == Date.MOD_RANGE or
self.date2.get_modifier() == Date.MOD_SPAN): self.date2.get_modifier() == Date.MOD_SPAN):
start1, stop1 = self.date1.get_start_stop_range() start1, stop1 = self.date1.get_start_stop_range()