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

Guido van Rossum guido at python.org
Thu Jul 30 21:38:25 CEST 2015


On Thu, Jul 30, 2015 at 6:46 PM, Chris Barker <chris.barker at noaa.gov> wrote:

> [...] I thought a timedelta was a duration, but I was wrong, it is a
> Period in units of days (I think!), and sure it apparently does that right.
>

Honestly I don't think timedelta cleanly maps to either of those
concepts[1]. While it's true that when a timedelta is added to a datetime
it behaves like a Period, when timedeltas are added or subtracted they
behave more like Durations: adding several timedeltas just results in
modding the number of seconds to be in [0, 86400) and assigning the rest to
days (e.g. a timedelta of -1 seconds ends up being -1 days and +86399
seconds). So I don't think it can be extended to provide more human time
operations.

[1] From http://nodatime.org/1.2.x/userguide/concepts.html; Duration is a
simple number of ticks, while a Period is a vector of calendar-based units
like year, month, etc.
-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150730/9f418fea/attachment.html>


More information about the Datetime-SIG mailing list