0002045: Julian date: year incremented each time event is modified; removed earlier hack, and fixed properly. Other date parsers or displayers may have to change
svn: r10587
This commit is contained in:
parent
fe35c2ff91
commit
3373062274
@ -162,12 +162,12 @@ class DateDisplay:
|
||||
val = - val
|
||||
|
||||
if slash:
|
||||
if val % 100 == 99:
|
||||
year = "%d/%d" % (val, (val%1000)+1)
|
||||
elif val % 10 == 9:
|
||||
year = "%d/%d" % (val, (val%100)+1)
|
||||
if (val-1) % 100 == 99:
|
||||
year = "%d/%d" % (val - 1, (val%1000))
|
||||
elif (val-1) % 10 == 9:
|
||||
year = "%d/%d" % (val - 1, (val%100))
|
||||
else:
|
||||
year = "%d/%d" % (val, (val%10)+1)
|
||||
year = "%d/%d" % (val - 1, (val%10))
|
||||
else:
|
||||
year = "%d" % (val)
|
||||
|
||||
|
@ -328,8 +328,12 @@ class DateParser:
|
||||
s = False
|
||||
else:
|
||||
d = self._get_int(groups[1])
|
||||
y = int(groups[3])
|
||||
s = groups[4] != None
|
||||
if groups[4] != None: # slash year digit
|
||||
y = int(groups[3][:-1] + groups[4])
|
||||
s = True
|
||||
else: # regular, non-slash date
|
||||
y = int(groups[3])
|
||||
s = False
|
||||
value = (d, m, y, s)
|
||||
if check and not check((d, m, y)):
|
||||
value = Date.EMPTY
|
||||
@ -349,8 +353,12 @@ class DateParser:
|
||||
y = None
|
||||
s = False
|
||||
else:
|
||||
y = int(groups[3])
|
||||
s = groups[4] != None
|
||||
if groups[4] != None: # slash year digit
|
||||
y = int(groups[3][:-1] + groups[4])
|
||||
s = True
|
||||
else:
|
||||
y = int(groups[3])
|
||||
s = False
|
||||
value = (d, m, y, s)
|
||||
if check and not check((d, m, y)):
|
||||
value = Date.EMPTY
|
||||
@ -382,8 +390,8 @@ class DateParser:
|
||||
d = self._get_int(groups[4])
|
||||
if check and not check((d, m, y)):
|
||||
return Date.EMPTY
|
||||
if groups[2]:
|
||||
return (d, m, y, True)
|
||||
if groups[2]: # slash year digit
|
||||
return (d, m, y + 1, True)
|
||||
else:
|
||||
return (d, m, y, False)
|
||||
|
||||
@ -595,7 +603,7 @@ class DateParser:
|
||||
|
||||
if date.get_slash():
|
||||
date.set_calendar(Date.CAL_JULIAN)
|
||||
date.set_year(date.get_year() + 1) # year++ and forces recalc
|
||||
date.recalc_sort_value() # needed after the calendar change
|
||||
|
||||
def invert_year(self, subdate):
|
||||
return (subdate[0], subdate[1], -subdate[2], subdate[3])
|
||||
|
@ -578,6 +578,12 @@ class Date:
|
||||
|
||||
if self.modifier == Date.MOD_TEXTONLY:
|
||||
val = self.text
|
||||
elif self.get_slash():
|
||||
val = "%04d/%d-%02d-%02d" % (
|
||||
self.dateval[Date._POS_YR] - 1,
|
||||
(self.dateval[Date._POS_YR]) % 10,
|
||||
self.dateval[Date._POS_MON],
|
||||
self.dateval[Date._POS_DAY])
|
||||
elif self.modifier == Date.MOD_RANGE or self.modifier == Date.MOD_SPAN:
|
||||
val = "%04d-%02d-%02d - %04d-%02d-%02d" % (
|
||||
self.dateval[Date._POS_YR], self.dateval[Date._POS_MON],
|
||||
@ -962,6 +968,14 @@ class Date:
|
||||
if text:
|
||||
self.text = text
|
||||
|
||||
def recalc_sort_value(self):
|
||||
"""
|
||||
Recalculates the numerical sort value associated with the date
|
||||
and returns it. Public method.
|
||||
"""
|
||||
self._calc_sort_value()
|
||||
return self.sortval
|
||||
|
||||
def _calc_sort_value(self):
|
||||
"""
|
||||
Calculate the numerical sort value associated with the date.
|
||||
|
Loading…
Reference in New Issue
Block a user