git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
EWEric Wong <normalperson@yhbt.net>
Date
Feb 12, 2012, 08:15 UTC
Message-ID
<20120212081553.GA10068@dcvr.yhbt.net>
In-Reply-To
<4EEEF199.4000404@gmail.com>
"\"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.
Previous: Wei-Yin Chen (陳威尹)Next: Wei-Yin Chen (陳威尹)
Message 2 of 3 in “git-svn: Fix time zone in --localtime”
  1. git-svn: Fix time zone in --localtimeWei-Yin Chen (陳威尹), Dec 19, 2011
  2. Eric WongFeb 12, 2012
  3. Wei-Yin Chen (陳威尹)Feb 12, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.