From 02cceb2e8b91ab65a9f5c629c31d333b52750918 Mon Sep 17 00:00:00 2001
From: Doug Blank <doug.blank@gmail.com>
Date: Thu, 17 Apr 2008 12:15:48 +0000
Subject: [PATCH] Use sophisticated Date.match() for lt and gt; don't match
 invalid dates

svn: r10574
---
 src/gen/lib/date.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py
index 38c170227..d86eaa061 100644
--- a/src/gen/lib/date.py
+++ b/src/gen/lib/date.py
@@ -189,7 +189,7 @@ class Date:
             self.sortval  = 0
             self.newyear = 0
             self.set_yr_mon_day(*source)
-        elif type(source) == str:
+        elif type(source) == str and source != "":
             if (calendar != None or 
                 modifier != None or 
                 quality != None):
@@ -355,10 +355,16 @@ class Date:
     #    return self.sortval == other.sortval
 
     def __lt__(self, other):
-        return self.sortval < other.sortval
+        """
+        Comparison for less than.
+        """
+        return self.match(other, comparison="<")
 
     def __gt__(self, other):
-        return self.sortval > other.sortval
+        """
+        Comparison for greater than.
+        """
+        return self.match(other, comparison=">")
 
     def is_equal(self, other):
         """
@@ -467,7 +473,9 @@ class Date:
         comparison >> :
             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):
             if comparison in ["=", "=="]:
                 return (self.text.upper().find(other_date.text.upper()) != -1)