Use sophisticated Date.match() for lt and gt; don't match invalid dates
svn: r10574
This commit is contained in:
parent
dcc838a7aa
commit
02cceb2e8b
@ -189,7 +189,7 @@ class Date:
|
|||||||
self.sortval = 0
|
self.sortval = 0
|
||||||
self.newyear = 0
|
self.newyear = 0
|
||||||
self.set_yr_mon_day(*source)
|
self.set_yr_mon_day(*source)
|
||||||
elif type(source) == str:
|
elif type(source) == str and source != "":
|
||||||
if (calendar != None or
|
if (calendar != None or
|
||||||
modifier != None or
|
modifier != None or
|
||||||
quality != None):
|
quality != None):
|
||||||
@ -355,10 +355,16 @@ class Date:
|
|||||||
# return self.sortval == other.sortval
|
# return self.sortval == other.sortval
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
return self.sortval < other.sortval
|
"""
|
||||||
|
Comparison for less than.
|
||||||
|
"""
|
||||||
|
return self.match(other, comparison="<")
|
||||||
|
|
||||||
def __gt__(self, other):
|
def __gt__(self, other):
|
||||||
return self.sortval > other.sortval
|
"""
|
||||||
|
Comparison for greater than.
|
||||||
|
"""
|
||||||
|
return self.match(other, comparison=">")
|
||||||
|
|
||||||
def is_equal(self, other):
|
def is_equal(self, other):
|
||||||
"""
|
"""
|
||||||
@ -467,7 +473,9 @@ class Date:
|
|||||||
comparison >> :
|
comparison >> :
|
||||||
Returns True if all parts of other_date > all parts of self
|
Returns True if all parts of other_date > all parts of self
|
||||||
"""
|
"""
|
||||||
if (other_date.modifier == Date.MOD_TEXTONLY or
|
if (self.sortval == 0 or other_date.sortval == 0):
|
||||||
|
return False
|
||||||
|
elif (other_date.modifier == Date.MOD_TEXTONLY or
|
||||||
self.modifier == Date.MOD_TEXTONLY):
|
self.modifier == Date.MOD_TEXTONLY):
|
||||||
if comparison in ["=", "=="]:
|
if comparison in ["=", "=="]:
|
||||||
return (self.text.upper().find(other_date.text.upper()) != -1)
|
return (self.text.upper().find(other_date.text.upper()) != -1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user