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

Chris Barker chris.barker at noaa.gov
Thu Jul 30 02:31:03 CEST 2015


Sorry this is old, but:

Chris Barker chris.barker at noaa.gov:
> > [that a day is always 24 hours] it's not an assumption, it's a
> definition.
>
> Right, but that's like defining Pi to be three. It's not in accordance
> to reality, and therefore it causes a lot of problems.


No it's not -- not at all. "day" has two definitions, one is 24 hours, and
one is incrementing the date on a calendar (or something like that). Both
definitions are equally valid, we jsut need to be clear about which one we
are using. period.

what I suppose is less clear is which definition is being used by the
timedetla object. I argue that the 24 hr definition is what is used there,
because, well, that's exactly how it is used internally:

In [3]: datetime.timedelta(days=1)
Out[3]: datetime.timedelta(1)

In [4]: datetime.timedelta(seconds=24*60*60)
Out[4]: datetime.timedelta(1)

Perhaps the original intent was that "days" means calendar days, and for
naive datetimes, it turns out to be the same thing, but that is not what
the implementation does, and given that it supports seconds and
microseconds, but not months or years, the API is pretty clearly designed
for timespans, not calendar definitions.

But maybe this will all get cleared up with the Glossary Recently posted.

-CHB



-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150729/3eeeef83/attachment.html>


More information about the Datetime-SIG mailing list