Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH v3 08/11] date: check for "local" before anything else

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:06:26

John Keeping [off-list ref] writes:
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.
"local" is a request to show the timestamp in the output in our
local timezone regardless of the format, so even though "relative"
is not affected by the timezone (because "relative" does not show a
timestamp at all---it only shows the duration), this change
conceptually makes sense.

Thanks.

quoted hunk
Signed-off-by: John Keeping <redacted>
---
 date.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/date.c b/date.c
index 8f91569..9f0a5dd 100644
--- 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);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help