On 2014-04-02, at 15:04 , Skip Montanaro <s...@pobox.com> wrote: > On Wed, Apr 2, 2014 at 7:52 AM, M.-A. Lemburg <m...@egenix.com> wrote: >>>>> print now() + RelativeDateTime(months=+1, day=1) >> 2014-05-01 14:49:05.83 > > I find this sort date arithmetic unintuitive, though I'm at a loss to > come up with better logic than you have: > >>>> d = Date(2014, 2, 28) >>>> d + RelativeDateTime(months=+1) > <mx.DateTime.DateTime object for '2014-03-28 00:00:00.00' at 1eda8c8> >>>> d = Date(2014, 1, 31) >>>> d + RelativeDateTime(months=+1) > <mx.DateTime.DateTime object for '2014-03-03 00:00:00.00' at 1eda870> > > I guess the assumption is that one month is the length in days of the > current month, though, you wind up with situations where shorter > months can be skipped altogether. Is there a way to talk in terms of > "months" but not have short months get skipped?
FWIW dateutil has a slightly different logic there: >>> date(2014, 2, 28) + relativedelta(months=+1) datetime.date(2014, 3, 28) >>> date(2014, 1, 31) + relativedelta(months=+1) datetime.date(2014, 2, 28) _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com