[Datetime-SIG] Calendar vs timespan calculations...

Tim Peters tim.peters at gmail.com
Thu Jul 30 18:45:51 CEST 2015


Oops!  Forgot one:

[Guido]
> ... create new timedelta-ish classes that implement "human" arithmetic

Note that there's an annoying inelegance here:  after

     datetime2 = datetime1 + timedeltaish  # or subtraction

then what does:

     datetime2 - datetime1

produce?  Knowledge of the _kind_ of timedelta-ish object used to
produce datetime2 is long gone, so it may not be the case that

    datetime2 - datetime1 == timedeltaish

or even produce an object of the same class as timedeltaish.

Of course that's never a problem today.  If the inelegance is thought
to be unbearable, I suppose new timedelta-ish classes could provide an
explicit class method to subtract datetime instances (yielding "the
right" timedelta-ish object of the class).


More information about the Datetime-SIG mailing list