Support output ISO 8601 format dates
Support output of full ISO 8601 style dates in e.g. git log and other places that use interpolation for formatting. Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Robin Rosenberg committed
Jul 14, 2007 at 01:00 UTC
ee8f838e0346751b21250f8d107049829b855a98
4 files changed
+15
-2
Documentation/pretty-formats.txt
+2
@@ -106,12 +106,14 @@ The placeholders are:
106
- '%aD': author date, RFC2822 style
107
- '%ar': author date, relative
108
- '%at': author date, UNIX timestamp
109
+- '%ai': author date, ISO 8601 format
110
- '%cn': committer name
111
- '%ce': committer email
112
- '%cd': committer date
113
- '%cD': committer date, RFC2822 style
114
- '%cr': committer date, relative
115
- '%ct': committer date, UNIX timestamp
116
+- '%ci': committer date, ISO 8601 format
117
- '%e': encoding
118
- '%s': subject
119
- '%b': body
cache.h
+1
-1
@@ -409,7 +409,7 @@ extern void *read_object_with_reference(const unsigned char *sha1,
409
unsigned long *size,
410
unsigned char *sha1_ret);
411
412
-enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL };
412
+enum date_mode { DATE_NORMAL = 0, DATE_RELATIVE, DATE_SHORT, DATE_LOCAL, DATE_ISO8601 };
413
const char *show_date(unsigned long time, int timezone, enum date_mode mode);
414
const char *show_rfc2822_date(unsigned long time, int timezone);
415
int parse_date(const char *date, char *buf, int bufsize);
commit.c
+5
-1
@@ -781,6 +781,7 @@ static void fill_person(struct interp *table, const char *msg, int len)
781
interp_set_entry(table, 2, show_date(date, tz, 0));
782
interp_set_entry(table, 3, show_rfc2822_date(date, tz));
783
interp_set_entry(table, 4, show_date(date, tz, 1));
784
+ interp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));
785
}
786
787
static long format_commit_message(const struct commit *commit,
@@ -799,12 +800,14 @@ static long format_commit_message(const struct commit *commit,
800
{ "%aD" }, /* author date, RFC2822 style */
801
{ "%ar" }, /* author date, relative */
802
{ "%at" }, /* author date, UNIX timestamp */
803
+ { "%ai" }, /* author date, ISO 8601 */
804
{ "%cn" }, /* committer name */
805
{ "%ce" }, /* committer email */
806
{ "%cd" }, /* committer date */
807
{ "%cD" }, /* committer date, RFC2822 style */
808
{ "%cr" }, /* committer date, relative */
809
{ "%ct" }, /* committer date, UNIX timestamp */
810
+ { "%ci" }, /* committer date, ISO 8601 */
811
{ "%e" }, /* encoding */
812
{ "%s" }, /* subject */
813
{ "%b" }, /* body */
@@ -821,10 +824,11 @@ static long format_commit_message(const struct commit *commit,
824
IPARENTS, IPARENTS_ABBREV,
825
IAUTHOR_NAME, IAUTHOR_EMAIL,
826
IAUTHOR_DATE, IAUTHOR_DATE_RFC2822, IAUTHOR_DATE_RELATIVE,
824
- IAUTHOR_TIMESTAMP,
827
+ IAUTHOR_TIMESTAMP, IAUTHOR_ISO8601,
828
ICOMMITTER_NAME, ICOMMITTER_EMAIL,
829
ICOMMITTER_DATE, ICOMMITTER_DATE_RFC2822,
830
ICOMMITTER_DATE_RELATIVE, ICOMMITTER_TIMESTAMP,
831
+ ICOMMITTER_ISO8601,
832
IENCODING,
833
ISUBJECT,
834
IBODY,
date.c
+7
@@ -137,6 +137,13 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
137
if (mode == DATE_SHORT)
138
sprintf(timebuf, "%04d-%02d-%02d", tm->tm_year + 1900,
139
tm->tm_mon + 1, tm->tm_mday);
140
+ else if (mode == DATE_ISO8601)
141
+ sprintf(timebuf, "%04d-%02d-%02d %02d:%02d:%02d %+05d",
142
+ tm->tm_year + 1900,
143
+ tm->tm_mon + 1,
144
+ tm->tm_mday,
145
+ tm->tm_hour, tm->tm_min, tm->tm_sec,
146
+ tz);
147
else
148
sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d%c%+05d",
149
weekday_names[tm->tm_wday],