On Tue, Jan 13, 2009 at 10:20 AM, TK Soh <[email protected]> wrote: > > On Tue, Jan 13, 2009 at 2:12 AM, halim <[email protected]> wrote: > > # HG changeset patch > > # User halim <[email protected]> > > # Date 1231809879 -28800 > > # Node ID f1d13f06c28e29a47d0d20cb79525d86d32a1565 > > # Parent 13746bb5a4b74bb6057ab54eb931604dfcda4671 > > display in localtime > > It's not clear what you try to display. > > > diff -r 13746bb5a4b7 -r f1d13f06c28e contrib/nautilus-thg.py > > --- a/contrib/nautilus-thg.py Fri Jan 09 22:39:56 2009 -0600 > > +++ b/contrib/nautilus-thg.py Tue Jan 13 09:24:39 2009 +0800 > > @@ -21,6 +21,7 @@ > > import tempfile > > import time > > import urllib > > +from tortoise import datetime > > > > TORTOISEHG_PATH = '~/tools/tortoisehg-dev' > > TERMINAL_KEY = '/desktop/gnome/applications/terminal/exec' > > @@ -513,7 +514,7 @@ > > rev = ctx.rev() > > ctx = repo.changectx(rev) > > node = short(ctx.node()) > > - date = time.strftime("%Y-%m-%d %H:%M:%S", > > time.gmtime(ctx.date()[0])) > > + date = datetime.displaytime(ctx.date()) > > hint: util.datestr() > > > parents = '\n'.join([short(p.node()) for p in ctx.parents()]) > > description = ctx.description() > > user = ctx.user() > > diff -r 13746bb5a4b7 -r f1d13f06c28e hggtk/changeset.py > > --- a/hggtk/changeset.py Fri Jan 09 22:39:56 2009 -0600 > > +++ b/hggtk/changeset.py Tue Jan 13 09:24:39 2009 +0800 > > @@ -24,7 +24,7 @@ > > from hgcmd import CmdDialog > > from hglib import toutf, fromutf > > from gtklib import StatusBar > > - > > +from tortoise import datetime > > > > class ChangeSet(GDialog): > > """GTK+ based dialog for displaying repository logs > > @@ -120,7 +120,7 @@ > > > > # TODO: Add toggle for gmtime/localtime > > eob = buf.get_end_iter() > > - date = time.strftime("%Y-%m-%d %H:%M:%S", > > time.gmtime(ctx.date()[0])) > > + date = datetime.displaytime(ctx.date()) > > if self.clipboard: > > self.clipboard.set_text(short(ctx.node())) > > change = str(rev) + ':' + short(ctx.node()) > > diff -r 13746bb5a4b7 -r f1d13f06c28e hggtk/datamine.py > > --- a/hggtk/datamine.py Fri Jan 09 22:39:56 2009 -0600 > > +++ b/hggtk/datamine.py Tue Jan 13 09:24:39 2009 +0800 > > @@ -20,6 +20,7 @@ > > from vis.colormap import AnnotateColorMap, AnnotateColorSaturation > > from vis.treeview import TreeView > > import gtklib > > +from tortoise import datetime > > > > class DataMineDialog(GDialog): > > COL_REVID = 0 > > @@ -148,7 +149,7 @@ > > author = util.shortuser(ctx.user()) > > summary = ctx.description().replace('\0', '') > > summary = summary.split('\n')[0] > > - date = time.strftime("%y-%m-%d %H:%M", time.gmtime(ctx.date()[0])) > > + date = datetime.displaytime(ctx.date()) > > desc = author+'@'+str(rev)+' '+date+' "'+summary+'"' > > self.changedesc[rev] = (desc, author) > > return (desc, author) > > diff -r 13746bb5a4b7 -r f1d13f06c28e hggtk/vis/treemodel.py > > --- a/hggtk/vis/treemodel.py Fri Jan 09 22:39:56 2009 -0600 > > +++ b/hggtk/vis/treemodel.py Tue Jan 13 09:24:39 2009 +0800 > > @@ -10,8 +10,8 @@ > > import gtk > > import gobject > > import re > > -from time import (strftime, gmtime) > > from mercurial import util > > +from tortoise import datetime > > from mercurial.node import short > > from mercurial.hgweb import webutil > > > > @@ -128,7 +128,7 @@ > > else: > > author = toutf(util.shortuser(ctx.user())) > > > > - date = strftime("%Y-%m-%d %H:%M:%S", gmtime(ctx.date()[0])) > > + date = datetime.displaytime(ctx.date()) > > > > wc_parent = revid in self.parents > > head = revid in self.heads > > diff -r 13746bb5a4b7 -r f1d13f06c28e tortoise/datetime.py > > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > > +++ b/tortoise/datetime.py Tue Jan 13 09:24:39 2009 +0800 > > @@ -0,0 +1,15 @@ > > +import time > > + > > +def locatime(date): > > + format = '%b %d %H:%M:%S %Y %1%2' > > + t, tz = date > > + if "%1" in format or "%2" in format: > > + sign = (tz > 0) and "-" or "+" > > + minutes = abs(tz) / 60 > > + format = format.replace("%1", "%c%02d" % (sign, minutes / 60)) > > + format = format.replace("%2", "%02d" % (minutes % 60)) > > + s = time.strftime(format, time.gmtime(float(t) - tz)) > > + return s > > As I mentioned, mercurial already provide the util.datestr() function > to do this. You just need to pass the format we need to it.
Ok. Noted. IIRC, I was just copying from Mercurial. BTW. I will still retain the new tortoisehg/datetime.py so that it easier to maintain if there is a need to dsplay in gmtime. Any concerns? > > > +def displaytime(date): > > + return locatime(date) ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Tortoisehg-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop
