diff options
author | Tomi Pieviläinen <tomi.pievilainen+launchpad@iki.fi> | 2012-02-19 00:16:26 +0200 |
---|---|---|
committer | Tomi Pieviläinen <tomi.pievilainen+launchpad@iki.fi> | 2012-02-19 00:16:26 +0200 |
commit | b6993d02819b4f927d76c15613d6648fa416bad3 (patch) | |
tree | cb6c42fe38cedb613b837f84bc6fb2d8b8b7353d /dateutil/relativedelta.py | |
parent | f21920abb2739e37b97669b2b5c303b80f611858 (diff) | |
download | dateutil-b6993d02819b4f927d76c15613d6648fa416bad3.tar.gz |
Fix relativedelta arithmetics
Diffstat (limited to 'dateutil/relativedelta.py')
-rw-r--r-- | dateutil/relativedelta.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/dateutil/relativedelta.py b/dateutil/relativedelta.py index a1b8929..67de55e 100644 --- a/dateutil/relativedelta.py +++ b/dateutil/relativedelta.py @@ -367,13 +367,13 @@ Here is the behavior of operations with relativedelta: def __mul__(self, other): f = float(other) - return relativedelta(years=self.years*f, - months=self.months*f, - days=self.days*f, - hours=self.hours*f, - minutes=self.minutes*f, - seconds=self.seconds*f, - microseconds=self.microseconds*f, + return relativedelta(years=int(self.years*f), + months=int(self.months*f), + days=int(self.days*f), + hours=int(self.hours*f), + minutes=int(self.minutes*f), + seconds=int(self.seconds*f), + microseconds=int(self.microseconds*f), leapdays=self.leapdays, year=self.year, month=self.month, @@ -384,6 +384,8 @@ Here is the behavior of operations with relativedelta: second=self.second, microsecond=self.microsecond) + __rmul__ = __mul__ + def __eq__(self, other): if not isinstance(other, relativedelta): return False @@ -416,6 +418,8 @@ Here is the behavior of operations with relativedelta: def __div__(self, other): return self.__mul__(1/float(other)) + __truediv__ = __div__ + def __repr__(self): l = [] for attr in ["years", "months", "days", "leapdays", |