[Python-Dev] Negative timedelta strings

Xavier Morel python-dev at masklinn.net
Mon Mar 31 22:01:52 CEST 2014


On 2014-03-28, at 17:19 , Skip Montanaro <skip at pobox.com> wrote:
> (*) As an aside (that is, this belongs in a separate thread if you
> want to discuss it), in my opinion, attempting to support ISO 8601
> formatting is pointless without the presence of an anchor datetime.
> Otherwise how would you know how far back "five months" or "seven
> years" was?

dateutil's relativedelta keeps the notion "abstract" until it's
combined with an anchor datetime, at which point it's reified to
a real duration[0].

> If that's the case, then you might as well add the
timedelta to your anchor datetime and just use datetime.strftime().

You can't even express "next month" with timedelta, since the duration
of a month is not a fixed number of seconds.

[0] well not exactly, a relativedelta really defines a processing
    pipeline on its anchor date, which allows for fun stuff like
    "saturday the third week of next month".


More information about the Python-Dev mailing list