﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16899	Wrong offset for Europe/Moscow	igor@…	nobody	"Hello everybody!

in file source:/django/branches/releases/1.3.X/django/utils/tzinfo.py#L40 I see these code:

{{{
59	    def _isdst(self, dt):
60	        tt = (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)
61	        try:
62	            stamp = time.mktime(tt)
63	        except (OverflowError, ValueError):
64	            # 32 bit systems can't handle dates after Jan 2038, and certain
65	            # systems can't handle dates before ~1901-12-01:
66	            #
67	            # >>> time.mktime((1900, 1, 13, 0, 0, 0, 0, 0, 0))
68	            # OverflowError: mktime argument out of range
69	            # >>> time.mktime((1850, 1, 13, 0, 0, 0, 0, 0, 0))
70	            # ValueError: year out of range
71	            #
72	            # In this case, we fake the date, because we only care about the
73	            # DST flag.
74	            tt = (2037,) + tt[1:]
75	            stamp = time.mktime(tt)
76	        tt = time.localtime(stamp)
77	        return tt.tm_isdst > 0
}}}

It's using in 


{{{
40	    def utcoffset(self, dt):
41	        if self._isdst(dt):
42	            return timedelta(seconds=-time.altzone)
43	        else:
44	            return timedelta(seconds=-time.timezone)
}}}

and make wrong value for Europe/Moscow. time.altzone contains proper value.

Why isn't time.daylight checked rather than _isdst?


{{{
$ export | grep TZ
TZ=Europe/Moscow
$ python
>>> import time
>>> time.tzname
('MSK', 'MSK')
>>> time.tzname, time.timezone, time.altzone
(('MSK', 'MSK'), -10800, -14400)
>>> time.localtime(time.mktime((2011, 9, 21, 14, 5, 10, 2, 0, -1))).tm_isdst
0
>>> time.daylight
1
>>>

}}}



"	Bug	closed	Core (Other)	1.3	Normal	fixed	timezone	iigor12	Accepted	0	0	0	0	0	0
