ctucx.git: stagit

ctucx' stagit fork

commit f8a7ba139a1cb7b2faf885ba20d1f5e8caf60184
parent 4b680dc9ced8aa6982dc94518da95810916d2635
Author: Leah (ctucx) <git@ctu.cx>
Date: Sat, 13 May 2023 22:16:41 +0200

stagit, stagit-index: add offset to time in printtimeshort
2 files changed, 11 insertions(+), 4 deletions(-)
M
stagit-index.c
|
8
++++++--
M
stagit.c
|
7
+++++--
diff --git a/stagit-index.c b/stagit-index.c
@@ -88,7 +88,7 @@ printtimeshort(FILE *fp, const git_time *intime)
 	time_t t;
 	char out[32];
 
-	t = (time_t)intime->time;
+	t = (time_t)intime->time + (intime->offset * 60);
 	if (!(intm = gmtime(&t)))
 		return;
 	strftime(out, sizeof(out), "%Y-%m-%d %H:%M", intm);

@@ -128,11 +128,15 @@ writefooter(FILE *fp)
 		"<pre><code>git config format.subjectPrefix \"PATCH &lt;name-of-repository&gt;\"</code></pre>\n" , email, email);
 
 	static char *gen_time;
+	static struct tm lt = {0};
+
     time_t now = time(&now);
+    localtime_r(&now, &lt);
+
 	gen_time = ctime(&now);
 	gen_time[24] = '\0';
 
-	fprintf(fp, "\n</main><footer><p>Generated on %s (UTC)</p></footer></body></html>", gen_time);
+	fprintf(fp, "\n</main><footer><p>Generated on %s (%s)</p></footer></body></html>", gen_time, lt.tm_zone);
 }
 
 int
diff --git a/stagit.c b/stagit.c
@@ -69,6 +69,7 @@ static char *http_cloneurl = "";
 static char *ssh_cloneurl = "";
 
 static char *gen_time;
+static struct tm lt = {0};
 static char *name = "";
 static char *strippedname = "";
 static char description[255];

@@ -514,7 +515,7 @@ printtimeshort(FILE *fp, const git_time *intime)
 	time_t t;
 	char out[32];
 
-	t = (time_t)intime->time;
+	t = (time_t)intime->time + (intime->offset * 60);
 	if (!(intm = gmtime(&t)))
 		return;
 	strftime(out, sizeof(out), "%Y-%m-%d %H:%M", intm);

@@ -613,7 +614,7 @@ writeheader(FILE *fp, const char *title, const char *mode)
 void
 writefooter(FILE *fp)
 {
-	fprintf(fp, "\n</main><footer><p>Generated on %s (UTC)</p></footer></body></html>", gen_time);
+	fprintf(fp, "\n</main><footer><p>Generated on %s (%s)</p></footer></body></html>", gen_time, lt.tm_zone);
 }
 
 void

@@ -1280,6 +1281,8 @@ main(int argc, char *argv[])
 	struct commitinfo *ci;
 
     time_t now = time(&now);
+    localtime_r(&now, &lt);
+
 	gen_time = ctime(&now);
 	gen_time[24] = '\0';