date: check for "local" before anything else

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>
This commit is contained in:
John Keeping 2015-09-03 22:48:58 +01:00 committed by Junio C Hamano
parent f3c1ba5026
commit dc6d782c5d

6
date.c
View File

@ -174,6 +174,9 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode)
struct tm *tm; struct tm *tm;
static struct strbuf timebuf = STRBUF_INIT; static struct strbuf timebuf = STRBUF_INIT;
if (mode->type == DATE_LOCAL)
tz = local_tzoffset(time);
if (mode->type == DATE_RAW) { if (mode->type == DATE_RAW) {
strbuf_reset(&timebuf); strbuf_reset(&timebuf);
strbuf_addf(&timebuf, "%lu %+05d", time, tz); 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; return timebuf.buf;
} }
if (mode->type == DATE_LOCAL)
tz = local_tzoffset(time);
tm = time_to_tm(time, tz); tm = time_to_tm(time, tz);
if (!tm) { if (!tm) {
tm = time_to_tm(0, 0); tm = time_to_tm(0, 0);