[Datetime-SIG] The BDFL's take

Lennart Regebro regebro at gmail.com
Wed Jul 29 18:34:19 CEST 2015


On Wed, Jul 29, 2015 at 6:23 PM, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
> On Wed, Jul 29, 2015 at 12:08 PM, Lennart Regebro <regebro at gmail.com> wrote:
>>>>> t = datetime.strptime("2014-11-02T01:30-0400", "%Y-%m-%dT%H:%M%z")
>> ValueError: 'z' is a bad directive in format '%Y-%m-%dT%H:%M%z'
>>
>> Nope, didn't work.
>
> Sorry, but it does work for me:
>
> $ TZ=America/New_York python3
> Python 3.4.3 (default, Jul 20 2015, 12:59:38)
> [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from datetime import *
>>>> t = datetime.strptime("2014-11-02T01:30-0400", "%Y-%m-%dT%H:%M%z")
>
> which version of Python are you using?

Sorry, I thought I was on Python3, but I wasn't. My fault entirely!

Anyway, you can't seriously consider that I have to set the TZ
environment variable as a viable solution, can you?
And in this case the original date and time you have aren't even set
to the right timezone. It's set to a fixed offset of UTC-4.
In my example I use America/New_York the whole time.

//Lennart


More information about the Datetime-SIG mailing list