From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Wong Subject: Re: [PATCH] git-svn: Fix time zone in --localtime Date: Sun, 12 Feb 2012 08:15:53 +0000 Message-ID: <20120212081553.GA10068@dcvr.yhbt.net> References: <4EEEF199.4000404@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: git@vger.kernel.org, Pete Harlan , gitster@pobox.com To: Wei-Yin Chen =?utf-8?B?KOmZs+WogeWwuSk=?= X-From: git-owner@vger.kernel.org Sun Feb 12 09:16:00 2012 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RwUbI-0003o7-2h for gcvg-git-2@plane.gmane.org; Sun, 12 Feb 2012 09:16:00 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751227Ab2BLIPy convert rfc822-to-quoted-printable (ORCPT ); Sun, 12 Feb 2012 03:15:54 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:56500 "EHLO dcvr.yhbt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751014Ab2BLIPx (ORCPT ); Sun, 12 Feb 2012 03:15:53 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 55F371F451; Sun, 12 Feb 2012 08:15:53 +0000 (UTC) Content-Disposition: inline In-Reply-To: <4EEEF199.4000404@gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: "\"Wei-Yin Chen (=E9=99=B3=E5=A8=81=E5=B0=B9)\"" wrote: > 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. >=20 > Failed case can be illustrated like this in linux shell: > > echo $TZ > Asia/Taipei > > date +%Z > CST > > env TZ=3D`date +%Z` date > Mon Dec 19 06:03:04 CST 2011 > > date > Mon Dec 19 14:03:04 CST 2011 >=20 > Signed-off-by: Wei-Yin Chen (=E9=99=B3=E5=A8=81=E5=B0=B9) > --- Hi, sorry for the late reply, this got lost in the shuffle. This issue seems reasonable, but did you test this change at all? > sub format_svn_date { > - # some systmes don't handle or mishandle %z, so be creative. > my $t =3D shift || time; > - my $gm =3D timelocal(gmtime($t)); > - my $sign =3D qw( + + - )[ $t <=3D> $gm ]; > - my $gmoff =3D sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[= 2,1]); > + my $gmoff =3D get_tz($t); > return strftime("%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)", localtim= e($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 { =20 sub format_svn_date { my $t =3D shift || time; - my $gmoff =3D get_tz($t); + my $gmoff =3D 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.