diff options
Diffstat (limited to 'src/isodate/duration.py')
-rw-r--r-- | src/isodate/duration.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/isodate/duration.py b/src/isodate/duration.py index 437afe8..a901865 100644 --- a/src/isodate/duration.py +++ b/src/isodate/duration.py @@ -209,6 +209,27 @@ class Duration(object): raise TypeError('unsupported operand type(s) for +: %s and %s' % (other.__class__, self.__class__)) + def __mul__(self, other): + if isinstance(other, int): + newduration = Duration( + years=self.years * other, + months=self.months * other) + newduration.tdelta = self.tdelta * other + return newduration + raise TypeError('unsupported operand type(s) for +: %s and %s' % + (self.__class__, other.__class__)) + + def __rmul__(self, other): + + if isinstance(other, int): + newduration = Duration( + years=self.years * other, + months=self.months * other) + newduration.tdelta = self.tdelta * other + return newduration + raise TypeError('unsupported operand type(s) for +: %s and %s' % + (other.__class__, self.__class__)) + def __sub__(self, other): ''' It is possible to subtract Duration and timedelta objects from Duration |