summaryrefslogtreecommitdiff
path: root/date.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-09-08 21:35:52 -0700
committerJunio C Hamano <gitster@pobox.com>2016-09-08 21:35:52 -0700
commitf59c6e6ccb1386f0fdde2753f62536dfd3343118 (patch)
treec270485f41e5100c47da29fe0e5b6e432bc438ba /date.c
parent7f5885ad2abfbf9b760e2f32f70537d1c380734d (diff)
parent442f6fd3d6272b1c7b92e0a24b4be1cf162b4d04 (diff)
downloadgit-f59c6e6ccb1386f0fdde2753f62536dfd3343118.tar.xz
Merge branch 'jk/reflog-date' into maint
The reflog output format is documented better, and a new format --date=unix to report the seconds-since-epoch (without timezone) has been added. * jk/reflog-date: date: clarify --date=raw description date: add "unix" format date: document and test "raw-local" mode doc/pretty-formats: explain shortening of %gd doc/pretty-formats: describe index/time formats for %gd doc/rev-list-options: explain "-g" output formats doc/rev-list-options: clarify "commit@{Nth}" for "-g" option
Diffstat (limited to 'date.c')
-rw-r--r--date.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/date.c b/date.c
index 4c7aa9ba85..a996331f5b 100644
--- a/date.c
+++ b/date.c
@@ -177,6 +177,12 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode)
struct tm *tm;
static struct strbuf timebuf = STRBUF_INIT;
+ if (mode->type == DATE_UNIX) {
+ strbuf_reset(&timebuf);
+ strbuf_addf(&timebuf, "%lu", time);
+ return timebuf.buf;
+ }
+
if (mode->local)
tz = local_tzoffset(time);
@@ -792,6 +798,8 @@ static enum date_mode_type parse_date_type(const char *format, const char **end)
return DATE_NORMAL;
if (skip_prefix(format, "raw", end))
return DATE_RAW;
+ if (skip_prefix(format, "unix", end))
+ return DATE_UNIX;
if (skip_prefix(format, "format", end))
return DATE_STRFTIME;