I have the following code:
import datetime
from dateutil.relativedelta import relativedelta
date_1=datetime.date(2000,2,28)+relativedelta(years=+1)
date_2=datetime.date(2000,2,29)+relativedelta(years=+1)
print(date_1)
print(date_2)
date_1=date_1+relativedelta(years=+1)
date_2=date_2+relativedelta(years=+1)
print(date_1)
print(date_2)
date_1=date_1+relativedelta(years=+1)
date_2=date_2+relativedelta(years=+1)
print(date_1)
print(date_2)
And this is the output:
2001-02-28
2001-02-28
2002-02-28
2002-02-28
2003-02-28
2003-02-28
My question is why the output is the same for both 28 and 29 february?I thought when I enter 29 the answer in the end is gonna be 1/3/2003 and for 28 the answer in the end is gonna be 28/2/2003.(different answers).Additionally,when I'm doing:
import datetime
from dateutil.relativedelta import relativedelta
print(relativedelta(datetime.date(2003,2,28),datetime.date(2000,2,29)).years)
print(relativedelta(datetime.date(2003,2,28),datetime.date(2000,2,28)).years)
I get:
3
3
I don't know why it's the same.