[Python-Dev] Status on PEP-431 Timezones

Lennart Regebro regebro at gmail.com
Tue Jul 28 08:54:58 CEST 2015


On Tue, Jul 28, 2015 at 8:11 AM, Tim Peters <tim.peters at gmail.com> wrote:
> [Tim]
>>> timedelta objects only store days, seconds, and microseconds,
>
> [Lennart Regebro <regebro at gmail.com>]
>> Except that they don't actually store days. They store 24 hour
>> periods,
>
> Not really.  A timedelta is truly an integer number of microseconds,
> and that's all.

That's what I said. Timedeltas, internally assume that 1 day is 24
hours. Or 86400000 microseconds. That's the assumption internally in
the timedelta object.

The problem with that being that in the real world that's not true.

> 24 hours is 24 hours at any time in _any_ time zone, ignoring leap
> seconds.  timedeltas are durations, not points in time.  "time zones"
> make no sense applied to durations.

My point exactly.

And should not then adding 86400000 microseconds to a datetime
actually result in a datetime that happens 86400000 microseconds
later?

>> ie, it assumes that one day is always 24 hours.
>
> That's really not what it's doing

That is really exactly what the timedelta is doing, as you yourself,
just a few lines above say.

> used in explanations.  What somedatetime+timedelta really does is
> simpler than that:  it adds the number of microseconds represented by
> the timedelta to somedatetime,

No it doesn't.


More information about the Python-Dev mailing list