git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Carr <basilarchia@gmail.com>
To: git@vger.kernel.org
Subject: add UTC option for pretty-formats
Date: Tue, 26 Oct 2010 18:32:21 -0700	[thread overview]
Message-ID: <AANLkTikN_B-bUTyy5440AVwTD=KkUWdkf_ukRszTuhYG@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 66 bytes --]

Adds displaying author and commit times in UTC using %au and %cu.

[-- Attachment #2: git_format_utc.diff --]
[-- Type: text/x-patch, Size: 2591 bytes --]

commit 99a429c3e369ca76113a8642f80245d7644b9a2f
Author: Jeff Carr <jcarr@basilarchia@gmail.com>
Date:   Tue Oct 26 18:25:06 2010 -0700

    Adds a UTC option to the pretty formats

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 561cc9f..df56147 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -114,6 +114,7 @@ The placeholders are:
 - '%ar': author date, relative
 - '%at': author date, UNIX timestamp
 - '%ai': author date, ISO 8601 format
+- '%au': author date, UTC
 - '%cn': committer name
 - '%cN': committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1])
 - '%ce': committer email
@@ -123,6 +124,7 @@ The placeholders are:
 - '%cr': committer date, relative
 - '%ct': committer date, UNIX timestamp
 - '%ci': committer date, ISO 8601 format
+- '%cu': committer date, UTC
 - '%d': ref names, like the --decorate option of linkgit:git-log[1]
 - '%e': encoding
 - '%s': subject
diff --git a/builtin/blame.c b/builtin/blame.c
index 1015354..33b04e6 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2343,6 +2343,9 @@ parse_done:
 	case DATE_SHORT:
 		blame_date_width = sizeof("2006-10-19");
 		break;
+	case DATE_UTC:
+		blame_date_width = sizeof("Fri Mar 12 20:18:53 UTC 2010");
+		break;
 	case DATE_RELATIVE:
 		/* "normal" is used as the fallback for "relative" */
 	case DATE_LOCAL:
diff --git a/cache.h b/cache.h
index 33decd9..a46965d 100644
--- a/cache.h
+++ b/cache.h
@@ -812,6 +812,7 @@ enum date_mode {
 	DATE_LOCAL,
 	DATE_ISO8601,
 	DATE_RFC2822,
+	DATE_UTC,
 	DATE_RAW
 };
 
diff --git a/date.c b/date.c
index 00f9eb5..64bbce0 100644
--- a/date.c
+++ b/date.c
@@ -157,6 +157,17 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
 		return timebuf;
 	}
 
+	if (mode == DATE_UTC) {
+		tm = time_to_tm(time, 0);
+		sprintf(timebuf, "%.3s %.3s %2d %02d:%02d:%02d UTC %d",
+			weekday_names[tm->tm_wday],
+			month_names[tm->tm_mon],
+			tm->tm_mday,
+			tm->tm_hour, tm->tm_min, tm->tm_sec,
+			tm->tm_year + 1900);
+		return timebuf;
+	}
+
 	if (mode == DATE_RELATIVE) {
 		struct timeval now;
 		gettimeofday(&now, NULL);
diff --git a/pretty.c b/pretty.c
index f85444b..9903a12 100644
--- a/pretty.c
+++ b/pretty.c
@@ -531,6 +531,9 @@ static size_t format_person_part(struct strbuf *sb, char part,
 	case 'i':	/* date, ISO 8601 */
 		strbuf_addstr(sb, show_date(date, tz, DATE_ISO8601));
 		return placeholder_len;
+	case 'u':	/* date, UTC */
+		strbuf_addstr(sb, show_date(date, tz, DATE_UTC));
+		return placeholder_len;
 	}
 
 skip:

             reply	other threads:[~2010-10-27  1:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27  1:32 Jeff Carr [this message]
2010-11-08  8:41 ` add UTC option for pretty-formats Jonathan Nieder

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='AANLkTikN_B-bUTyy5440AVwTD=KkUWdkf_ukRszTuhYG@mail.gmail.com' \
    --to=basilarchia@gmail.com \
    --cc=git@vger.kernel.org \
    /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).