summaryrefslogtreecommitdiffabout
authorStefan 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)
commit0f0ab148c6d444316af10e6b4c7a60630fed45d3 (patch) (side-by-side diff)
treea52c08e648c5d656866cecf78e757f2f85211b19
parenta1266edfe6ec1fd678c8f6b60ffbd21d88ff5a93 (diff)
downloadcgit-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>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c3
-rw-r--r--cgit.h3
-rw-r--r--ui-commit.c4
-rw-r--r--ui-patch.c2
-rw-r--r--ui-shared.c11
-rw-r--r--ui-shared.h2
-rw-r--r--ui-tag.c2
7 files changed, 17 insertions, 10 deletions
diff --git a/cgit.c b/cgit.c
index e2d5edb..f49fffa 100644
--- a/cgit.c
+++ b/cgit.c
@@ -88,4 +88,6 @@ void config_cb(const char *name, const char *value)
else if (!strcmp(name, "clone-prefix"))
ctx.cfg.clone_prefix = xstrdup(value);
+ else if (!strcmp(name, "local-time"))
+ ctx.cfg.local_time = atoi(value);
else if (!strcmp(name, "repo.group"))
ctx.cfg.repo_group = xstrdup(value);
@@ -168,4 +170,5 @@ static void prepare_context(struct cgit_context *ctx)
ctx->cfg.css = "/cgit.css";
ctx->cfg.logo = "/git-logo.png";
+ ctx->cfg.local_time = 0;
ctx->cfg.max_repo_count = 50;
ctx->cfg.max_commit_count = 50;
diff --git a/cgit.h b/cgit.h
index 7881aca..b01fa31 100644
--- a/cgit.h
+++ b/cgit.h
@@ -23,5 +23,5 @@
* 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"
@@ -149,4 +149,5 @@ struct cgit_config {
int enable_log_filecount;
int enable_log_linecount;
+ int local_time;
int max_repo_count;
int max_commit_count;
diff --git a/ui-commit.c b/ui-commit.c
index 4bbb391..a6a85a4 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -41,5 +41,5 @@ void cgit_print_commit(char *hex)
html_txt(info->author_email);
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("<tr><th>committer</th><td>");
@@ -48,5 +48,5 @@ void cgit_print_commit(char *hex)
html_txt(info->committer_email);
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("<tr><th>commit</th><td colspan='2' class='sha1'>");
diff --git a/ui-patch.c b/ui-patch.c
index c1c4ce3..e60877d 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -104,5 +104,5 @@ void cgit_print_patch(char *hex)
htmlf("From: %s%s\n", info->author, info->author_email);
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);
if (info->msg && *info->msg) {
diff --git a/ui-shared.c b/ui-shared.c
index 4280a70..197ee37 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -354,5 +354,5 @@ 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)
{
char buf[64];
@@ -361,5 +361,8 @@ void cgit_print_date(time_t secs, char *format)
if (!secs)
return;
- time = gmtime(&secs);
+ if(local_time)
+ time = localtime(&secs);
+ else
+ time = gmtime(&secs);
strftime(buf, sizeof(buf)-1, format, time);
html_txt(buf);
@@ -376,5 +379,5 @@ 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;
}
@@ -454,5 +457,5 @@ void cgit_print_docend()
else {
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);
html("</div>\n");
diff --git a/ui-shared.h b/ui-shared.h
index 3005d30..07da4b4 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -28,5 +28,5 @@ 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);
extern void cgit_print_http_headers(struct cgit_context *ctx);
diff --git a/ui-tag.c b/ui-tag.c
index ab2c66d..b4db32e 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -58,5 +58,5 @@ void cgit_print_tag(char *revname)
if (info->tagger_date > 0) {
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");
}