@@ -491,6 +491,18 @@ sub evaluate_uri {
491491 ' override' => 0,
492492 ' default' => [0]},
493493
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+
494506 # Syntax highlighting support. This is based on Daniel Svensson's
495507 # and Sham Chukoury's work in gitweb-xmms2.git.
496508 # It requires the 'highlight' program present in $PATH,
@@ -3897,9 +3909,20 @@ sub git_footer_html {
38973909 qq! startBlame("! . href(action => " blame_data" , -replay => 1) .qq! ",\n ! .
38983910 qq! "! . href() .qq! ");\n ! .
38993911 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+
39013916 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 ! .
39033926 qq! </script>\n ! ;
39043927 }
39053928
@@ -4103,22 +4126,25 @@ sub git_print_section {
41034126 print $cgi -> end_div;
41044127}
41054128
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 ' };
41094132
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>! ;
41194137 }
41204138
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 ;
41224148}
41234149
41244150# Outputs the author name and date in long form
@@ -4131,10 +4157,9 @@ sub git_print_authorship {
41314157 my %ad = parse_date($co -> {' author_epoch' }, $co -> {' author_tz' });
41324158 print " <$tag class=\" author_date\" >" .
41334159 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 " ;
41384163}
41394164
41404165# Outputs table rows containing the full author or committer information,
@@ -4151,16 +4176,16 @@ sub git_print_authorship_rows {
41514176 my %wd = parse_date($co -> {" ${who} _epoch" }, $co -> {" ${who} _tz" });
41524177 print " <tr><td>$who </td><td>" .
41534178 format_search_author($co -> {" ${who} _name" }, $who ,
4154- esc_html($co -> {" ${who} _name" })) . " " .
4179+ esc_html($co -> {" ${who} _name" })) . " " .
41554180 format_search_author($co -> {" ${who} _email" }, $who ,
4156- esc_html(" <" . $co -> {" ${who} _email" } . " >" )) .
4181+ esc_html(" <" . $co -> {" ${who} _email" } . " >" )) .
41574182 " </td><td rowspan=\" 2\" >" .
41584183 git_get_avatar($co -> {" ${who} _email" }, -size => ' double' ) .
41594184 " </td></tr>\n " .
41604185 " <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>" .
41644189 " </tr>\n " ;
41654190 }
41664191}
@@ -5648,7 +5673,8 @@ sub git_summary {
56485673 " <tr id=\" metadata_desc\" ><td>description</td><td>" . esc_html($descr ) . " </td></tr>\n " .
56495674 " <tr id=\" metadata_owner\" ><td>owner</td><td>" . esc_html($owner ) . " </td></tr>\n " ;
56505675 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 " ;
56525678 }
56535679
56545680 # use per project git URL list in $projectroot/$project/cloneurl
0 commit comments