>
> [Tim Peters]
>
> >
> > Guido's reply gave a clearer invariant:
> >
> >     dt.timestamp() ==
> >     dt.astimezone(utc).timestamp() ==
> >     dt.astimezone(<any other tz>).timestamp()
>
> [ Nick Coghlan]

> Might it be worth mentioning Guido's invariant in the section of the PEP
> about the timestamp method?
>
The case of missing time in Guido's invariant is rather subtle.  What is
happening is that .timestamp()  and .astimezone(..) methods use the same
"normalization" to interpret what dt means.  This is not obvious in the
expression above.  Particularly in dt.astimezone(<any other
tz>).timestamp().  Here, if instead of <any other tz> we pass dt.tzinfo,
then .astimezone(..) becomes a noop and "normalization" happens in
.timestamp().  I don't think exposing all this in the PEP will help.  Let's
return to this when it is time to write the reference documentation.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to