From: Jakub Narebski Date: Fri, 18 Mar 2011 17:46:02 GMT Subject: [PATCH 3/3 (alternate)] gitweb: Mark "atnight" author/committer times also for 'localtime' Message-ID: <201103181846.04979.jnareb@gmail.com> In-Reply-To: <64c70e95e767572e5be732dc7e17815b@localhost> From: Kevin Cernekee 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 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 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 Signed-off-by: Jakub Narebski --- 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 "$who" . 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"} . ">")) . "" . git_get_avatar($co->{"${who}_email"}, -size => 'double') . "\n" . "" . - " $wd{'rfc2822'}"; - print_local_time(%wd) if !gitweb_check_feature('localtime'); + " "; + if (gitweb_check_feature('localtime')) { + if ($wd{'hour_local'} < 6) { + print "$wd{'rfc2822'}"; + } else { + print $wd{'rfc2822'}; + } + } else { + print $wd{'rfc2822'} . format_local_time(%wd); + } print "" . "\n"; } -- 1.7.3