154
154
return other - self.date()
156
def __cmp__(self, other):
157
""" Compare with other Date instance """
158
if isinstance(other, Date):
159
comparison = cmp(self.date(), other.date())
161
# Keep fuzzy dates below normal dates
163
if self.is_fuzzy() and not other.is_fuzzy():
165
elif not self.is_fuzzy() and other.is_fuzzy():
169
elif isinstance(other, datetime.date):
170
return cmp(self.date(), other)
172
raise NotImplementedError
156
def __lt__(self, other):
157
""" Judge whehter less than other Date instance """
158
if isinstance(other, Date):
159
td = self.date() - other.date()
161
# Keep fuzzy dates below normal dates
162
if td == datetime.timedelta(0):
163
if self.is_fuzzy() and not other.is_fuzzy():
165
elif not self.is_fuzzy() and other.is_fuzzy():
168
return self.date() < other.date()
169
elif isinstance(other, datetime.date):
170
return self.date() < other
172
raise NotImplementedError
175
def __gt__(self, other):
176
""" Judge whehter greater than other Date instance """
177
if isinstance(other, Date):
178
td = other.date() - self.date()
180
# Keep fuzzy dates below normal dates
181
if td == datetime.timedelta(0):
182
if self.is_fuzzy() and not other.is_fuzzy():
184
elif not self.is_fuzzy() and other.is_fuzzy():
187
return other.date() < self.date()
188
elif isinstance(other, datetime.date):
189
return other < self.date()
191
raise NotImplementedError
174
194
def __str__(self):
175
195
if self._fuzzy is not None: