[Python-Dev] Status on PEP-431 Timezones (original) (raw)
Isaac Schwabacher ischwabacher at wisc.edu
Thu Apr 9 21:39:09 CEST 2015
- Previous message (by thread): [Python-Dev] Status on PEP-431 Timezones
- Next message (by thread): [Python-Dev] Status on PEP-431 Timezones
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 15-04-09, Alexander Belopolsky wrote:
On Thu, Apr 9, 2015 at 3:07 PM, Isaac Schwabacher <ischwabacher at wisc.edu(javascript:main.compose()> wrote: > > No, it does not. Please read the documentation: "self must be aware (self.tzinfo must not be None, and self.utcoffset() must not return None)." > > Whoops, you're right. But that's even worse-- it doesn't give you a way to convert a naive datetime at all. Currently the only way from "2013-11-03 01:30:00" to "2013-11-03 01:30:00-0500 America/Chicago" is still datetime.replace().
Well, you are right, but at least we do have a localtime utility hidden in the email package: >>> from datetime import * >>> from email.utils import localtime >>> print(localtime(datetime.now())) 2015-04-09 15:19:12.840000-04:00 You can read <http://bugs.python.org/issue9527> for the reasons it did not make into datetime.
But that's restricted to the system time zone. Nothing good ever comes from the system time zone...
ijs
- Previous message (by thread): [Python-Dev] Status on PEP-431 Timezones
- Next message (by thread): [Python-Dev] Status on PEP-431 Timezones
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]