relativedelta.months > 12 raise an AssertionError

Bug #1045343 reported by mutetella
6
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
        delta.months = delta.months % 12

mutetella

mutetella (mutetella)
tags: added: relativedelta
Revision history for this message
mutetella (mutetella) wrote :

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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.