time zone for commit recorded incorrectly

Bug #77588 reported by James Henstridge
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
James Henstridge

Bug Description

Western Australia recently adopted daylight saving time, however Bazaar continues to record the time zone of my commits as +0800 even though I've installed the time zone data update and the time is being reported in DST.

Looking at the local_time_offset() function in bzrlib.osutils, I see that it is using time.timezone and time.altzone to determine the the offset. However, both of these variables are set to -28800 on my system so it uses +0800 for DST.

The implementation of these constants for Linux systems is roughly as follows:
 1. take the current time and round it to the start of the year.
 2. record the UTC offset for local time at this point
 3. record the UTC offset for local time half a year after this point
 4. the lower offset is the main time zone and the higher offset is the DST zone.

Unfortunately, since we didn't have DST in January 2006 or July 2006, both values are the same.

A better implementation for local_time_offset() would be something like this:

    def local_time_offset(t=None):
        """Return offset of local zone from GMT, either at present or at time t."""
        if t is None:
            t = time.time()
        local = datetime.datetime.fromtimestamp(t)
        utc = datetime.datetime.utcfromtimestamp(t)
        offset = local - utc
        return offset.days * 86400 + offset.seconds

This should avoid the use of those constants, and give correct results for past or future times that use different rules to the present time.

description: updated
Revision history for this message
John A Meinel (jameinel) wrote :

James has implemented a fix for this, it is pending review and should be in 0.14

Changed in bzr:
assignee: nobody → jamesh
importance: Undecided → Medium
status: Unconfirmed → Fix Committed
Revision history for this message
Alexander Belchenko (bialix) wrote :

merged in bzr.dev as revno.2222

Changed in bzr:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.