diff options
author | Stefan Naewe <stefan.naewe@atlas-elektronik.com> | 2008-08-01 21:54:38 (JST) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-08-02 05:09:13 (JST) |
commit | 0f0ab148c6d444316af10e6b4c7a60630fed45d3 (patch) | |
tree | a52c08e648c5d656866cecf78e757f2f85211b19 /ui-shared.c | |
parent | a1266edfe6ec1fd678c8f6b60ffbd21d88ff5a93 (diff) | |
download | cgit-0f0ab148c6d444316af10e6b4c7a60630fed45d3.zip cgit-0f0ab148c6d444316af10e6b4c7a60630fed45d3.tar.gz |
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 (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ui-shared.c b/ui-shared.c index 4280a70..197ee37 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -353,14 +353,17 @@ 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 | 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); |
365 | html_txt(buf); | 368 | html_txt(buf); |
366 | } | 369 | } |
@@ -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 | } |