On Tue, Sep 22, 2015 at 3:01 AM, Nick Coghlan <ncoghlan at gmail.com> wrote: > ... for times that > don't exist, "dt.astimezone(utc).astimezone(dt.tzinfo)" will normalise > them to be a time that actually exists in the original time zone, and > that normalisation also effectively happens when calling > "dt.timestamp()". > Yes. In fact, if you consider the canonical bijection between timestamps and datetimes (t = EPOCH + s * timedelta(0, 1); s = (t - EPOCH) / timedelta(0, 1)), t.astimezone(utc) and t.timestamp() become the same up to some annoying numerical details. The same logic applies to u.astimezone(tzinfo) and datetime.fromtimestamp(s). Note that I deliberately did not mark the units on the sketches: you can think of the UTC axis to be labeled by datetimes or by numeric timestamps. Note that dt != dt.astimezone(utc).astimezone(dt.tzinfo) is one way to detect that dt is in a gap, but I recommend (dt.replace(fold=0).utcoffset() > dt.replace(fold=1).utcoffset().) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150922/d28e4e3d/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4