Comment 2 for bug 1551099

Matt Johnson (mj1856) wrote :

Do not try to add 365 days. You're just exchanging one type of leap year bug with another.

The problem is much more complicated than you might think, as you have to consider whether to add 365 or 366 days based on whether or not there's an instance of February 29th in the range being covered. Also, if you're using a time zone aware datetime, you also have to consider if you've crossed one or more time zone transitions (daylight saving time, etc.) in the specified time zone.

Instead, use the python-dateutil library:

new_date = datetime_object + relativedelta(years=1)