aboutsummaryrefslogtreecommitdiff
path: root/gitweb/gitweb.perl
diff options
context:
space:
mode:
authorJohn 'Warthog9' Hawley <warthog9@eaglescrag.net>2011-04-28 21:04:09 +0200
committerJunio C Hamano <gitster@pobox.com>2011-05-24 11:22:45 -0700
commit291e52bd19877dc8fdd77079ba4c4326f114c461 (patch)
tree3fa91233286b12022cb696cfd78e3405dcc56638 /gitweb/gitweb.perl
parentce71b07632c71c2e6f4732abd3db6d59fb1bb924 (diff)
downloadgit-291e52bd19877dc8fdd77079ba4c4326f114c461.tar.gz
git-291e52bd19877dc8fdd77079ba4c4326f114c461.tar.xz
gitweb: JavaScript ability to adjust time based on timezone
This patch is based on Kevin Cernekee's <cernekee@gmail.com> patch series entitled "gitweb: introduce localtime feature". While Kevin's patch changed the server side output so that the timezone was output from gitweb itself, this has a number of drawbacks, in particular with respect to gitweb-caching. This patch takes the same basic goal, display the appropriate times in a given common timezone, and implements it in JavaScript. This requires adding / using a new class, "datetime", to be able to find elements to be adjusted from JavaScript. Appropriate dates are wrapped in a span with this class. Timezone to be used can be retrieved from "gitweb_tz" cookie, though currently there is no way to set / manipulate this cookie from gitweb; this is left for later commit. Valid timezones, currently, are: "utc", "local" (which means that timezone is taken from browser), and "+/-ZZZZ" numeric timezone as in RFC-2822. Default timezone is "local" (currently not configurable, left for later commit). Fallback (should JavaScript not be enabled) is to treat dates as they have been and display them, only, in UTC. Pages affected: * 'summary' view, "last change" field (commit time from latest change) * 'log' view, author time * 'commit' and 'commitdiff' views, author/committer time * 'tag' view, tagger time Based-on-code-from: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net> Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gitweb/gitweb.perl')
-rwxr-xr-xgitweb/gitweb.perl11
1 files changed, 8 insertions, 3 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 67bcfe894..6651946f5 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3732,9 +3732,14 @@ sub git_footer_html {
qq!startBlame("!. href(action=>"blame_data", -replay=>1) .qq!",\n!.
qq! "!. href() .qq!");\n!.
qq!</script>\n!;
- } elsif (gitweb_check_feature('javascript-actions')) {
+ } else {
print qq!<script type="text/javascript">\n!.
- qq!window.onload = fixLinks;\n!.
+ qq!window.onload = function () {\n!.
+ (gitweb_check_feature('javascript-actions') ?
+ qq! fixLinks();\n! : '').
+ # last parameter to onloadTZSetup must be CSS class used by format_timestamp_html
+ qq! onloadTZSetup('local', 'gitweb_tz', 'datetime');\n!.
+ qq!};\n!.
qq!</script>\n!;
}
@@ -3940,7 +3945,7 @@ sub git_print_section {
sub format_timestamp_html {
my $date = shift;
- my $strtime = $date->{'rfc2822'};
+ my $strtime = '<span class="datetime">'.$date->{'rfc2822'}.'</span>';
my $localtime_format = '(%02d:%02d %s)';
if ($date->{'hour_local'} < 6) {