about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2015-08-13 12:24:32 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2015-08-13 15:39:59 +0200
commitf03e3cb8a5c6b597b87321e1f082d3ab177e8baa (patch)
tree63836fc9531748ca4cc3fc29563cbc820e136cd8
parentfilter: don't use dlsym unnecessarily (diff)
downloadcgit-pink-f03e3cb8a5c6b597b87321e1f082d3ab177e8baa.tar.gz
cgit-pink-f03e3cb8a5c6b597b87321e1f082d3ab177e8baa.zip
ui-shared: extract date formatting to a function
This will allow this code to be common with print_rel_date.

Signed-off-by: John Keeping <john@keeping.me.uk>
-rw-r--r--ui-shared.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 1292ac9..19cd521 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -604,19 +604,24 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
 		path[len - 1] = tail;
 }
 
-void cgit_print_date(time_t secs, const char *format, int local_time)
+static const char *fmt_date(time_t secs, const char *format, int local_time)
 {
-	char buf[64];
+	static char buf[64];
 	struct tm *time;
 
 	if (!secs)
-		return;
+		return "";
 	if (local_time)
 		time = localtime(&secs);
 	else
 		time = gmtime(&secs);
 	strftime(buf, sizeof(buf)-1, format, time);
-	html_txt(buf);
+	return buf;
+}
+
+void cgit_print_date(time_t secs, const char *format, int local_time)
+{
+	html_txt(fmt_date(secs, format, local_time));
 }
 
 static void print_rel_date(time_t t, double value,