US/Eastern offset

Ian Kelly ian.g.kelly at gmail.com
Thu Dec 22 17:19:08 EST 2016


On Thu, Dec 22, 2016 at 2:49 PM, Skip Montanaro
<skip.montanaro at gmail.com> wrote:
> In a small application I realized I needed all my timestamps to have
> timezone info. Some timestamp strings come in with no TZ markings, but
> I know they are US/Eastern. so, I built one:
>
>>>> import pytz
>>>> tz = pytz.timezone("US/Eastern")
>>>> tz
> <DstTzInfo 'US/Eastern' LMT-1 day, 19:04:00 STD>
>
> What's with those extra four minutes? Here is one such timestamp I
> logged in my app:
>
>     2016-12-22T20:35:05-04:56
>
> WTF? Has my brain turned to mush, and the people in New York now move
> so fast that they are four minutes closer to their London counterparts
> than they used to be?

Not sure, but LMT suggests that it's coming up with a Local Mean Time
zone rather than the proper EST zone. The four minute offset suggests
that this is a local mean time for a meridian one degree east of EST.
I'm wondering if it's using some historical definition for the time
zone's date-neutral repr. What do you get if you try using it to
convert a UTC time? E.g.:

py> dt = pytz.utc.localize(datetime(2016, 12, 23))
py> dt.astimezone(pytz.timezone('US/Eastern'))
datetime.datetime(2016, 12, 22, 19, 0, tzinfo=<DstTzInfo 'US/Eastern'
EST-1 day, 19:00:00 STD>)


More information about the Python-list mailing list