After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 172098 - ITime doesn't consider Daylight Savings Time
ITime doesn't consider Daylight Savings Time
Status: RESOLVED FIXED
Product: gDesklets
Classification: Deprecated
Component: sensors/controls
svn/bzr repository
Other Linux
: Normal normal
: ---
Assigned To: gDesklets Maintainers
gDesklets Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-03-30 13:33 UTC by Joerg Leis
Modified: 2005-05-07 06:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Daylight Savings Patch (1.46 KB, patch)
2005-05-06 07:16 UTC, Joerg Leis
none Details | Review

Description Joerg Leis 2005-03-30 13:33:33 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().
Comment 1 Christian Meyer 2005-03-30 13:43:34 UTC
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.
Comment 2 Joerg Leis 2005-03-30 21:08:49 UTC
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
Comment 3 Christian Meyer 2005-03-30 21:19:25 UTC
A diff would be really handy, thanks.
--> diff -u old_file new_file
Comment 4 Joerg Leis 2005-05-06 07:16:47 UTC
Created attachment 46081 [details] [review]
Daylight Savings Patch

Resolves the bug.
Comment 5 Martin Grimme 2005-05-06 21:54:29 UTC
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? :)
Comment 6 Joerg Leis 2005-05-07 06:22:50 UTC
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.