diff options
author | John Keeping | 2015-08-13 12:24:32 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2015-08-13 15:39:59 +0200 |
commit | f03e3cb8a5c6b597b87321e1f082d3ab177e8baa (patch) | |
tree | 63836fc9531748ca4cc3fc29563cbc820e136cd8 /ui-shared.c | |
parent | 0c4d76755b98bb597279a1930bf4c69eca7dde62 (diff) | |
download | cgit-f03e3cb8a5c6b597b87321e1f082d3ab177e8baa.tar.gz cgit-f03e3cb8a5c6b597b87321e1f082d3ab177e8baa.tar.bz2 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>
Diffstat (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 13 |
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 | ||
607 | void cgit_print_date(time_t secs, const char *format, int local_time) | 607 | static 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 | |||
622 | void 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 | ||
622 | static void print_rel_date(time_t t, double value, | 627 | static void print_rel_date(time_t t, double value, |