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>
John Keeping committed
Sep 3, 2015 at 22:48 UTC
dc6d782c5d2526b251061daffc3e74d15c8c7095
1 file changed
+3
-3
date.c
+3
-3
@@ -174,6 +174,9 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode)
174
struct tm *tm;
175
static struct strbuf timebuf = STRBUF_INIT;
176
177
+ if (mode->type == DATE_LOCAL)
178
+ tz = local_tzoffset(time);
179
+
180
if (mode->type == DATE_RAW) {
181
strbuf_reset(&timebuf);
182
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)
192
return timebuf.buf;
193
}
194
192
- if (mode->type == DATE_LOCAL)
193
- tz = local_tzoffset(time);
194
-
195
tm = time_to_tm(time, tz);
196
if (!tm) {
197
tm = time_to_tm(0, 0);