From b6993d02819b4f927d76c15613d6648fa416bad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Pievil=C3=A4inen?= Date: Sun, 19 Feb 2012 00:16:26 +0200 Subject: Fix relativedelta arithmetics --- dateutil/relativedelta.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'dateutil/relativedelta.py') 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", -- cgit v1.2.3