relativedelta.months > 12 raise an AssertionError
Bug #1045343 reported by
mutetella
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dateutil |
New
|
Undecided
|
Unassigned |
Bug Description
An calculation for more than 12 months forward or backward will raise an AssertionError. This error occurs with dateutils 1.5 and 2.0, for previous versions I don't know.
Currently I solved this as follow:
if delta.months > 12:
delta.years += delta.months / 12
mutetella
tags: | added: relativedelta |
To post a comment you must log in.
I must substantiate my Bug Description:
>>> datetime.date(2012, 9, 4) + dateutil. relativedelta. relativedelta( months= +13)
datetime.date(2013, 10, 4)
>>> d = dateutil. relativedelta. relativedelta( )
>>> d.months = 13
>>> datetime.date(2012, 9, 4) + d
AssertionError
>>> d = dateutil. relativedelta. relativedelta( )
>>> d.days = 40
>>> datetime.date(2012, 9, 4) + d
datetime.date(2012, 10, 14)
The AssertionError only occurs with 'relativedelta. months' > 12 but not with 'days'- or 'years'-attributes. With 'months' > 12 passed as an __init__-attribute it works proper.