480
'override' => 0,
481
'default' => [0]},
482
483
+ # Enable and configure ability to change common timezone for dates
484
+ # in gitweb output via JavaScript. Enabled by default.
485
+ # Project specific override is not supported.
486
+ 'javascript-timezone' => {
487
+ 'override' => 0,
488
+ 'default' => [
489
+ 'local', # default timezone: 'utc', 'local', or '(-|+)HHMM' format,
490
+ # or undef to turn off this feature
491
+ 'gitweb_tz', # name of cookie where to store selected timezone
492
+ 'datetime', # CSS class used to mark up dates for manipulation
493
+ ]},
494
+
495
# Syntax highlighting support. This is based on Daniel Svensson's
496
# and Sham Chukoury's work in gitweb-xmms2.git.
497
# It requires the 'highlight' program present in $PATH,
3745
qq! "!. href() .qq!");\n!.
3746
qq!</script>\n!;
3747
} else {
3748
+ my ($jstimezone, $tz_cookie, $datetime_class) =
3749
+ gitweb_get_feature('javascript-timezone');
3750
+
3751
print qq!<script type="text/javascript">\n!.
3737
- qq!window.onload = function () {\n!.
3738
- (gitweb_check_feature('javascript-actions') ?
3739
- qq! fixLinks();\n! : '').
3740
- # last parameter to onloadTZSetup must be CSS class used by format_timestamp_html
3741
- qq! var tz_cookie = { name: 'gitweb_tz', expires: 14, path: '/' };\n!. # in days
3742
- qq! onloadTZSetup('local', tz_cookie, 'datetime');\n!.
3743
- qq!};\n!.
3752
+ qq!window.onload = function () {\n!;
3753
+ if (gitweb_check_feature('javascript-actions')) {
3754
+ print qq! fixLinks();\n!;
3755
+ }
3756
+ if ($jstimezone && $tz_cookie && $datetime_class) {
3757
+ print qq! var tz_cookie = { name: '$tz_cookie', expires: 14, path: '/' };\n!. # in days
3758
+ qq! onloadTZSetup('$jstimezone', tz_cookie, '$datetime_class');\n!;
3759
+ }
3760
+ print qq!};\n!.
3761
qq!</script>\n!;
3762
}
3763
3963
3964
sub format_timestamp_html {
3965
my $date = shift;
3949
- my $strtime = '<span class="datetime">'.$date->{'rfc2822'}.'</span>';
3966
+ my $strtime = $date->{'rfc2822'};
3967
+
3968
+ my (undef, undef, $datetime_class) =
3969
+ gitweb_get_feature('javascript-timezone');
3970
+ if ($datetime_class) {
3971
+ $strtime = qq!<span class="$datetime_class">$strtime</span>!;
3972
+ }
3973
3974
my $localtime_format = '(%02d:%02d %s)';
3975
if ($date->{'hour_local'} < 6) {