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

[PATCH 3/3 (alternate)] gitweb: Mark "atnight" author/committer times also for 'localtime'

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 18, 2011, 17:46 UTC
Message-ID
<201103181846.04979.jnareb@gmail.com>
In-Reply-To
<64c70e95e767572e5be732dc7e17815b@localhost>
From: Kevin Cernekee <cernekee@gmail.com>

By default, with 'localtime' feature disabled, the dates in 'commit', 'commitdiff' and 'tag' views show both GMT time, and localtime in recorded author/committer/tagger timezone, marking localtime with "atnight" class to notify times between 0 and 6 AM local time.

An example output can look like this:
  author   A U Thor <author@example.com>
           Wed, 16 Mar 2011 07:02:42 +0000 (02:02 -0500)
                                            ^^^^^

where underlined part is marked with "atnight" class (in red with default stylesheet).

If $feature{'localtime'} is enabled, we display the RFC 2822 date/time in the author's/committer's/tagger's local timezone; previous commit removed marking "atnight" times, because there wasn't separate local time to mark up after GMT time.

This commit makes gitweb mark _whole_ RFC 2822 date/time with "atnight" class for times between 0 and 6 AM.

An example output can look like this:
  author   A U Thor <author@example.com>
           Wed, 16 Mar 2011 02:02:42 -0500
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
where again underlined part is marked with "atnight".

We probably should mark only time part of RFC 2822 date/time with "atnight" class, but such solution would be more involved.

While at it fix whitespace, using spaces for align, tabs for indent.

NOTE that git_print_authorship subroutine is for now left as is; there is no caller in gitweb that uses it with -localtime=>1.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Kevin, how about something like this instead?  This preserves _intent_
for why there is local time beside GMT time when 'localtime' is disabled
better, I think.

Junio and Kevin, I am not sure if authorship should remain with Kevin, or should it revert to me; the solution is quite different.

About no-change to git_print_authorship: alternate solution would be to remove support for -localtime option, like in original patches.

 gitweb/gitweb.perl |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index cdc2a96..5bda0a8 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4003,15 +4003,23 @@ sub git_print_authorship_rows {
 		my %wd = parse_date($co->{"${who}_epoch"}, $co->{"${who}_tz"});
 		print "<tr><td>$who</td><td>" .
 		      format_search_author($co->{"${who}_name"}, $who,
-			       esc_html($co->{"${who}_name"})) . " " .
+		                           esc_html($co->{"${who}_name"})) . " " .
 		      format_search_author($co->{"${who}_email"}, $who,
-			       esc_html("<" . $co->{"${who}_email"} . ">")) .
+		                           esc_html("<" . $co->{"${who}_email"} . ">")) .
 		      "</td><td rowspan=\"2\">" .
 		      git_get_avatar($co->{"${who}_email"}, -size => 'double') .
 		      "</td></tr>\n" .
 		      "<tr>" .
-		      "<td></td><td> $wd{'rfc2822'}";
-		print_local_time(%wd) if !gitweb_check_feature('localtime');
+		      "<td></td><td> ";
+		if (gitweb_check_feature('localtime')) {
+			if ($wd{'hour_local'} < 6) {
+				print "<span class=\"atnight\">$wd{'rfc2822'}</span>";
+			} else {
+				print $wd{'rfc2822'};
+			}
+		} else {
+			print $wd{'rfc2822'} . format_local_time(%wd);
+		}
 		print "</td>" .
 		      "</tr>\n";
 	}
-- 
1.7.3
Previous: Kevin CernekeeNext: Kevin Cernekee
Message 8 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.