Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Python 3.7.3, MacOS 10.14.5
- ```>>> import time, datetime
- >>> 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.
- ```>>> gmt
- 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).
- ## Python 3.7.1, Windows 7
- ```
- >>> 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.
- ## Python 3.6.4, Amazon Linux
- ```>>> epoch = int(datetime.datetime.now().timestamp())
- >>> gmt = time.gmtime(epoch)
- >>> gmt.tm_zone
- 'GMT'
- >>> time.strftime('%Z', gmt)
- 'GMT'
- >>> time.strftime('%z', gmt)
- '+0000'
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement