US/Eastern offset

Skip Montanaro skip.montanaro at gmail.com
Fri Dec 23 14:24:19 EST 2016


Okay, problem solved. My thanks to Chris Barker over on the Anaconda group
for help. (I originally thought there might be something amiss with the
pytz package in Anaconda, as our older non-Anaconda Python seemed not to
have the problem.) It turns out to be a problem I solved several years ago
at my previous employer (but forgot I had solved, and for perhaps obvious
reasons, I wasn't able to take my solution with me - another advantage for
open source...). It all boils down to the difference between these two
operations:

now.replace(tzinfo=eastern_tz)
eastern_tz.astimezone(now)

where now is datetime.datetime.now() and eastern_tz is
pytz.timezone("America/Eastern").

So, my problem has (again) been solved. A colleague here has suggested arrow
<https://pypi.python.org/pypi/arrow/0.10.0> as an alternative to
datetime+pytz, which I will look into during the slow period next week.

Skip



More information about the Python-list mailing list