git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Fonseca <fonseca@diku.dk>
To: Aneesh Kumar <aneesh.kumar@gmail.com>
Cc: git@vger.kernel.org, junkio@cox.net
Subject: [PATCH] Fix date display
Date: Thu, 2 Feb 2006 13:21:24 +0100	[thread overview]
Message-ID: <20060202122124.GB9756@diku.dk> (raw)
In-Reply-To: <cc723f590602012033w41b49b2ao4423707702086739@mail.gmail.com>

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<ident>.*) (?P<epoch>\d+) (?P<tz>[+-]\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

      parent reply	other threads:[~2006-02-02 12:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-02  4:33 gitview 0.3 Aneesh Kumar
2006-02-02  6:13 ` Junio C Hamano
2006-02-02  7:15   ` Aneesh Kumar
2006-02-02 16:03   ` Aneesh Kumar
2006-02-03  5:03     ` Junio C Hamano
2006-02-03  9:20       ` Andreas Ericsson
2006-02-02 12:21 ` Jonas Fonseca [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060202122124.GB9756@diku.dk \
    --to=fonseca@diku.dk \
    --cc=aneesh.kumar@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).