all repos — cgit @ f03e3cb8a5c6b597b87321e1f082d3ab177e8baa

a hyperfast web frontend for git written in c

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>
John Keeping john@keeping.me.uk
Thu, 13 Aug 2015 12:24:32 +0100
commit

f03e3cb8a5c6b597b87321e1f082d3ab177e8baa

parent

0c4d76755b98bb597279a1930bf4c69eca7dde62

1 files changed, 9 insertions(+), 4 deletions(-)

jump to
M ui-shared.cui-shared.c

@@ -604,19 +604,24 @@ if (item && tail)

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,