Skip to content

Commit

Permalink
date: check for "local" before anything else
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
John Keeping authored and Junio C Hamano committed Sep 3, 2015
1 parent f3c1ba5 commit dc6d782
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions date.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit dc6d782

Please sign in to comment.