t0302 & t3900: add forgotten quotes
[gitweb.git] / date.c
diff --git a/date.c b/date.c
index 7c9f76998ac7a00fb5f8781dd8e460f899edbfac..a996331f5b33703c9f70844c6b49453ec39d16a7 100644 (file)
--- a/date.c
+++ b/date.c
@@ -74,6 +74,8 @@ static int local_tzoffset(unsigned long time)
        localtime_r(&t, &tm);
        t_local = tm_to_time_t(&tm);
 
+       if (t_local == -1)
+               return 0; /* error; just use +0000 */
        if (t_local < t) {
                eastwest = -1;
                offset = t - t_local;
@@ -175,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);
 
@@ -790,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;