Akira Li added the comment: I agree that time.timezone, time.altzone is not enough in the general case. Because UTC offset may be different at different dates for reasons unrelated to DST transitions therefore any solution that doesn't take into account a given date/time into account will fail.
*Nothing* works in the general case. Nothing. But it doesn't mean that the current behaviour of time.timezone can't be improved for this particular use-case: lt = time.localtime() # in a short-lived script assertEqual(lt.tm_gmtoff, -[time.timezone, time.altzone][lt.tm_isdst]) The test checks values for the current time (time.localtime()). It should work in *most* cases if time.timezone/altzone have correct values at import time. Perhaps synchronizing time.timezone with C timezone variable as I've mentioned before http://bugs.python.org/issue22798 may fix this issue too. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22799> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com