예제 #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
예제 #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__))
예제 #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
예제 #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
예제 #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
예제 #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__))
예제 #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))
예제 #8
0
파일: tests.py 프로젝트: ixc/python-edtf
 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))
예제 #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)
예제 #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)