[Datetime-SIG] Clearing up terminology

ISAAC J SCHWABACHER ischwabacher at wisc.edu
Thu Jul 30 17:26:53 CEST 2015


> From: Datetime-SIG <datetime-sig-bounces+ischwabacher=wisc.edu at python.org> on behalf of Chris Barker <chris.barker at noaa.gov>
> Sent: Wednesday, July 29, 2015 19:14
> To: Felipe Ochoa
> Cc: datetime-sig
> Subject: Re: [Datetime-SIG] Clearing up terminology
> 
> Then there seem to be the big hang-up: people want a way to define Periods (as defined above) and want to be able to do datetime math with them. I"m still really confused as to why folks seemed to think "time zone aware" somehow meant using Peiods rather  than Durations for arithmetic, but there you go. Clearly this is very useful thing to have, but it's NEW feature, and not covered in the PEP.

I think you're missing something here.  This *isn't* the current behavior-- adding a 24 hour timedelta (a Duration) to an aware datetime (a ZonedDateTime) *doesn't* produce an aware datetime corresponding to the Instant 24 hours after the Instant corresponding to the first datetime; rather, it produces an aware datetime equal to the first but with its days field incremented by one.  This result corresponds to an Instant that may be 23 or 25 hours (or some weirder number, in exceptional cases) after the first Instant.  Which is to say, currently, datetime.timedelta behaves neither as a Period nor as a Duration.  In order to use it as a Duration, you need to convert to UTC before doing arithmetic and convert back after.  *That* is what has people up in arms.

ijs



More information about the Datetime-SIG mailing list