Example #1
0
 def __ne__(self, other):
     if isinstance(other, EDTFObject):
         return str(self) != str(other)
     elif isinstance(other, date):
         return str(self) != other.isoformat()
     elif isinstance(other, struct_time):
         return self._strict_date() != trim_struct_time(other)
     return True
Example #2
0
 def __le__(self, other):
     if isinstance(other, EDTFObject):
         return self.lower_strict() <= other.lower_strict()
     elif isinstance(other, date):
         return self.lower_strict() <= dt_to_struct_time(other)
     elif isinstance(other, struct_time):
         return self.lower_strict() <= trim_struct_time(other)
     raise TypeError("can't compare %s with %s" % (type(self).__name__, type(other).__name__))
Example #3
0
 def __ne__(self, other):
     if isinstance(other, EDTFObject):
         return str(self) != str(other)
     elif isinstance(other, date):
         return str(self) != other.isoformat()
     elif isinstance(other, struct_time):
         return self._strict_date() != trim_struct_time(other)
     return True
Example #4
0
 def __eq__(self, other):
     if isinstance(other, EDTFObject):
         return str(self) == str(other)
     elif isinstance(other, date):
         return str(self) == other.isoformat()
     elif isinstance(other, struct_time):
         return self._strict_date() == trim_struct_time(other)
     return False
Example #5
0
 def __eq__(self, other):
     if isinstance(other, EDTFObject):
         return str(self) == str(other)
     elif isinstance(other, date):
         return str(self) == other.isoformat()
     elif isinstance(other, struct_time):
         return self._strict_date() == trim_struct_time(other)
     return False
Example #6
0
 def __le__(self, other):
     if isinstance(other, EDTFObject):
         return self.lower_strict() <= other.lower_strict()
     elif isinstance(other, date):
         return self.lower_strict() <= dt_to_struct_time(other)
     elif isinstance(other, struct_time):
         return self.lower_strict() <= trim_struct_time(other)
     raise TypeError("can't compare %s with %s" %
                     (type(self).__name__, type(other).__name__))
Example #7
0
 def test_trim_struct_time(self):
     now = datetime.now()
     st = now.timetuple()
     trimmed_st = convert.trim_struct_time(st)
     # Confirm trimmed `struct_time` has expected date/time values
     self.assertEqual(
         trimmed_st[:6],
         (now.year, now.month, now.day, now.hour, now.minute, now.second))
     # Confirm 'extra' fields are set to defaults
     self.assertEqual(trimmed_st[6:], (0, 0, -1))
     # Confirm 'extra' fields in untrimmed `struct_time` has real values
     self.assertNotEqual(st[6:], (0, 0, -1))
Example #8
0
 def test_trim_struct_time(self):
     now = datetime.now()
     st = now.timetuple()
     trimmed_st = convert.trim_struct_time(st)
     # Confirm trimmed `struct_time` has expected date/time values
     self.assertEqual(
         trimmed_st[:6],
         (now.year, now.month, now.day, now.hour, now.minute, now.second)
     )
     # Confirm 'extra' fields are set to defaults
     self.assertEqual(trimmed_st[6:], (0, 0, -1))
     # Confirm 'extra' fields in untrimmed `struct_time` has real values
     self.assertNotEqual(st[6:], (0, 0, -1))
Example #9
0
 def __ne__(self, other):
     if isinstance(other, datetime):
         return self.isoformat() != other.isoformat()
     elif isinstance(other, struct_time):
         return self._strict_date() != trim_struct_time(other)
     return super(DateAndTime, self).__ne__(other)
Example #10
0
 def __ne__(self, other):
     if isinstance(other, datetime):
         return self.isoformat() != other.isoformat()
     elif isinstance(other, struct_time):
         return self._strict_date() != trim_struct_time(other)
     return super(DateAndTime, self).__ne__(other)