A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-April/139088.html below:

[Python-Dev] Status on PEP-431 Timezones

[Python-Dev] Status on PEP-431 TimezonesIsaac Schwabacher ischwabacher at wisc.edu
Thu Apr 9 18:49:51 CEST 2015
On 15-04-09, Alexander Belopolsky  wrote:
> 
> On Thu, Apr 9, 2015 at 11:59 AM, Isaac Schwabacher <ischwabacher at wisc.edu(javascript:main.compose()> 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

All of the datetimes in this example are time zone aware; I meant if someone passed you datetime(2013, 11, 3, 1, 30) without a time zone. astimezone assumes that the input naive time is UTC, which is not the case here.

ijs
More information about the Python-Dev mailing list

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