-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.h | 3 | ||||
-rw-r--r-- | ui-commit.c | 4 | ||||
-rw-r--r-- | ui-patch.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 11 | ||||
-rw-r--r-- | ui-shared.h | 2 | ||||
-rw-r--r-- | ui-tag.c | 2 |
7 files changed, 17 insertions, 10 deletions
@@ -89,2 +89,4 @@ void config_cb(const char *name, const char *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")) @@ -169,2 +171,3 @@ static void prepare_context(struct cgit_context *ctx) ctx->cfg.logo = "/git-logo.png"; + ctx->cfg.local_time = 0; ctx->cfg.max_repo_count = 50; @@ -24,3 +24,3 @@ */ -#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" @@ -150,2 +150,3 @@ struct cgit_config { int enable_log_linecount; + int local_time; int max_repo_count; diff --git a/ui-commit.c b/ui-commit.c index 4bbb391..a6a85a4 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -42,3 +42,3 @@ void cgit_print_commit(char *hex) 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"); @@ -49,3 +49,3 @@ void cgit_print_commit(char *hex) 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"); @@ -105,3 +105,3 @@ void cgit_print_patch(char *hex) 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); diff --git a/ui-shared.c b/ui-shared.c index 4280a70..197ee37 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -355,3 +355,3 @@ void cgit_object_link(struct object *obj) -void cgit_print_date(time_t secs, char *format) +void cgit_print_date(time_t secs, char *format, int local_time) { @@ -362,3 +362,6 @@ void cgit_print_date(time_t secs, char *format) return; - time = gmtime(&secs); + if(local_time) + time = localtime(&secs); + else + time = gmtime(&secs); strftime(buf, sizeof(buf)-1, format, time); @@ -377,3 +380,3 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) if (secs > max_relative && max_relative >= 0) { - cgit_print_date(t, format); + cgit_print_date(t, format, ctx.cfg.local_time); return; @@ -455,3 +458,3 @@ void cgit_print_docend() 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); diff --git a/ui-shared.h b/ui-shared.h index 3005d30..07da4b4 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -29,3 +29,3 @@ extern void cgit_object_link(struct object *obj); 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); @@ -59,3 +59,3 @@ void cgit_print_tag(char *revname) 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"); |