[issue22799] wrong time.timezone

Akira Li report at bugs.python.org
Wed Jan 28 19:55:49 CET 2015


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 <report at bugs.python.org>
<http://bugs.python.org/issue22799>
_______________________________________


More information about the Python-bugs-list mailing list