From d971b265aa6503221afcc84c6e0d05ecf8c1565c Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 11 Jun 2003 01:35:04 +0000 Subject: [PATCH] * src/Date.py: Handle date ranges in the form of xxxx - xxxx svn: r1688 --- src/Date.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Date.py b/src/Date.py index c6aefd734..739e74f72 100644 --- a/src/Date.py +++ b/src/Date.py @@ -76,6 +76,7 @@ class Date: tstr = _("(and|to|-)") fmt = compile("\s*%s\s+(.+)\s+%s\s+(.+)\s*$" % (fstr,tstr),IGNORECASE) + fmt1 = compile("\s*([^-]+)\s*-\s*([^-]+)\s*$",IGNORECASE) def __init__(self,source=None): if source: @@ -193,8 +194,8 @@ class Date: return compare_dates(self,other) == 0 def set(self,text): - match = Date.fmt.match(text) try: + match = Date.fmt.match(text) if match: matches = match.groups() self.start.set(matches[1]) @@ -203,9 +204,21 @@ class Date: self.stop.calendar = self.calendar self.stop.set(matches[3]) self.range = 1 - else: - self.start.set(text) - self.range = 0 + return + + 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: if text != "": self.range = -1