Date fixes.
svn: r587
This commit is contained in:
parent
525f9af8c6
commit
1668f37b5a
34
src/Date.py
34
src/Date.py
@ -204,7 +204,7 @@ class Date:
|
|||||||
else:
|
else:
|
||||||
self.start.set(text)
|
self.start.set(text)
|
||||||
self.range = 0
|
self.range = 0
|
||||||
except:
|
except Date.Error:
|
||||||
self.range = -1
|
self.range = -1
|
||||||
self.text = text
|
self.text = text
|
||||||
|
|
||||||
@ -423,7 +423,7 @@ class SingleDate:
|
|||||||
|
|
||||||
def setMonthStr(self,text):
|
def setMonthStr(self,text):
|
||||||
try:
|
try:
|
||||||
self.month = SingleDate.m2num[string.lower(text[0:3])]
|
self.month = _m2num[string.lower(text[0:3])]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.setMonthStrEng(text)
|
self.setMonthStrEng(text)
|
||||||
|
|
||||||
@ -768,18 +768,6 @@ class SingleDate:
|
|||||||
def setModeVal(self,val):
|
def setModeVal(self,val):
|
||||||
self.mode = val
|
self.mode = val
|
||||||
|
|
||||||
def getMode(self,val):
|
|
||||||
if val == None:
|
|
||||||
self.mode = SingleDate.exact
|
|
||||||
elif string.lower(val)[0:2] == "be":
|
|
||||||
self.mode = SingleDate.before
|
|
||||||
elif string.lower(val)[0:2] == "af":
|
|
||||||
self.mode = SingleDate.after
|
|
||||||
elif string.lower(val)[0:2] == "ab":
|
|
||||||
self.mode = SingleDate.about
|
|
||||||
else:
|
|
||||||
self.mode = SingleDate.exact
|
|
||||||
|
|
||||||
def set(self,text):
|
def set(self,text):
|
||||||
if self.calendar == GREGORIAN:
|
if self.calendar == GREGORIAN:
|
||||||
self.set_gregorian(text)
|
self.set_gregorian(text)
|
||||||
@ -794,6 +782,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt2.match(text)
|
match = SingleDate.fmt2.match(text)
|
||||||
if match:
|
if match:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
|
self.setMode(matches[0])
|
||||||
if l == 0:
|
if l == 0:
|
||||||
mon = string.lower(matches[2])
|
mon = string.lower(matches[2])
|
||||||
else:
|
else:
|
||||||
@ -811,6 +800,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt3.match(text)
|
match = SingleDate.fmt3.match(text)
|
||||||
if match:
|
if match:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
|
self.setMode(matches[0])
|
||||||
self.setYearVal(matches[3])
|
self.setYearVal(matches[3])
|
||||||
self.setMonthVal(matches[2])
|
self.setMonthVal(matches[2])
|
||||||
self.setDayVal(matches[1])
|
self.setDayVal(matches[1])
|
||||||
@ -819,6 +809,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt4.match(text)
|
match = SingleDate.fmt4.match(text)
|
||||||
if match:
|
if match:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
|
self.setMode(matches[0])
|
||||||
if l == 0:
|
if l == 0:
|
||||||
mon = string.lower(matches[1])
|
mon = string.lower(matches[1])
|
||||||
else:
|
else:
|
||||||
@ -831,6 +822,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt5.match(text)
|
match = SingleDate.fmt5.match(text)
|
||||||
if match:
|
if match:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
|
self.setMode(matches[0])
|
||||||
self.setYearVal(matches[1])
|
self.setYearVal(matches[1])
|
||||||
self.month = UNDEF
|
self.month = UNDEF
|
||||||
self.day = UNDEF
|
self.day = UNDEF
|
||||||
@ -844,7 +836,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt2.match(text)
|
match = SingleDate.fmt2.match(text)
|
||||||
if match != None:
|
if match != None:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.getMode(matches[0])
|
self.setMode(matches[0])
|
||||||
self.setMonthStr(matches[2])
|
self.setMonthStr(matches[2])
|
||||||
if self.month == UNDEF:
|
if self.month == UNDEF:
|
||||||
raise Date.Error,text
|
raise Date.Error,text
|
||||||
@ -858,7 +850,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt5.match(text)
|
match = SingleDate.fmt5.match(text)
|
||||||
if match != None:
|
if match != None:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.getMode(matches[0])
|
self.setMode(matches[0])
|
||||||
self.month = UNDEF
|
self.month = UNDEF
|
||||||
self.day = UNDEF
|
self.day = UNDEF
|
||||||
self.year = int(matches[1])
|
self.year = int(matches[1])
|
||||||
@ -867,7 +859,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt7.match(text)
|
match = SingleDate.fmt7.match(text)
|
||||||
if match != None:
|
if match != None:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.getMode(matches[0])
|
self.setMode(matches[0])
|
||||||
if Date.entryCode == 2:
|
if Date.entryCode == 2:
|
||||||
self.setMonthVal(matches[2])
|
self.setMonthVal(matches[2])
|
||||||
self.setYearVal(matches[1])
|
self.setYearVal(matches[1])
|
||||||
@ -879,7 +871,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt3.match(text)
|
match = SingleDate.fmt3.match(text)
|
||||||
if match != None:
|
if match != None:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.getMode(matches[0])
|
self.setMode(matches[0])
|
||||||
if Date.entryCode == 0:
|
if Date.entryCode == 0:
|
||||||
self.setMonthVal(matches[1])
|
self.setMonthVal(matches[1])
|
||||||
self.setDayVal(matches[2])
|
self.setDayVal(matches[2])
|
||||||
@ -897,7 +889,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt1.match(text)
|
match = SingleDate.fmt1.match(text)
|
||||||
if match != None:
|
if match != None:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.getMode(matches[0])
|
self.setMode(matches[0])
|
||||||
self.setMonthStr(matches[1])
|
self.setMonthStr(matches[1])
|
||||||
if self.month == UNDEF:
|
if self.month == UNDEF:
|
||||||
raise Date.Error,text
|
raise Date.Error,text
|
||||||
@ -912,7 +904,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt4.match(text)
|
match = SingleDate.fmt4.match(text)
|
||||||
if match != None:
|
if match != None:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.getMode(matches[0])
|
self.setMode(matches[0])
|
||||||
self.setMonthStr(matches[1])
|
self.setMonthStr(matches[1])
|
||||||
if self.month == UNDEF:
|
if self.month == UNDEF:
|
||||||
raise Date.Error,text
|
raise Date.Error,text
|
||||||
@ -924,7 +916,7 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt6.match(text)
|
match = SingleDate.fmt6.match(text)
|
||||||
if match != None:
|
if match != None:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.getMode(matches[0])
|
self.setMode(matches[0])
|
||||||
self.setMonthVal(matches[1])
|
self.setMonthVal(matches[1])
|
||||||
self.day = UNDEF
|
self.day = UNDEF
|
||||||
self.year = UNDEF
|
self.year = UNDEF
|
||||||
|
@ -402,9 +402,9 @@ class GrampsParser:
|
|||||||
d.get_start_date().setIsoDate(attrs['val'])
|
d.get_start_date().setIsoDate(attrs['val'])
|
||||||
|
|
||||||
if attrs.has_key("type"):
|
if attrs.has_key("type"):
|
||||||
d.get_start_date().getMode(attrs['type'])
|
d.get_start_date().setMode(attrs['type'])
|
||||||
else:
|
else:
|
||||||
d.get_start_date().getMode(None)
|
d.get_start_date().setMode(None)
|
||||||
|
|
||||||
|
|
||||||
def start_datestr(self,attrs):
|
def start_datestr(self,attrs):
|
||||||
|
@ -152,9 +152,6 @@ def loadData(database, filename, callback=None):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
parser.parse(xml_file)
|
parser.parse(xml_file)
|
||||||
except ExpatError,msg:
|
|
||||||
errmsg = "%s\n%s" % (_("Error reading %s") % filename,str(msg))
|
|
||||||
GnomeErrorDialog(errmsg)
|
|
||||||
except IOError,msg:
|
except IOError,msg:
|
||||||
errmsg = "%s\n%s" % (_("Error reading %s") % filename,str(msg))
|
errmsg = "%s\n%s" % (_("Error reading %s") % filename,str(msg))
|
||||||
GnomeErrorDialog(errmsg)
|
GnomeErrorDialog(errmsg)
|
||||||
|
Loading…
Reference in New Issue
Block a user