1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 from timelinelib.calendar.time import ComparableValue
20 from timelinelib.calendar.time import GenericDeltaMixin
21 from timelinelib.calendar.time import GenericTimeMixin
22
23
24 -class NumTime(ComparableValue, GenericTimeMixin):
25
26 @property
29
31 return "{0}<{1!r}>".format(self.__class__.__name__, self.value)
32
34 if isinstance(other, self.DeltaClass):
35
36 return self.__class__(self.value + other.value)
37 else:
38 return NotImplemented
39
41 if isinstance(other, self.DeltaClass):
42
43 return self.__class__(self.value - other.value)
44 elif isinstance(other, self.__class__):
45
46 return self.DeltaClass(self.value - other.value)
47 else:
48 return NotImplemented
49
50
51 -class NumDelta(ComparableValue, GenericDeltaMixin):
52
54 return "{0}<{1!r}>".format(self.__class__.__name__, self.value)
55
57 if isinstance(other, self.__class__):
58
59 return self.__class__(self.value - other.value)
60 else:
61 return NotImplemented
62
64
65 return self.__class__(self.value * other)
66
68 if isinstance(other, self.__class__):
69
70 return float(self.value) / float(other.value)
71 else:
72
73 return self.__class__(self.value / other)
74