Bug introduced in v12.1.1 or earlier and fixed in v13.0.0
I am on Mathematica 12.1.1, running the following code and getting different results. Is it bug in DatePlus?
Setup
date1 = DateObject[{2020, 1, 30}]
activitytimeperiodcoveredbyoneperiodicpayment = "Month"
rng = Range[5]
Execution of DatePlus[]:
DatePlus[DateString[date1, "ISODate"], {#,
activitytimeperiodcoveredbyoneperiodicpayment}] & /@ rng
DatePlus[date1, {#,
activitytimeperiodcoveredbyoneperiodicpayment}] & /@ rng
Result:
{"Sat 29 Feb 2020 00:00:00", "Mon 30 Mar 2020 00:00:00", "Thu 30 Apr \
2020 00:00:00", "Sat 30 May 2020 00:00:00", "Tue 30 Jun 2020 \
00:00:00"}
{DateObject[{2020, 3, 1}, "Day", "Gregorian", -4.],
DateObject[{2020, 3, 30}, "Day", "Gregorian", -4.],
DateObject[{2020, 4, 30}, "Day", "Gregorian", -4.],
DateObject[{2020, 5, 30}, "Day", "Gregorian", -4.],
DateObject[{2020, 6, 30}, "Day", "Gregorian", -4.]}
```
DateObject
thanDateList
orDateString
input, in your case, withDateObject
it increases month without controlling the day overflow (we don't have 2020-2-30) so it goes to the next month, but with other types, it snaps to the last possible day without overflowing. $\endgroup$DatePlus
and/or a bug inDateObject
. $\endgroup$