I get different results when I add months to a DateTime in different increments. Is this a bug?
> start_date = DateTime.strptime("03/31/2001", "%m/%d/%Y")
#=> Sat, 31 Mar 2001 00:00:00 +0000
> start_date + 3.months
#=> Sat, 30 Jun 2001
> d1 = start_date + 3.months
#=> Sat, 30 Jun 2001
> d2 = d1 + 3.months
#=> Sun, 30 Sep 2001
> d3 = d2 + 3.months
#=> Sun, 30 Dec 2001
> start_date + 9.months
#=> Mon, 31 Dec 2001
So, (((start_date + 3.months) + 3.months) + 3.months)
!= start_date + 9.months
?
Solution (based on accepted answer below): using d3.end_of_month
gives me the expected 31 December
instead of 30 December
.