Re: [PATCH] git-svn: Fix time zone in --localtime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"\"Wei-Yin Chen (陳威尹)\"" <chen.weiyin@xxxxxxxxx> 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.
> 
> 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@xxxxxxxxx>
> ---

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 = 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]