mirror of
https://git.zx2c4.com/cgit
synced 2024-11-26 10:28:42 +00:00
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>
This commit is contained in:
parent
0c4d76755b
commit
f03e3cb8a5
13
ui-shared.c
13
ui-shared.c
@ -604,19 +604,24 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
|
|||||||
path[len - 1] = 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;
|
struct tm *time;
|
||||||
|
|
||||||
if (!secs)
|
if (!secs)
|
||||||
return;
|
return "";
|
||||||
if (local_time)
|
if (local_time)
|
||||||
time = localtime(&secs);
|
time = localtime(&secs);
|
||||||
else
|
else
|
||||||
time = gmtime(&secs);
|
time = gmtime(&secs);
|
||||||
strftime(buf, sizeof(buf)-1, format, time);
|
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,
|
static void print_rel_date(time_t t, double value,
|
||||||
|
Loading…
Reference in New Issue
Block a user