<div dir="ltr">Most UNIX platforms extend struct tm to include tm_gmtoff and tm_zone fields that contain the current UTC offset in seconds and the zone abbreviation.<br><br>Python has been making these fields available as attributes of time.struct_time [1] since version 3.3, but only on platforms that support them in the C library.<div><br></div><div><div>>>> import time</div><div>>>> t = time.localtime()</div><div>>>> t.tm_gmtoff</div><div>-14400</div><div>>>> t.tm_zone</div><div>'EDT'</div><div><br></div><div>I propose that we make these attributes available on all platforms by computing their values when they are not available in struct tm.</div><div><br></div><div>The tm_gmtoff value is easy to compute by comparing localtime() to gmtime():</div><div><br></div><div><div>>>> u = time.gmtime(time.mktime(t))</div><div>>>> from calendar import timegm</div><div>>>> timegm(t) - timegm(u)</div><div>-14400</div></div><div><br></div><div>and tm_zone can be computed by calling strftime() with a '%Z' directive.</div><div><br></div><div><div>>>> time.strftime('%Z', t)</div><div>'EDT'</div></div><div><br></div><div>What does the group think?</div><br>[1]: <a href="https://docs.python.org/3/library/time.html#time.struct_time">https://docs.python.org/3/library/time.html#time.struct_time</a><br></div></div>