>>> epoch = int(datetime.datetime.now().timestamp())
>>> epoch
1567872682
>>> gmt = time.gmtime(epoch)
>>> gmt.tm_zone
'UTC'
>>> time.strftime('%Z', gmt)
'UTC'
>>> time.strftime('%z', gmt)
'-0500'
I'm currently at -0400 (EDT)
and my best guess is that because the tm_isdst
flag is set to false, it's interpreting my Eastern time zone as it would be when we're no longer on DST.
time.struct_time(tm_year=2019, tm_mon=9, tm_mday=7, tm_hour=16, tm_min=11, tm_sec=22, tm_wday=5, tm_yday=250, tm_isdst=0)
In my Anaconda install on Windows 7, it's worse (or maybe better: more consistently broken).
>>> gmt.tm_zone
'UTC'
>>> time.strftime('%Z', gmt)
'Eastern Standard Time'
>>> time.strftime('%z', gmt)
'-0500'
On Amazon Linux, Python 3.6, the system works properly. In fact it addresses another problem with the above: technically UTC isn't a time zone, while GMT is.
>>> gmt = time.gmtime(epoch)
>>> gmt.tm_zone
'GMT'
>>> time.strftime('%Z', gmt)
'GMT'
>>> time.strftime('%z', gmt)
'+0000'