about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJohn Keeping2015-08-13 12:24:32 +0100
committerJason A. Donenfeld2015-08-13 15:39:59 +0200
commitf03e3cb8a5c6b597b87321e1f082d3ab177e8baa (patch)
tree63836fc9531748ca4cc3fc29563cbc820e136cd8
parentfilter: don't use dlsym unnecessarily (diff)
downloadcgit-f03e3cb8a5c6b597b87321e1f082d3ab177e8baa.tar.gz
cgit-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)
604 path[len - 1] = tail; 604 path[len - 1] = tail;
605} 605}
606 606
607void cgit_print_date(time_t secs, const char *format, int local_time) 607static const char *fmt_date(time_t secs, const char *format, int local_time)
608{ 608{
609 char buf[64]; 609 static char buf[64];
610 struct tm *time; 610 struct tm *time;
611 611
612 if (!secs) 612 if (!secs)
613 return; 613 return "";
614 if (local_time) 614 if (local_time)
615 time = localtime(&secs); 615 time = localtime(&secs);
616 else 616 else
617 time = gmtime(&secs); 617 time = gmtime(&secs);
618 strftime(buf, sizeof(buf)-1, format, time); 618 strftime(buf, sizeof(buf)-1, format, time);
619 html_txt(buf); 619 return buf;
620}
621
622void cgit_print_date(time_t secs, const char *format, int local_time)
623{
624 html_txt(fmt_date(secs, format, local_time));
620} 625}
621 626
622static void print_rel_date(time_t t, double value, 627static void print_rel_date(time_t t, double value,