@@ -491,6 +491,18 @@ sub evaluate_uri {
491
491
' override' => 0,
492
492
' default' => [0]},
493
493
494
+ # Enable and configure ability to change common timezone for dates
495
+ # in gitweb output via JavaScript. Enabled by default.
496
+ # Project specific override is not supported.
497
+ ' javascript-timezone' => {
498
+ ' override' => 0,
499
+ ' default' => [
500
+ ' local' , # default timezone: 'utc', 'local', or '(-|+)HHMM' format,
501
+ # or undef to turn off this feature
502
+ ' gitweb_tz' , # name of cookie where to store selected timezone
503
+ ' datetime' , # CSS class used to mark up dates for manipulation
504
+ ]},
505
+
494
506
# Syntax highlighting support. This is based on Daniel Svensson's
495
507
# and Sham Chukoury's work in gitweb-xmms2.git.
496
508
# It requires the 'highlight' program present in $PATH,
@@ -3897,9 +3909,20 @@ sub git_footer_html {
3897
3909
qq! startBlame("! . href(action => " blame_data" , -replay => 1) .qq! ",\n ! .
3898
3910
qq! "! . href() .qq! ");\n ! .
3899
3911
qq! </script>\n ! ;
3900
- } elsif (gitweb_check_feature(' javascript-actions' )) {
3912
+ } else {
3913
+ my ($jstimezone , $tz_cookie , $datetime_class ) =
3914
+ gitweb_get_feature(' javascript-timezone' );
3915
+
3901
3916
print qq! <script type="text/javascript">\n ! .
3902
- qq! window.onload = fixLinks;\n ! .
3917
+ qq! window.onload = function () {\n ! ;
3918
+ if (gitweb_check_feature(' javascript-actions' )) {
3919
+ print qq! fixLinks();\n ! ;
3920
+ }
3921
+ if ($jstimezone && $tz_cookie && $datetime_class ) {
3922
+ print qq! var tz_cookie = { name: '$tz_cookie ', expires: 14, path: '/' };\n ! . # in days
3923
+ qq! onloadTZSetup('$jstimezone ', tz_cookie, '$datetime_class ');\n ! ;
3924
+ }
3925
+ print qq! };\n ! .
3903
3926
qq! </script>\n ! ;
3904
3927
}
3905
3928
@@ -4103,22 +4126,25 @@ sub git_print_section {
4103
4126
print $cgi -> end_div;
4104
4127
}
4105
4128
4106
- sub print_local_time {
4107
- print format_local_time( @_ ) ;
4108
- }
4129
+ sub format_timestamp_html {
4130
+ my $date = shift ;
4131
+ my $strtime = $date -> { ' rfc2822 ' };
4109
4132
4110
- sub format_local_time {
4111
- my $localtime = ' ' ;
4112
- my %date = @_ ;
4113
- if ($date {' hour_local' } < 6) {
4114
- $localtime .= sprintf (" (<span class=\" atnight\" >%02d:%02d</span> %s )" ,
4115
- $date {' hour_local' }, $date {' minute_local' }, $date {' tz_local' });
4116
- } else {
4117
- $localtime .= sprintf (" (%02d:%02d %s )" ,
4118
- $date {' hour_local' }, $date {' minute_local' }, $date {' tz_local' });
4133
+ my (undef , undef , $datetime_class ) =
4134
+ gitweb_get_feature(' javascript-timezone' );
4135
+ if ($datetime_class ) {
4136
+ $strtime = qq! <span class="$datetime_class ">$strtime </span>! ;
4119
4137
}
4120
4138
4121
- return $localtime ;
4139
+ my $localtime_format = ' (%02d:%02d %s)' ;
4140
+ if ($date -> {' hour_local' } < 6) {
4141
+ $localtime_format = ' (<span class="atnight">%02d:%02d</span> %s)' ;
4142
+ }
4143
+ $strtime .= ' ' .
4144
+ sprintf ($localtime_format ,
4145
+ $date -> {' hour_local' }, $date -> {' minute_local' }, $date -> {' tz_local' });
4146
+
4147
+ return $strtime ;
4122
4148
}
4123
4149
4124
4150
# Outputs the author name and date in long form
@@ -4131,10 +4157,9 @@ sub git_print_authorship {
4131
4157
my %ad = parse_date($co -> {' author_epoch' }, $co -> {' author_tz' });
4132
4158
print " <$tag class=\" author_date\" >" .
4133
4159
format_search_author($author , " author" , esc_html($author )) .
4134
- " [$ad {'rfc2822'}" ;
4135
- print_local_time(%ad ) if ($opts {-localtime });
4136
- print " ]" . git_get_avatar($co -> {' author_email' }, -pad_before => 1)
4137
- . " </$tag >\n " ;
4160
+ " [" .format_timestamp_html(\%ad )." ]" .
4161
+ git_get_avatar($co -> {' author_email' }, -pad_before => 1) .
4162
+ " </$tag >\n " ;
4138
4163
}
4139
4164
4140
4165
# Outputs table rows containing the full author or committer information,
@@ -4151,16 +4176,16 @@ sub git_print_authorship_rows {
4151
4176
my %wd = parse_date($co -> {" ${who} _epoch" }, $co -> {" ${who} _tz" });
4152
4177
print " <tr><td>$who </td><td>" .
4153
4178
format_search_author($co -> {" ${who} _name" }, $who ,
4154
- esc_html($co -> {" ${who} _name" })) . " " .
4179
+ esc_html($co -> {" ${who} _name" })) . " " .
4155
4180
format_search_author($co -> {" ${who} _email" }, $who ,
4156
- esc_html(" <" . $co -> {" ${who} _email" } . " >" )) .
4181
+ esc_html(" <" . $co -> {" ${who} _email" } . " >" )) .
4157
4182
" </td><td rowspan=\" 2\" >" .
4158
4183
git_get_avatar($co -> {" ${who} _email" }, -size => ' double' ) .
4159
4184
" </td></tr>\n " .
4160
4185
" <tr>" .
4161
- " <td></td><td> $wd {'rfc2822'} " ;
4162
- print_local_time( %wd );
4163
- print " </td>" .
4186
+ " <td></td><td>" .
4187
+ format_timestamp_html(\ %wd ) .
4188
+ " </td>" .
4164
4189
" </tr>\n " ;
4165
4190
}
4166
4191
}
@@ -5648,7 +5673,8 @@ sub git_summary {
5648
5673
" <tr id=\" metadata_desc\" ><td>description</td><td>" . esc_html($descr ) . " </td></tr>\n " .
5649
5674
" <tr id=\" metadata_owner\" ><td>owner</td><td>" . esc_html($owner ) . " </td></tr>\n " ;
5650
5675
if (defined $cd {' rfc2822' }) {
5651
- print " <tr id=\" metadata_lchange\" ><td>last change</td><td>$cd {'rfc2822'}</td></tr>\n " ;
5676
+ print " <tr id=\" metadata_lchange\" ><td>last change</td>" .
5677
+ " <td>" .format_timestamp_html(\%cd )." </td></tr>\n " ;
5652
5678
}
5653
5679
5654
5680
# use per project git URL list in $projectroot/$project/cloneurl
0 commit comments