* add UTC option for pretty-formats
@ 2010-10-27 1:32 Jeff Carr
2010-11-08 8:41 ` Jonathan Nieder
0 siblings, 1 reply; 2+ messages in thread
From: Jeff Carr @ 2010-10-27 1:32 UTC (permalink / raw)
To: git
[-- 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:
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: add UTC option for pretty-formats
2010-10-27 1:32 add UTC option for pretty-formats Jeff Carr
@ 2010-11-08 8:41 ` Jonathan Nieder
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Nieder @ 2010-11-08 8:41 UTC (permalink / raw)
To: Jeff Carr; +Cc: git
Hi Jeff,
Jeff Carr wrote:
> --- 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
Why not:
TZ=UTC git log --format=%ad --date=local
or something like:
git log --format=%AD(rfc2822,tz=UTC)
? In other words, why should we provide this feature with date=rfc
dates and not date=iso ones?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-08 8:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-27 1:32 add UTC option for pretty-formats Jeff Carr
2010-11-08 8:41 ` Jonathan Nieder
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).