Edgewall Software
Modify

Opened 9 years ago

Closed 6 years ago

#12454 closed defect (fixed)

Timezone of MercurialChangeset's date is wrong

Reported by: Jun Omae Owned by:
Priority: normal Milestone: plugin - mercurial
Component: plugin/mercurial Version: 0.12-stable
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fix timezone.

API Changes:
Internal Changes:

Description

$ TZ=America/St_Johns date +'%x %X %z'
04/12/2016 01:58:26 PM -0230
$ TZ=America/St_Johns hg add test.txt
$ TZ=America/St_Johns hg commit -m 'half-hour timezone'
$ hg log -r 0
changeset:   0:ffda17928997
tag:         tip
user:        Jun Omae <jun66j5@gmail.com>
date:        Tue Apr 12 13:58:55 2016 -0230
summary:     half-hour timezone
$
$ ~/venv/trac/1.0.10/bin/python
Python 2.5.6 (r256:88840, Oct 21 2014, 22:49:55)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from trac.env import Environment
>>> env = Environment('/home/jun66j5/var/trac/1.0-sqlite')
>>> repos = env.get_repository('test.hg')
>>> cset = repos.get_changeset(0)
>>> cset.date
datetime.datetime(2016, 4, 12, 18, 58, 55, tzinfo=<FixedOffset "GMT 2:00" 2:30:00>)

The timezone offset should be -2:30.

Attachments (0)

Change History (3)

comment:1 by Jun Omae, 9 years ago

  • tracext/hg/backend.py

    a b  
    594594
    595595    def from_hg_time(self, timeinfo):
    596596        time, tz = timeinfo
    597         tzinfo = FixedOffset(tz / 60, 'GMT %d:00' % (tz / 3600))
     597        tz = -tz
     598        tzmin = tz / 60
     599        if tz == 0:
     600            name = 'GMT'
     601        else:
     602            name = 'GMT ' + ('+' if tz >= 0 else '-') + \
     603                   '%02d:%02d' % divmod(abs(tzmin), 60)
     604        tzinfo = FixedOffset(tzmin, name)
    598605        return datetime.fromtimestamp(time, tzinfo)
    599606
    600607    def changectx(self, rev=None):

After the above patch, the date property would be the same with date field in hg log -r0.

>>> cset = repos.get_changeset(0)
>>> cset.date
datetime.datetime(2016, 4, 12, 13, 58, 55, tzinfo=<FixedOffset "GMT -02:30" -1 day, 21:30:00>)
>>> cset.date.isoformat()
'2016-04-12T13:58:55-02:30'
>>>

comment:2 by Jun Omae, 9 years ago

Summary: Timezone of changeset date is wrongTimezone of MercurialChangeset's date is wrong

comment:3 by Peter Suter, 6 years ago

Milestone: plugin - mercurial
Release Notes: modified (diff)
Resolution: fixed
Status: newclosed

Pushed comment:1 changes with test in [57/mercurial-plugin].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.