Thread (1 message) 1 message, 1 author, 2016-06-15

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:48

Jakub Narebski [off-list ref] writes:
Junio C Hamano wrote:
...
quoted
and format_timestamp would be like

	sub format_timestamp {
		my %date = %$_[0];
      	my $use_localtime = $_[1];
		my $localtime, $ret, $nite;

		$nite = ($date{'hour_local'} < 6);

		if ($use_localtime) {
			$ret = $date{'rfc2822_local'};
      		if ($nite) {
                        	$ret = sprintf("<span class='atnight'>%s</span>", $ret);
			}
		} else {
			... what the current format_local_time does to set
	        	... including the spanning part
              	$ret = "$date{'rfc2822'} ($localtime)";
		}
		return $ret;
	}
Well, if we go this route, and assuming that parse_date does only parsing
and we use separate subroutine for generating date in an rfc2822 format,
then we could mark only time with "atnight" also when 'localtime' feature
is enabled.
 
quoted
Wouldn't it be much cleaner?  You can then clean up the other call site of
print_local_time in git_print_authorship using the same helper function
(presumably you would always pass 0 to $use_localtime there), no?
Right.  Well, I'd have to think a bit about API for format_timestamp,
but it looks like good direction.
I don't think there is much to think about for format_timestamp, as I was
suggesting to keep what comes in %date more or less the same as what the
current parse_date() generates.  I was only hinting that parse_date() is
misnamed.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help