From: Jonas Fonseca Date: Thu, 02 Feb 2006 12:21:24 GMT Subject: [PATCH] Fix date display Message-ID: <20060202122124.GB9756@diku.dk> In-Reply-To: Hello, Here is a patch that uses the tz info for setting commit dates. --- a/gitview 2006-02-02 12:29:05.000000000 +0100 +++ b/gitview 2006-02-02 12:28:24.000000000 +0100 @@ -31,6 +31,7 @@ have_gtksourceview = False print "Running without gtksourceview module" +re_ident = re.compile('(author|committer) (?P.*) (?P\d+) (?P[+-]\d{4})') def list_to_string(args, skip): count = len(args) @@ -43,6 +44,16 @@ return str_arg +def show_date(epoch, tz): + secs = float(epoch) + tzsecs = float(tz[1:3]) * 3600 + tzsecs += float(tz[3:5]) * 60 + if (tz[0] == "+"): + secs += tzsecs + else: + secs -= tzsecs + return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(secs)) + class CellRendererGraph(gtk.GenericCellRenderer): """Cell renderer for directed graph. @@ -277,22 +288,15 @@ if (m != None): continue - - m = re.match("author", line) - if (m != None ): - patch_author = re.split(" ", line) - self.author = list_to_string(patch_author[1:-2], 0) - self.date = time.strftime("%Y-%m-%d %H:%M:%S", - time.gmtime(float(patch_author[-2]))) - continue - - m = re.match("committer", line) - if (m != None ): - patch_committer = re.split(" ", line) - self.committer = list_to_string(patch_committer[1:-2], 0) - self.commit_date = time.strftime("%Y-%m-%d %H:%M:%S", - time.gmtime(float(patch_committer[-2]))) - continue + m = re_ident.match(line) + if (m != None): + date = show_date(m.group('epoch'), m.group('tz')) + if m.group(1)[0] == 'a': + self.author = m.group('ident') + self.date = date + else: + self.committer = m.group('ident') + self.commit_date = date def get_message(self, with_diff=0): if (with_diff == 1): -- Jonas Fonseca