author | Stefan Naewe <stefan.naewe@atlas-elektronik.com> | 2008-08-01 12:54:38 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-08-01 20:09:13 (UTC) |
commit | 0f0ab148c6d444316af10e6b4c7a60630fed45d3 (patch) (unidiff) | |
tree | a52c08e648c5d656866cecf78e757f2f85211b19 | |
parent | a1266edfe6ec1fd678c8f6b60ffbd21d88ff5a93 (diff) | |
download | cgit-0f0ab148c6d444316af10e6b4c7a60630fed45d3.zip cgit-0f0ab148c6d444316af10e6b4c7a60630fed45d3.tar.gz cgit-0f0ab148c6d444316af10e6b4c7a60630fed45d3.tar.bz2 |
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>
-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) | |||
89 | ctx.cfg.clone_prefix = xstrdup(value); | 89 | ctx.cfg.clone_prefix = xstrdup(value); |
90 | else if (!strcmp(name, "local-time")) | ||
91 | ctx.cfg.local_time = atoi(value); | ||
90 | else if (!strcmp(name, "repo.group")) | 92 | else if (!strcmp(name, "repo.group")) |
@@ -169,2 +171,3 @@ static void prepare_context(struct cgit_context *ctx) | |||
169 | ctx->cfg.logo = "/git-logo.png"; | 171 | ctx->cfg.logo = "/git-logo.png"; |
172 | ctx->cfg.local_time = 0; | ||
170 | ctx->cfg.max_repo_count = 50; | 173 | ctx->cfg.max_repo_count = 50; |
@@ -24,3 +24,3 @@ | |||
24 | */ | 24 | */ |
25 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" | 25 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)" |
26 | #define FMT_SHORTDATE "%Y-%m-%d" | 26 | #define FMT_SHORTDATE "%Y-%m-%d" |
@@ -150,2 +150,3 @@ struct cgit_config { | |||
150 | int enable_log_linecount; | 150 | int enable_log_linecount; |
151 | int local_time; | ||
151 | int max_repo_count; | 152 | 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) | |||
42 | html("</td><td class='right'>"); | 42 | html("</td><td class='right'>"); |
43 | cgit_print_date(info->author_date, FMT_LONGDATE); | 43 | cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time); |
44 | html("</td></tr>\n"); | 44 | html("</td></tr>\n"); |
@@ -49,3 +49,3 @@ void cgit_print_commit(char *hex) | |||
49 | html("</td><td class='right'>"); | 49 | html("</td><td class='right'>"); |
50 | cgit_print_date(info->committer_date, FMT_LONGDATE); | 50 | cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time); |
51 | html("</td></tr>\n"); | 51 | html("</td></tr>\n"); |
@@ -105,3 +105,3 @@ void cgit_print_patch(char *hex) | |||
105 | html("Date: "); | 105 | html("Date: "); |
106 | cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n"); | 106 | cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n", ctx.cfg.local_time); |
107 | htmlf("Subject: %s\n\n", info->subject); | 107 | 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) | |||
355 | 355 | ||
356 | void cgit_print_date(time_t secs, char *format) | 356 | void cgit_print_date(time_t secs, char *format, int local_time) |
357 | { | 357 | { |
@@ -362,3 +362,6 @@ void cgit_print_date(time_t secs, char *format) | |||
362 | return; | 362 | return; |
363 | time = gmtime(&secs); | 363 | if(local_time) |
364 | time = localtime(&secs); | ||
365 | else | ||
366 | time = gmtime(&secs); | ||
364 | strftime(buf, sizeof(buf)-1, format, time); | 367 | strftime(buf, sizeof(buf)-1, format, time); |
@@ -377,3 +380,3 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
377 | if (secs > max_relative && max_relative >= 0) { | 380 | if (secs > max_relative && max_relative >= 0) { |
378 | cgit_print_date(t, format); | 381 | cgit_print_date(t, format, ctx.cfg.local_time); |
379 | return; | 382 | return; |
@@ -455,3 +458,3 @@ void cgit_print_docend() | |||
455 | html("<div class='footer'>generated "); | 458 | html("<div class='footer'>generated "); |
456 | cgit_print_date(time(NULL), FMT_LONGDATE); | 459 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); |
457 | htmlf(" by cgit %s", cgit_version); | 460 | 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); | |||
29 | extern void cgit_print_error(char *msg); | 29 | extern void cgit_print_error(char *msg); |
30 | extern void cgit_print_date(time_t secs, char *format); | 30 | extern void cgit_print_date(time_t secs, char *format, int local_time); |
31 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); | 31 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
@@ -59,3 +59,3 @@ void cgit_print_tag(char *revname) | |||
59 | html("<tr><td>Tag date</td><td>"); | 59 | html("<tr><td>Tag date</td><td>"); |
60 | cgit_print_date(info->tagger_date, FMT_LONGDATE); | 60 | cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time); |
61 | html("</td></tr>\n"); | 61 | html("</td></tr>\n"); |