summaryrefslogtreecommitdiff
path: root/src/isodate/duration.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/isodate/duration.py')
-rw-r--r--src/isodate/duration.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/isodate/duration.py b/src/isodate/duration.py
index fa501cd..0d5e0fa 100644
--- a/src/isodate/duration.py
+++ b/src/isodate/duration.py
@@ -140,6 +140,8 @@ class Duration(object):
newduration.tdelta = self.tdelta + other.tdelta
return newduration
if isinstance(other, (date, datetime)):
+ if (not( float(self.years).is_integer() and float(self.months).is_integer())):
+ raise ValueError('fractional years or months not supported for date calculations')
newmonth = other.month + self.months
carry, newmonth = fquotmod(newmonth, 1, 13)
newyear = other.year + self.years + carry
@@ -162,6 +164,8 @@ class Duration(object):
newduration.tdelta = self.tdelta + other
return newduration
if isinstance(other, (date, datetime)):
+ if (not( float(self.years).is_integer() and float(self.months).is_integer())):
+ raise ValueError('fractional years or months not supported for date calculations')
newmonth = other.month + self.months
carry, newmonth = fquotmod(newmonth, 1, 13)
newyear = other.year + self.years + carry
@@ -199,6 +203,8 @@ class Duration(object):
'''
#print '__rsub__:', self, other
if isinstance(other, (date, datetime)):
+ if (not( float(self.years).is_integer() and float(self.months).is_integer())):
+ raise ValueError('fractional years or months not supported for date calculations')
newmonth = other.month - self.months
carry, newmonth = fquotmod(newmonth, 1, 13)
newyear = other.year - self.years + carry