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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Kevin Cernekee <cernekee@xxxxxxxxx>

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@xxxxxxxxxxx>
           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@xxxxxxxxxxx>
           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@xxxxxxxxx>
Signed-off-by: Jakub Narebski <jnareb@xxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]