date: check for "local" before anything else
authorJohn Keeping <john@keeping.me.uk>
Thu, 3 Sep 2015 21:48:58 +0000 (22:48 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Sep 2015 22:42:18 +0000 (15:42 -0700)
In a following commit we will make "local" orthogonal to the format.
Although this will not apply to "relative", which does not use the
timezone, it applies to all other formats so move the timezone
conversion to the start of the function.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
date.c
diff --git a/date.c b/date.c
index 8f9156909b8d9d2cad6425aa44deebdcd01b2168..9f0a5ddf6cfe773915034f7068b2e050a44c9178 100644 (file)
--- a/date.c
+++ b/date.c
@@ -174,6 +174,9 @@ 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_LOCAL)
+               tz = local_tzoffset(time);
+
        if (mode->type == DATE_RAW) {
                strbuf_reset(&timebuf);
                strbuf_addf(&timebuf, "%lu %+05d", time, tz);
@@ -189,9 +192,6 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode)
                return timebuf.buf;
        }
 
-       if (mode->type == DATE_LOCAL)
-               tz = local_tzoffset(time);
-
        tm = time_to_tm(time, tz);
        if (!tm) {
                tm = time_to_tm(0, 0);