Re: [PATCH] git-svn: Fix time zone in --localtime
"\"Wei-Yin Chen (陳威尹)\"" <chen.weiyin@gmail.com> wrote:
Show 19 quoted lines
> Use numerical form of time zone to replace alphabetic time zone
> abbreviation generated by "%Z". "%Z" is not portable and contain
> ambiguity for many areas. For example, CST could be "Central
> Standard Time" (GMT-0600) and "China Standard Time" (GMT+0800).
> Alphabetic time zone abbreviation is meant for human readability,
> not for specifying a time zone for machines.
>
> Failed case can be illustrated like this in linux shell:
> > echo $TZ
> Asia/Taipei
> > date +%Z
> CST
> > env TZ=`date +%Z` date
> Mon Dec 19 06:03:04 CST 2011
> > date
> Mon Dec 19 14:03:04 CST 2011
>
> Signed-off-by: Wei-Yin Chen (陳威尹) <chen.weiyin@gmail.com>
> ---
Hi, sorry for the late reply, this got lost in the shuffle.
This issue seems reasonable, but did you test this change at all?
Show 9 quoted lines
> sub format_svn_date {
> - # some systmes don't handle or mishandle %z, so be creative.
> my $t = shift || time;
> - my $gm = timelocal(gmtime($t));
> - my $sign = qw( + + - )[ $t <=> $gm ];
> - my $gmoff = sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]);
> + my $gmoff = get_tz($t);
> return strftime("%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)", localtime($t));
> }I needed the following additional change to get things working:
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -6111,7 +6111,7 @@ sub run_pager {
sub format_svn_date {
my $t = shift || time;
- my $gmoff = get_tz($t);
+ my $gmoff = Git::SVN::get_tz($t);
return strftime("%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)", localtime($t));
}
If there are no objections, I'll squash this and push for Junio
tomorrow.