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

On Thu, Jul 30, 2015 at 6:46 PM, Chris Barker chris.barker@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.
participants (1)
-
Guido van Rossum