* src/Date.py: Handle date ranges in the form of xxxx - xxxx
svn: r1688
This commit is contained in:
parent
209075afc8
commit
d971b265aa
21
src/Date.py
21
src/Date.py
@ -76,6 +76,7 @@ class Date:
|
|||||||
tstr = _("(and|to|-)")
|
tstr = _("(and|to|-)")
|
||||||
|
|
||||||
fmt = compile("\s*%s\s+(.+)\s+%s\s+(.+)\s*$" % (fstr,tstr),IGNORECASE)
|
fmt = compile("\s*%s\s+(.+)\s+%s\s+(.+)\s*$" % (fstr,tstr),IGNORECASE)
|
||||||
|
fmt1 = compile("\s*([^-]+)\s*-\s*([^-]+)\s*$",IGNORECASE)
|
||||||
|
|
||||||
def __init__(self,source=None):
|
def __init__(self,source=None):
|
||||||
if source:
|
if source:
|
||||||
@ -193,8 +194,8 @@ class Date:
|
|||||||
return compare_dates(self,other) == 0
|
return compare_dates(self,other) == 0
|
||||||
|
|
||||||
def set(self,text):
|
def set(self,text):
|
||||||
match = Date.fmt.match(text)
|
|
||||||
try:
|
try:
|
||||||
|
match = Date.fmt.match(text)
|
||||||
if match:
|
if match:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.start.set(matches[1])
|
self.start.set(matches[1])
|
||||||
@ -203,9 +204,21 @@ class Date:
|
|||||||
self.stop.calendar = self.calendar
|
self.stop.calendar = self.calendar
|
||||||
self.stop.set(matches[3])
|
self.stop.set(matches[3])
|
||||||
self.range = 1
|
self.range = 1
|
||||||
else:
|
return
|
||||||
self.start.set(text)
|
|
||||||
self.range = 0
|
match = Date.fmt1.match(text)
|
||||||
|
if match:
|
||||||
|
matches = match.groups()
|
||||||
|
self.start.set(matches[0])
|
||||||
|
if self.stop == None:
|
||||||
|
self.stop = SingleDate()
|
||||||
|
self.stop.calendar = self.calendar
|
||||||
|
self.stop.set(matches[1])
|
||||||
|
self.range = 1
|
||||||
|
return
|
||||||
|
|
||||||
|
self.start.set(text)
|
||||||
|
self.range = 0
|
||||||
except Errors.DateError:
|
except Errors.DateError:
|
||||||
if text != "":
|
if text != "":
|
||||||
self.range = -1
|
self.range = -1
|
||||||
|
Loading…
Reference in New Issue
Block a user