mirror of
https://git.zx2c4.com/cgit
synced 2024-11-22 16:38:42 +00:00
Added local-time
option to cgitrc
When `local-time` is set, commit, tag and patch timestamps will be printed in the servers timezone. Also, regardless of the value of `local-time`, these timestamps will now always show the timezone. Signed-off-by: Stefan Naewe <stefan.naewe@atlas-elektronik.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This commit is contained in:
parent
a1266edfe6
commit
0f0ab148c6
3
cgit.c
3
cgit.c
@ -87,6 +87,8 @@ void config_cb(const char *name, const char *value)
|
|||||||
ctx.cfg.robots = xstrdup(value);
|
ctx.cfg.robots = xstrdup(value);
|
||||||
else if (!strcmp(name, "clone-prefix"))
|
else if (!strcmp(name, "clone-prefix"))
|
||||||
ctx.cfg.clone_prefix = xstrdup(value);
|
ctx.cfg.clone_prefix = xstrdup(value);
|
||||||
|
else if (!strcmp(name, "local-time"))
|
||||||
|
ctx.cfg.local_time = atoi(value);
|
||||||
else if (!strcmp(name, "repo.group"))
|
else if (!strcmp(name, "repo.group"))
|
||||||
ctx.cfg.repo_group = xstrdup(value);
|
ctx.cfg.repo_group = xstrdup(value);
|
||||||
else if (!strcmp(name, "repo.url"))
|
else if (!strcmp(name, "repo.url"))
|
||||||
@ -167,6 +169,7 @@ static void prepare_context(struct cgit_context *ctx)
|
|||||||
ctx->cfg.cache_static_ttl = -1;
|
ctx->cfg.cache_static_ttl = -1;
|
||||||
ctx->cfg.css = "/cgit.css";
|
ctx->cfg.css = "/cgit.css";
|
||||||
ctx->cfg.logo = "/git-logo.png";
|
ctx->cfg.logo = "/git-logo.png";
|
||||||
|
ctx->cfg.local_time = 0;
|
||||||
ctx->cfg.max_repo_count = 50;
|
ctx->cfg.max_repo_count = 50;
|
||||||
ctx->cfg.max_commit_count = 50;
|
ctx->cfg.max_commit_count = 50;
|
||||||
ctx->cfg.max_lock_attempts = 5;
|
ctx->cfg.max_lock_attempts = 5;
|
||||||
|
3
cgit.h
3
cgit.h
@ -22,7 +22,7 @@
|
|||||||
/*
|
/*
|
||||||
* Dateformats used on misc. pages
|
* Dateformats used on misc. pages
|
||||||
*/
|
*/
|
||||||
#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S"
|
#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)"
|
||||||
#define FMT_SHORTDATE "%Y-%m-%d"
|
#define FMT_SHORTDATE "%Y-%m-%d"
|
||||||
|
|
||||||
|
|
||||||
@ -148,6 +148,7 @@ struct cgit_config {
|
|||||||
int enable_index_links;
|
int enable_index_links;
|
||||||
int enable_log_filecount;
|
int enable_log_filecount;
|
||||||
int enable_log_linecount;
|
int enable_log_linecount;
|
||||||
|
int local_time;
|
||||||
int max_repo_count;
|
int max_repo_count;
|
||||||
int max_commit_count;
|
int max_commit_count;
|
||||||
int max_lock_attempts;
|
int max_lock_attempts;
|
||||||
|
@ -40,14 +40,14 @@ void cgit_print_commit(char *hex)
|
|||||||
html(" ");
|
html(" ");
|
||||||
html_txt(info->author_email);
|
html_txt(info->author_email);
|
||||||
html("</td><td class='right'>");
|
html("</td><td class='right'>");
|
||||||
cgit_print_date(info->author_date, FMT_LONGDATE);
|
cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
|
||||||
html("</td></tr>\n");
|
html("</td></tr>\n");
|
||||||
html("<tr><th>committer</th><td>");
|
html("<tr><th>committer</th><td>");
|
||||||
html_txt(info->committer);
|
html_txt(info->committer);
|
||||||
html(" ");
|
html(" ");
|
||||||
html_txt(info->committer_email);
|
html_txt(info->committer_email);
|
||||||
html("</td><td class='right'>");
|
html("</td><td class='right'>");
|
||||||
cgit_print_date(info->committer_date, FMT_LONGDATE);
|
cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
|
||||||
html("</td></tr>\n");
|
html("</td></tr>\n");
|
||||||
html("<tr><th>commit</th><td colspan='2' class='sha1'>");
|
html("<tr><th>commit</th><td colspan='2' class='sha1'>");
|
||||||
tmp = sha1_to_hex(commit->object.sha1);
|
tmp = sha1_to_hex(commit->object.sha1);
|
||||||
|
@ -103,7 +103,7 @@ void cgit_print_patch(char *hex)
|
|||||||
htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1));
|
htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1));
|
||||||
htmlf("From: %s%s\n", info->author, info->author_email);
|
htmlf("From: %s%s\n", info->author, info->author_email);
|
||||||
html("Date: ");
|
html("Date: ");
|
||||||
cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n");
|
cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n", ctx.cfg.local_time);
|
||||||
htmlf("Subject: %s\n\n", info->subject);
|
htmlf("Subject: %s\n\n", info->subject);
|
||||||
if (info->msg && *info->msg) {
|
if (info->msg && *info->msg) {
|
||||||
htmlf("%s", info->msg);
|
htmlf("%s", info->msg);
|
||||||
|
@ -353,13 +353,16 @@ void cgit_object_link(struct object *obj)
|
|||||||
html_link_close();
|
html_link_close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cgit_print_date(time_t secs, char *format)
|
void cgit_print_date(time_t secs, char *format, int local_time)
|
||||||
{
|
{
|
||||||
char buf[64];
|
char buf[64];
|
||||||
struct tm *time;
|
struct tm *time;
|
||||||
|
|
||||||
if (!secs)
|
if (!secs)
|
||||||
return;
|
return;
|
||||||
|
if(local_time)
|
||||||
|
time = localtime(&secs);
|
||||||
|
else
|
||||||
time = gmtime(&secs);
|
time = gmtime(&secs);
|
||||||
strftime(buf, sizeof(buf)-1, format, time);
|
strftime(buf, sizeof(buf)-1, format, time);
|
||||||
html_txt(buf);
|
html_txt(buf);
|
||||||
@ -375,7 +378,7 @@ void cgit_print_age(time_t t, time_t max_relative, char *format)
|
|||||||
secs = now - t;
|
secs = now - t;
|
||||||
|
|
||||||
if (secs > max_relative && max_relative >= 0) {
|
if (secs > max_relative && max_relative >= 0) {
|
||||||
cgit_print_date(t, format);
|
cgit_print_date(t, format, ctx.cfg.local_time);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,7 +456,7 @@ void cgit_print_docend()
|
|||||||
html_include(ctx.cfg.footer);
|
html_include(ctx.cfg.footer);
|
||||||
else {
|
else {
|
||||||
html("<div class='footer'>generated ");
|
html("<div class='footer'>generated ");
|
||||||
cgit_print_date(time(NULL), FMT_LONGDATE);
|
cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time);
|
||||||
htmlf(" by cgit %s", cgit_version);
|
htmlf(" by cgit %s", cgit_version);
|
||||||
html("</div>\n");
|
html("</div>\n");
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ extern void cgit_diff_link(char *name, char *title, char *class, char *head,
|
|||||||
extern void cgit_object_link(struct object *obj);
|
extern void cgit_object_link(struct object *obj);
|
||||||
|
|
||||||
extern void cgit_print_error(char *msg);
|
extern void cgit_print_error(char *msg);
|
||||||
extern void cgit_print_date(time_t secs, char *format);
|
extern void cgit_print_date(time_t secs, char *format, int local_time);
|
||||||
extern void cgit_print_age(time_t t, time_t max_relative, char *format);
|
extern void cgit_print_age(time_t t, time_t max_relative, char *format);
|
||||||
extern void cgit_print_http_headers(struct cgit_context *ctx);
|
extern void cgit_print_http_headers(struct cgit_context *ctx);
|
||||||
extern void cgit_print_docstart(struct cgit_context *ctx);
|
extern void cgit_print_docstart(struct cgit_context *ctx);
|
||||||
|
2
ui-tag.c
2
ui-tag.c
@ -57,7 +57,7 @@ void cgit_print_tag(char *revname)
|
|||||||
revname, sha1_to_hex(sha1));
|
revname, sha1_to_hex(sha1));
|
||||||
if (info->tagger_date > 0) {
|
if (info->tagger_date > 0) {
|
||||||
html("<tr><td>Tag date</td><td>");
|
html("<tr><td>Tag date</td><td>");
|
||||||
cgit_print_date(info->tagger_date, FMT_LONGDATE);
|
cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time);
|
||||||
html("</td></tr>\n");
|
html("</td></tr>\n");
|
||||||
}
|
}
|
||||||
if (info->tagger) {
|
if (info->tagger) {
|
||||||
|
Loading…
Reference in New Issue
Block a user