28/02/2009 + 1 month = 31/03/2009
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <boost/date_time/gregorian/formatters.hpp>
#include <iostream>
using namespace boost::gregorian;
using namespace std;
int main()
{
typedef boost::date_time::month_functor<date> add_month;
date d(2019, Feb, 28);
add_month mf(1);
date d2 = d + mf.get_offset(d);
cout << to_simple_string(d2) << endl;//output:2019-Mar-31
}
The output is 2019-Mar-31 rather than 2019-Mar-28. What is theoretical basis for this behavior? Talk about it outputs 2019-Mar-28 in both C# and delphi for the similar add month code.