[Datetime-SIG] Timeline arithmetic?

Tim Peters tim.peters at gmail.com
Mon Sep 7 22:04:58 CEST 2015


[Guido]
> Again, I can't follow this because I don't recall the definition of model A.

Pretty much that an aware datetime is exactly and only a spelling of a
POSIX timestamp.  Various things follow from that, such that timeline
arithmetic is overwhelmingly most natural in that model.

> But here's a fundamental difference between a timezone-aware datetime and a
> POSIX stamp (apart from epoch, range and precision). The difference applies
> only to "political" timezones, which may change offsets or DST rules. The
> difference is that an aware datetime says "in timezone Z, when the local
> clock says T". If T is in the future, politicians may change the mapping of
> T to UTC in Z. However, politics can't change the meaning of a POSIX
> timestamp. Even for T in the (distant) past the mapping may still change,
> when research finds that the rules for Z were different at some year in the
> past than they were presumed. So, to me, an aware datetime *fundamentally*
> differs from a POSIX timestamp, and even from a pair composed of a POSIX
> timestamp plus a tzinfo object.

The last is unclear to me, unless it's a conceptual distinction with
no visible consequences.  An aware datetime _is_ a <naive datetime,
tzinfo> pair, and there's a natural bijection between naive datetimes
and POSIX timestamps (across all instants both can represent).  That a
time_t is "in UTC" is as inconsequential for this purpose as that to
compute 3+1 I happen to have 3 turtles in mind rather than the
distance in meters to my refrigerator ;-)  I do see that it's useless
conceptual baggage (even potentially misleading) to drag UTC into it
at all.


> (POSIX timestamps are however embeddable in datetimes by using a fixed-offset tzinfo.)

Or use a naive datetime, for all practical purposes.


More information about the Datetime-SIG mailing list