GNOME Bugzilla – Bug 172098
ITime doesn't consider Daylight Savings Time
Last modified: 2005-05-07 06:22:50 UTC
The Control uses time.timezone as offset, but time.timezone returns the non-DST offset. Hence non-DST time is used always. Consider setting the timezone and getting the time with time.localtime().
This control is very buggy and we don't have time to fix it. If you want to contribute patches we'd highly appreciate that.
Resolve: In file __init__.py: change __set_timezone to def __set_timezone(self, tz): self.__timezone = tz self._update("timezone") change __get_time_and_date to def __get_time_and_date(self): if (self.__timezone): have_tz = "TZ" in os.environ old_tz = os.environ.get("TZ", "") os.environ["TZ"] = self.__timezone time.tzset() tme = time.localtime() if (not have_tz): del os.environ["TZ"] else: os.environ["TZ"] = old_tz time.tzset() else: tme = time.localtime() return tme
A diff would be really handy, thanks. --> diff -u old_file new_file
Created attachment 46081 [details] [review] Daylight Savings Patch Resolves the bug.
Thanks for your patch. It seems to work well and is in CVS now. I just don't understand why it does the fix the bug, though; haven't looked at it too closely. Could you please enlighten me? :)
The problem was the usage of 'time.timezone' which returns the offset of the non-DST timezone. 'time.localtime' however returns 'time.gmtime()' converted to local time which is DST-correct. Alas, 'time.daylight' cannot be used because it return nonzero if a DST timezone is defined and - as the the Python library reference puts it - DST is an adjustment of the timezone by usually one hour during part of the year and DST rules are magic. Thus a nonzero value doesn't suffice to get the correct offset.