git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] gitweb: show alternate author/committer times

From
Kevin Cernekee <cernekee@gmail.com>
Date
Mar 17, 2011, 19:38 UTC
Message-ID
<64c70e95e767572e5be732dc7e17815b@localhost>
In-Reply-To
<c8621826e0576e3e31240b0205e7e3d0@localhost>

On the commit/commitdiff views, show the author/committer times as follows:

If $feature{'localtime'} is disabled, display the RFC 2822 date/time in GMT, then print (HH:MM -TZ) in the author's/committer's local timezone. (i.e. no change to the current behavior)

If $feature{'localtime'} is enabled, display the RFC 2822 date/time in the author's/committer's local timezone, then print (HH:MM +0000) in GMT.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
 gitweb/gitweb.perl |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 578edc0..6b8f9a7 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3953,22 +3953,27 @@ sub git_print_section {
 	print $cgi->end_div;
 }
 
-sub print_local_time {
-	print format_local_time(@_);
-}
-
-sub format_local_time {
+# If localtime is disabled, show the server's local time in parentheses.
+# If localtime is enabled, show GMT in parentheses.
+sub print_alt_time {
 	my $localtime = '';
 	my %date = @_;
+	my ($h, $m, $tz) = ($date{'hour_local'}, $date{'minute_local'},
+		$date{'tz_local'});
+
+	if (gitweb_check_feature('localtime')) {
+		($h, $m, $tz) = ($date{'hour'}, $date{'minute'}, "+0000");
+	}
+
 	if ($date{'hour_local'} < 6) {
 		$localtime .= sprintf(" (<span class=\"atnight\">%02d:%02d</span> %s)",
-			$date{'hour_local'}, $date{'minute_local'}, $date{'tz_local'});
+			$h, $m, $tz);
 	} else {
 		$localtime .= sprintf(" (%02d:%02d %s)",
-			$date{'hour_local'}, $date{'minute_local'}, $date{'tz_local'});
+			$h, $m, $tz);
 	}
 
-	return $localtime;
+	print $localtime;
 }
 
 # Outputs the author name and date in long form
@@ -3982,7 +3987,6 @@ sub git_print_authorship {
 	print "<$tag class=\"author_date\">" .
 	      format_search_author($author, "author", esc_html($author)) .
 	      " [$ad{'rfc2822'}";
-	print_local_time(%ad) if ($opts{-localtime});
 	print "]" . git_get_avatar($co->{'author_email'}, -pad_before => 1)
 		  . "</$tag>\n";
 }
@@ -4009,7 +4013,7 @@ sub git_print_authorship_rows {
 		      "</td></tr>\n" .
 		      "<tr>" .
 		      "<td></td><td> $wd{'rfc2822'}";
-		print_local_time(%wd) if !gitweb_check_feature('localtime');
+		print_alt_time(%wd);
 		print "</td>" .
 		      "</tr>\n";
 	}
-- 
1.7.4.1
Previous: Junio C HamanoNext: Jakub Narebski
Message 7 of 17 in “gitweb: fix #patchNN anchors when path_info is enabled”
  1. 1/3 gitweb: fix #patchNN anchors when path_info is enabledKevin Cernekee, Mar 17, 2011
  2. 2/3 gitweb: introduce localtime featureKevin Cernekee, Mar 17, 2011
  3. 2/3 gitweb: introduce localtime featureJakub Narebski, Mar 18, 2011
  4. Junio C HamanoMar 18, 2011
  5. Jakub NarebskiMar 18, 2011
  6. Junio C HamanoMar 18, 2011
  7. 3/3 gitweb: show alternate author/committer timesKevin Cernekee, Mar 17, 2011
  8. 3/3 gitweb: Mark "atnight" author/committer times also for 'localtime'Jakub Narebski, Mar 18, 2011
  9. Kevin CernekeeMar 18, 2011
  10. Junio C HamanoMar 18, 2011
  11. Jakub NarebskiMar 18, 2011
  12. Junio C HamanoMar 19, 2011
  13. 1/3 gitweb: fix #patchNN anchors when path_info is enabledJakub Narebski, Mar 18, 2011
  14. Kevin CernekeeMar 18, 2011
  15. 1/3 gitweb: fix #patchNN anchors when path_info is enabledJakub Narebski, Mar 18, 2011
  16. Junio C HamanoMar 18, 2011
  17. Jakub NarebskiMar 18, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.