-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 | 9 | ||||
-rw-r--r-- | ui-shared.h | 2 | ||||
-rw-r--r-- | ui-tag.c | 2 |
7 files changed, 16 insertions, 9 deletions
@@ -87,6 +87,8 @@ void config_cb(const char *name, const char *value) | |||
87 | ctx.cfg.robots = xstrdup(value); | 87 | ctx.cfg.robots = xstrdup(value); |
88 | else if (!strcmp(name, "clone-prefix")) | 88 | else if (!strcmp(name, "clone-prefix")) |
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")) |
91 | ctx.cfg.repo_group = xstrdup(value); | 93 | ctx.cfg.repo_group = xstrdup(value); |
92 | else if (!strcmp(name, "repo.url")) | 94 | else if (!strcmp(name, "repo.url")) |
@@ -167,6 +169,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
167 | ctx->cfg.cache_static_ttl = -1; | 169 | ctx->cfg.cache_static_ttl = -1; |
168 | ctx->cfg.css = "/cgit.css"; | 170 | ctx->cfg.css = "/cgit.css"; |
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; |
171 | ctx->cfg.max_commit_count = 50; | 174 | ctx->cfg.max_commit_count = 50; |
172 | ctx->cfg.max_lock_attempts = 5; | 175 | ctx->cfg.max_lock_attempts = 5; |
@@ -22,7 +22,7 @@ | |||
22 | /* | 22 | /* |
23 | * Dateformats used on misc. pages | 23 | * Dateformats used on misc. pages |
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" |
27 | 27 | ||
28 | 28 | ||
@@ -148,6 +148,7 @@ struct cgit_config { | |||
148 | int enable_index_links; | 148 | int enable_index_links; |
149 | int enable_log_filecount; | 149 | int enable_log_filecount; |
150 | int enable_log_linecount; | 150 | int enable_log_linecount; |
151 | int local_time; | ||
151 | int max_repo_count; | 152 | int max_repo_count; |
152 | int max_commit_count; | 153 | int max_commit_count; |
153 | int max_lock_attempts; | 154 | int max_lock_attempts; |
diff --git a/ui-commit.c b/ui-commit.c index 4bbb391..a6a85a4 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -40,14 +40,14 @@ void cgit_print_commit(char *hex) | |||
40 | html(" "); | 40 | html(" "); |
41 | html_txt(info->author_email); | 41 | html_txt(info->author_email); |
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"); |
45 | html("<tr><th>committer</th><td>"); | 45 | html("<tr><th>committer</th><td>"); |
46 | html_txt(info->committer); | 46 | html_txt(info->committer); |
47 | html(" "); | 47 | html(" "); |
48 | html_txt(info->committer_email); | 48 | html_txt(info->committer_email); |
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"); |
52 | html("<tr><th>commit</th><td colspan='2' class='sha1'>"); | 52 | html("<tr><th>commit</th><td colspan='2' class='sha1'>"); |
53 | tmp = sha1_to_hex(commit->object.sha1); | 53 | tmp = sha1_to_hex(commit->object.sha1); |
@@ -103,7 +103,7 @@ void cgit_print_patch(char *hex) | |||
103 | htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1)); | 103 | htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1)); |
104 | htmlf("From: %s%s\n", info->author, info->author_email); | 104 | htmlf("From: %s%s\n", info->author, info->author_email); |
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); |
108 | if (info->msg && *info->msg) { | 108 | if (info->msg && *info->msg) { |
109 | htmlf("%s", info->msg); | 109 | htmlf("%s", info->msg); |
diff --git a/ui-shared.c b/ui-shared.c index 4280a70..197ee37 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -353,13 +353,16 @@ void cgit_object_link(struct object *obj) | |||
353 | html_link_close(); | 353 | html_link_close(); |
354 | } | 354 | } |
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 | { |
358 | char buf[64]; | 358 | char buf[64]; |
359 | struct tm *time; | 359 | struct tm *time; |
360 | 360 | ||
361 | if (!secs) | 361 | if (!secs) |
362 | return; | 362 | return; |
363 | if(local_time) | ||
364 | time = localtime(&secs); | ||
365 | else | ||
363 | time = gmtime(&secs); | 366 | time = gmtime(&secs); |
364 | strftime(buf, sizeof(buf)-1, format, time); | 367 | strftime(buf, sizeof(buf)-1, format, time); |
365 | html_txt(buf); | 368 | html_txt(buf); |
@@ -375,7 +378,7 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
375 | secs = now - t; | 378 | secs = now - t; |
376 | 379 | ||
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; |
380 | } | 383 | } |
381 | 384 | ||
@@ -453,7 +456,7 @@ void cgit_print_docend() | |||
453 | html_include(ctx.cfg.footer); | 456 | html_include(ctx.cfg.footer); |
454 | else { | 457 | else { |
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); |
458 | html("</div>\n"); | 461 | html("</div>\n"); |
459 | } | 462 | } |
diff --git a/ui-shared.h b/ui-shared.h index 3005d30..07da4b4 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
@@ -27,7 +27,7 @@ extern void cgit_diff_link(char *name, char *title, char *class, char *head, | |||
27 | extern void cgit_object_link(struct object *obj); | 27 | extern void cgit_object_link(struct object *obj); |
28 | 28 | ||
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); |
32 | extern void cgit_print_http_headers(struct cgit_context *ctx); | 32 | extern void cgit_print_http_headers(struct cgit_context *ctx); |
33 | extern void cgit_print_docstart(struct cgit_context *ctx); | 33 | extern void cgit_print_docstart(struct cgit_context *ctx); |
@@ -57,7 +57,7 @@ void cgit_print_tag(char *revname) | |||
57 | revname, sha1_to_hex(sha1)); | 57 | revname, sha1_to_hex(sha1)); |
58 | if (info->tagger_date > 0) { | 58 | if (info->tagger_date > 0) { |
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"); |
62 | } | 62 | } |
63 | if (info->tagger) { | 63 | if (info->tagger) { |