[Python-Dev] Status on PEP-431 Timezones (original) (raw)

Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Apr 9 18:20:50 CEST 2015


On Thu, Apr 9, 2015 at 11:59 AM, Isaac Schwabacher <ischwabacher at wisc.edu> wrote:

I just looked through the datetime documentation, and it looks like the currently blessed way of creating an aware datetime from a naive local datetime and a tzinfo is datetime.replace, which is too low level to handle the job.

Not quite. That's how you would create a UTC datetime, but from there you can get to your local timezone by calling astimezone() with no arguments:

print(datetime.now(timezone.utc).astimezone()) 2015-04-09 12:16:58.576272-04:00 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150409/0a1d2779/attachment.html>



More information about the Python-Dev mailing list