[Datetime-SIG] The BDFL's take

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Jul 29 17:50:46 CEST 2015


On Wed, Jul 29, 2015 at 11:33 AM, Lennart Regebro <regebro at gmail.com> wrote:
> On Wed, Jul 29, 2015 at 5:18 PM, Alexander Belopolsky
> <alexander.belopolsky at gmail.com> wrote:
>> You snipped my example and I won't repeat it for the umpteen time, but
>> it did not involve converting the timezone to UTC at all.
>
> You asked for examples of problem, I gave you two example of problems.

The problems you gave, are perfectly solvable using current Python 3 standard
library.  For some reason you insist on solving them using third party
tools that
are not designed for those particular tasks.

You want to know what was the local time in New York one astronomical hour
after  2014-11-02T01:30-0400 - set TZ=America/New_York and do this:

>>> t = datetime.strptime("2014-11-02T01:30-0400", "%Y-%m-%dT%H:%M%z")
>>> u = (t+timedelta(hours=1))
>>> u.astimezone().strftime("%Y-%m-%dT%H:%M%z")
'2014-11-02T01:30-0500'

What do you see lacking in this solution?  The only thing I see worth improving
is adding support for more than one local timezone so that I could ask for

>>> u.astimezone('Australia/Melbourne')

without having to switch my global TZ settings.


More information about the Datetime-SIG mailing list