A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-April/133751.html below:

[Python-Dev] Negative timedelta strings

[Python-Dev] Negative timedelta stringsSkip Montanaro skip at pobox.com
Wed Apr 2 15:04:51 CEST 2014
On Wed, Apr 2, 2014 at 7:52 AM, M.-A. Lemburg <mal at 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?

Thx,

Skip
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4