From: Jakub Narebski <jnareb@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Kevin Cernekee <cernekee@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 3/3 (alternate)] gitweb: Mark "atnight" author/committer times also for 'localtime'
Date: Fri, 18 Mar 2011 23:28:13 +0100 [thread overview]
Message-ID: <201103182328.19141.jnareb@gmail.com> (raw)
In-Reply-To: <7vmxksw3x8.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
> > 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.
>
> I don't think it is worth anything to keep dead code that anybody
> exercises to support -localtime option that nobody asks.
Right. Especially that refactoring would significantly change this
code.
> I thought we were getting closer (especially if you consider my suggestion
> to the earlier round, but obviously I am biased), but this looks far worse
> than your previous clean-up of Kevin's patch. What is the point of
> duplicating the atnight logic her? Why not kill the useless helper
> function "print-local-time", and instead enhance "format-local-time" so
> that whatever this added code does is performed there when the caller asks?
You are right. I concentrated on the fact that IMVHO Kevin's version of
this 3/3 solved wrong issue (the problem is not GMT + local, but atnight
which needs localtime), but forgot to stop to think how ugly and
duplicated the code is... or at least mark this patch as RFC, request
for comments on resulting look.
> Then the caller here would look more or less like:
>
> print "<tr><td>$who</td>" .
> "... author name, email, avatar ..." .
> "<td></td><td>" .
> format_timestamp(\%wd, gitweb_check_feature('localtime')) .
> "</td></tr>\n";
Right.
>
> 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.
> 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.
--
Jakub Narebski
Poland
next prev parent reply other threads:[~2011-03-18 22:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-17 19:38 [PATCH v2 1/3] gitweb: fix #patchNN anchors when path_info is enabled Kevin Cernekee
2011-03-17 19:38 ` [PATCH v2 2/3] gitweb: introduce localtime feature Kevin Cernekee
2011-03-18 14:40 ` [PATCH v3 " Jakub Narebski
2011-03-18 18:24 ` Junio C Hamano
2011-03-18 21:58 ` Jakub Narebski
2011-03-18 22:42 ` Junio C Hamano
2011-03-17 19:38 ` [PATCH 3/3] gitweb: show alternate author/committer times Kevin Cernekee
2011-03-18 17:46 ` [PATCH 3/3 (alternate)] gitweb: Mark "atnight" author/committer times also for 'localtime' Jakub Narebski
2011-03-18 19:07 ` Kevin Cernekee
2011-03-18 20:48 ` Junio C Hamano
2011-03-18 22:28 ` Jakub Narebski [this message]
2011-03-19 1:25 ` Junio C Hamano
2011-03-18 12:59 ` [PATCH v3 1/3] gitweb: fix #patchNN anchors when path_info is enabled Jakub Narebski
2011-03-18 15:25 ` Kevin Cernekee
2011-03-18 16:00 ` [PATCH v3 (amend) " Jakub Narebski
2011-03-18 16:57 ` [PATCH v3 " Junio C Hamano
2011-03-18 17:18 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201103182328.19141.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=cernekee@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).